Hi CumQuaT, I just took a look through advanced lighting and have just realized how many modifications evolved has really made.
It seems that Evolved has also added a way to exclude objects from the main screen render(s) while still allowing them to cast shadows. To remove/re-add objects to the main render, just call:
Object_Mask_Frame(ObjID,masked)
Object_Mask_AdvancedLighting(ObjID,masked)
That can be used for culled objects which are still casting a visable shadow.
I also notice that the
Object() array isn't being sorted in any way, and that the object-array lookups could be sped up with binary searches.
I see a lot of unneeded looping, for example:
function Object_Set_Static(ObjNumber)
if AdvancedLightingEnabled=1
Object=Object_FindArray(ObjNumber)
obj=-1
//this loop goes through every dynamic object even when it shouldn't
for o=1 to array count(DynamicObjNum())-1
if DynamicObjNum(o)=Object then obj=o
next o
if obj>-1
array delete element DynamicObjNum(),obj
endif
endif
endfunction
could be changed to:
function Object_Set_Static(ObjNumber)
if AdvancedLightingEnabled=1
Object=Object_FindArray(ObjNumber)
for o=1 to array count(DynamicObjNum())-1
if DynamicObjNum(o)=Object
array delete element DynamicObjNum(),o
//quit searching when the object is found
exitfunction
endif
next o
endif
endfunction
Almost all of the "
Object_..()" functions make a call to
Object_FindArray() which means alot of unneeded searches. That could be optimized by editing the functions to accept the object's array index, so you can call
Object_FindArray() yourself and avoid the extra searches. That would mean that the function could be farther re-written to:
function Object_Set_Static(ObjIndex)
if AdvancedLightingEnabled=1
for o=1 to array count(DynamicObjNum())-1
if DynamicObjNum(o)=ObjIndex
array delete element DynamicObjNum(),o
//quit searching when the object is found
exitfunction
endif
next o
endif
endfunction
Nearly every function starts off with "if AdvancedLightingEnabled=1" which could be removed since you should know yourself weather or not it has been setup. It is good practice (even more so when releasing libraries to others) but it means performing alot of worthless checks.
Alot of this stuff doesn't make much of a difference until your ObjectQT gets up there, but it just seems like a good idea to leave as much time for your game logic as possible.