JackFalcon Posted July 17, 2018 Share Posted July 17, 2018 Question about setEnabled(false). Is it better performance than visibility = 0 ? And wondering what is the difference? If 1 mesh is rotating 10 children, and 5 can be hidden - which is more performant: visibility or setEnabled(false); I'll test it.... Lots of reading. Thanks! Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 17, 2018 Share Posted July 17, 2018 I would be very surprised if visibility = 0 has higher performance. There are too many checks (ie: that break a for loop on mesh.isEnabled()) for disabled that are before visibility checks... Interested to see any statistics. JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Hersir Posted July 17, 2018 Share Posted July 17, 2018 Hi @aFalcon visibility = 0 will just not render mesh, but will do matrix calculations (position, rotation e.c), but if you set enabled false, it will not perform these calculations, so enabled false should be more performant. JackFalcon, adam and Dad72 3 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 17, 2018 Share Posted July 17, 2018 Hersir has right. setEnabled(false) no longer makes the mesh on the scene, but visibility=0 just makes the mesh invisible but still rendered as if it were visible somehow. JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted July 17, 2018 Author Share Posted July 17, 2018 Statistics -->great idea<-- Thank you setEnabled(true) insight! TINY-UPDATES: - the code below worked well as first pass rough-in. RESULTS: performance improvement achieved! (ding). - Will try setEnabled... on parents - -> But had interesting PROBLEM: need parent setEnabled(true) AND children setEnabled(false)???<-- anyway... : ) - Hello LOD! too. - Probably date.now all three [hope] (BZ thx). reloadLevel = function(){ for(var i=0; i<edges.length; i++){ edges[i].visibility = 1; } for(var i=0; i<orbs.length; i++){ orbs[i].visibility = 1; } for(var i=0; i<boxes.length; i++){ boxes[i].visibility = 1; } for (var i=0; i<tiles.length; i++){ tiles[i].visibility = 1; } } unloadLevel = function(){ for(var i=0; i<edges.length; i++){ edges[i].visibility = 0; } for(var i=0; i<orbs.length; i++){ orbs[i].visibility = 0; } for(var i=0; i<boxes.length; i++){ boxes[i].visibility = 0; } for (var i=0; i<tiles.length; i++){ tiles[i].visibility = 0; } } Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted July 17, 2018 Author Share Posted July 17, 2018 Ok, Put in TIMESTAMPS ... gotta go. Thanks to who'ever made dude. Here is adapted timestamp utility, to easily measure performance anywhere: //TIMER var timeStamp = 0; var currentTimeStamp = 0; var timeReport = function(testname){ console.log('TIMESTART: '+testname); if(!timeStamp){ timeStamp = new Date().getTime(); } return function (testname) { currentTimeStamp = new Date().getTime(); var timeDelta = currentTimeStamp - timeStamp; console.log('TIMESTOP: '+testname+' = '+timeDelta); timeStamp = null; } } //EXAMPLE-USAGE-. // var debugTimeStop = timeReport('START Time Test'); // debugTimeStop('END Time Test'); Statistics pending... Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted July 19, 2018 Author Share Posted July 19, 2018 rudimentary stats... TEST DESCRIPTION: rotating parent with gradual increasing number of children(30,60,90) for each rotation, step-interpolation = 0.02, on a closed-circuit track. BASELINE NO-PERF-OPS 3 CONTROL-TESTS: TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 1867 TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 4294 TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 6724 OP-TEST-1 visibility = 0 3 COMPARISON-TESTS: TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 1937 TIMESTOP: END-ORBIT = 4237 TIMESTOP: END-ORBIT = 4679 OP-TEST-1 RESULTS: Within variance, visibility = 0 for hidden mesh, reduces orbit time ~2 seconds on third rotation (HOO-RAY). QUESTION: which is better visibility or setEnabled(false)? Bird should read source code, or... TEST: replace vis =0 to setEnable(false) in the same loops... TIMESTART: START-ANIMATION TIMESTOP: END-ORBIT = 1917 TIMESTOP: END-ORBIT = 4227 TIMESTOP: END-ORBIT = 4778 RESULTS: Interesting - visibility is slightly faster (within variance). Didn't expect that. Bird should read source code. NOTE: couldn't use setElement(false) at parent level because in context need parent to remain visible, and only children hidden. NEXT-STEPS: Not going to do LOD test, sticking with simple visibility op for the moment. Instances not applicable. This is solved. Maybe more PERFOPS later. Hope this helps someone. brianzinn and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.