1 Reply Latest reply on Jul 14, 2010 5:24 AM by Psioniq

    "Reverse Parent Lookup"




      Not quite sure if I should post this here, or in the 3D section - but here goes (in here ^^)


      I'm currently in the process of scripting a 3D interface system which has a simple scenegraph associated with it.


      Now, all my objects have an ancestor class called "node", which ties into the scenegraph - these nodes have a property called pEnabled and if this is set to true, all of its children will receive updates on stepframe  - and it works pretty good so far.


      But - here is my "problem".. (my approach might not be the best for this - but hopefully one of you can help me out)


      I have a mouse class that repeatedly updates a list of models under the mouse location - the interface "manager" grabs this data on every update and does a check to see if the model is present in any of the ui element nodes.


      If the model is present in the list, I want to enable this node - but - I also want to enable its parent.. and the parents parent.. and the parents, parents parent etc. - until it reaches the rootnode (the ui "manager", which should always be enabled) :]


      The reason for doing this, is that I want to cut down on the amount of updates running per frame, as the renderer slows down quite a bit when I have more than ~100 enabled ui elements running - each with their own set of ancestor scripts.


      As mentioned - my approach might not be optimal - or even possible - but if any of you have any insight on how to accomplish something like this, I'd greatly appriciate the feedback.



      Thanks in advance :]

        • 1. Re: "Reverse Parent Lookup"
          Psioniq Level 1

          Ooohkay... seems like I figured it out.


          I made two simple functions for enabling and disabling:


          on enable me 

            if voidP(me.pParent.getaprop(#pElements)) then

              --- If the parent script is a ui element, enable it


            end if 

            --- Enable this element

            me.pEnabled = true

          end me


          Basically just running the enable() / disable() function on all parents until it reaches the ui "manager".. works like a charm.. so far -.^

          Feel free to comment anyway if any of you have anything you'd like to add :]