Hi All (but mostly Greg),
I wrapped rtrace into c++ singleton class to provide an interface for dynamic calls calls to rtrace without reloading the scene each time. Additionally I am adding the light sources (sky and/or sun(s)) after the main octree is built so they will live at the end of the object list. This way I can pop them off using freeobjects() and then add new sources (again, without reloading the scene, I only need to reinitialise the ambient cache). This was all working swimmingly until I tried to render a scene with a mixfunc:
fatal - undefined modifier "f" for mixfunc "glz"
This is when I discovered that the call to clearobjndx() within freeobjects() completely resets the modifier and object tables, explaining the error I get when mixfunc cannot find its component modifiers.
To get around this for now, I have done this (where nobjs is the argument passed to freeobjects():
/* EDIT: Don't free tables if only removing a few objects this probably means we want to use them again */ if (nobjs > 10) clearobjndx();
This is obviously not a very good solution. so my questions are:
- Is there a simple way to only clear the relevant items in the table?
- Or, since later entries always take precedence, is it actually necessary to clear the modifier table ever?
- What is the object table used for? I am surprised I haven’t encountered any issues sooner with these to tables completely reinitialised. Would this be an issue if I had a mesh in my scene?
- Should I just make a new function (free_some_objects()) that omits the clearobjindx() call, and only use freeobjects() when I really want to clear everything?