Refactor emissiveLights.sqf
Assigned, Unbreak Now!Public


Reproducable without other mods?
Cyruz created this task.Jan 20 2019, 4:06 PM

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.

jonpas claimed this task.Jan 20 2019, 4:08 PM

@NeoArmageddon Let me know how that goes, sometime in the next 2 months I will refactor this.

kju added a subscriber: kju.Apr 12 2019, 10:04 AM

My suggestions:

  1. 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
  2. check sun state every 0.25s seems too much
  3. not checking for CUP_lampState change first
  4. positionCameraToWorld and pos check every 0.5s seems too much (could be made based on speed/vehicle type one is in)
  5. nearObjects check every 0.5s (relevant when flying fast) instead of caching relevant object positions
  6. (minor) not saving both texture paths to variable (instead _m = format ['ca\Structures\Misc_Powerlines\Data\powlines_%1.rvmat',['multi1','light1'] select CUP_lampState];)
  7. (minor) not saving damaged texture path to variable
jonpas updated the task description. (Show Details)Jul 10 2019, 11:14 PM
jonpas added a comment.EditedJul 10 2019, 11:30 PM

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.

Freddo3000 changed the task status from Needs Review to Assigned.Jan 8 2020, 11:58 AM
Freddo3000 triaged this task as Unbreak Now! priority.Mar 11 2020, 9:42 AM