Description
Details
- Branch
- Development
- Reproducable without other mods?
- Yes
Needs to be evaluated of the function of that script (disabling the lights on a powerline post) can be moved to the Land_class/p3d/engine entirely.
@NeoArmageddon Let me know how that goes, sometime in the next 2 months I will refactor this.
My suggestions:
- should activate only when compatible lamps are present in terrain or mission (and module to manual activate it) - alternative would be init EH in the object class with isNil check for already running
- check sun state every 0.25s seems too much
- not checking for CUP_lampState change first
- positionCameraToWorld and pos check every 0.5s seems too much (could be made based on speed/vehicle type one is in)
- nearObjects check every 0.5s (relevant when flying fast) instead of caching relevant object positions
- (minor) not saving both texture paths to variable (instead _m = format ['ca\Structures\Misc_Powerlines\Data\powlines_%1.rvmat',['multi1','light1'] select CUP_lampState];)
- (minor) not saving damaged texture path to variable
I am in favour of removing this completely. Does anyone even notice a difference? No other terrain mod does this, CUP should not either. This can easily be a separately published script if someone really really wants it, it will never be good enough for inclusion in CUP Terrains.
As for refactoring, @kju's suggestions are rather irrelevant in terms of performance, important are:
- Run only on server with `setObjectMaterialGlobal˙
- Second loop is pointless, value is global, just change all the lamps if state changes instead of looping over all lamps in 400m range if you moved 100m (~commy2)
- Use 1s PFH
- Use unscheduled
In addition:
- Code cleanup
- Comments! (who knows that's sunrise formula from their head)
Entire thing can be made way shorter and way more efficient.
@NeoArmageddon any progress on moving this to models. Vanilla lamp posts seem to do that.