Game Development Community

RESOLVED setRenderEnabled(bool) ConsoleMethod

by Steve Acaster · in Torque 3D Professional · 02/21/2010 (7:44 pm) · 6 replies

Not a bug, just a request for %obj.setRenderEnabled(bool) be exposed to script, as I believe it could help enormously with performance in situations where portals/zones are not used or are inappropriate.

NEVER A BUG - AND I HAVE A SOLUTION -> SO MOVED TO RESOLVED

#1
02/21/2010 (8:59 pm)
In fact, this can be used in script already. Just assign to the 'isRenderEnabled' property of SceneObject. It calls the function internally.
#2
02/21/2010 (9:57 pm)
At the end of sceneObject.cpp
//yorks start
ConsoleMethod( SceneObject, isRenderEnabled, bool, 2, 2, "Are we Rendering?")
{
   return object->isRenderEnabled();
}//yorks end

And called in-game from the console or a script with:
%obj.isRenderEnabled=0;//don't render
%obj.isRenderEnabled=1;//do render

Result! Nice and easy that one.
#3
02/21/2010 (10:07 pm)

Yep, nice and easy. You don't need the extra method, though, but can go directly through the isRenderEnabled property--which in fact you are doing in the example above. Assigning and reading the property will internally call the respective methods on SceneObject.

if( %obj.isRenderEnabled )
   doSomethingWith( %obj );

%obj.isRenderEnabeld = true; // enable rendering
#4
02/21/2010 (10:24 pm)
*Falls off his chair laughing*

All this time, I hadn't realized that doSomethingWith(%obj) was an actual script, I had always thought it was like a psuedo-script example meaning "your stuff goes here".

Doh!

But yeah, tested that in a stock build and works fine.
#5
02/21/2010 (10:34 pm)

Oh, actually, it *is* meant as a "your stuff goes here" thing. Me putting comments in there on this probably wouldn't have hurt.

Anyways, the isRenderEnabled property works read&write out of the box. Kind of nice to obviate the need for extra methods by hiding more complex read/write logic behind properties.
#6
02/21/2010 (10:53 pm)
Yeah I just did a find in files and realised that ... but it's the second line that is required to *can't_think_of_the_word* (pass? call?) the object along.

//my TsStatic is called "big1"

// --- fails
if(big1.isrenderenabled) 
  big1.isrenderenabled=0;
// --- /fails

// --- works
if(big1.isrenderenabled) 
  LiterallyAnythingHere(big1); 

big1.isrenderenabled=0;
// --- /works