View Issue Details

IDProjectCategoryView StatusLast Update
0003823The Dark ModCodingpublic12.12.2014 08:20
Reportertels Assigned ToSteveL  
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product VersionTDM 2.02 
Summary0003823: trigger_touch performance does scale poorly
Descriptiontrigger_touch compares its own clipmodel to all clipmodels in the map, in each frame. It then calls a global script function with one parameter (the entity) for each entity that touches the trigger.

It will also activate all its targets each time one entity touches the trigger in each frame.

This is quite wasteful, and also makes it rather hard to use the trigger in scripting (because the function gets only passed the touching entity, but not the trigger it touches).

Proposed changes are:

* implement a "wait" (in seconds) spawnarg like for other trigger types. The trigger will not fire until "wait" seconds have passed. The default for this spawnarg can be 0 (to emulate the current behaviour), or f.i. 0.1 to limit the trigger to 10 firings/second (instead of 60). If "wait" is defaulting to "0", "editor_SetKeyValue wait" "0.1" can be used to at least set it to "0.1" for newly created triggers.

* implement "passSelf" and "passActviator". Both default to "0" and "1" to keep current behaviour. If "passSelf" is "1" and "passActivator" "0", call( trigger ) is executed. If passActivator "1" and passSelf "0", the call( activator ) (touching entity) is called, If both are 1, call( trigger, activator ) is called. Just like trigger_multi. This will allow scripts to know both the activator and the trigger entity.

* implement "event". If set, a scripting event (method) on each target entity of the trigger is called, if the target has scriptobject and this has the named method. Like with call(), "trigger" and "activator" are passed depending on passSelf and passActivator. This allows the call to be relayed to a scriptobject w/o having an intermediate "atdm:target_callScriptEvent" entity just to relay the call to a method.

* implement a "noactivate" spawnarg (this could also be added to trigger_multi). If set to "1", the trigger will not activate it's targets when it fires. (this feature would allow to store entities as trigger targets without having them to be "activated") Useful in combination with "event" above.
Additional Informationhttp://forums.thedarkmod.com/topic/16479-scripting-atdmtarget-callobjectfunction-and-triggers-and-activating-entities/page__view__findpost__p__352729
TagsNo tags attached.

Activities

tels

tels

07.09.2014 15:41

reporter   ~0006955

Last edited: 08.09.2014 17:07

Here is a patch implementing "wait", "random", "delay", "random_delay" on idTrigger_Touch, as well as "pass_self" and "pass_activator":

http://swift-mazes.com/pub/tdm-patches/tels_patch_c_trigger_2014-09-08.txt

tels

tels

08.09.2014 15:30

reporter   ~0006964

Attached is a testmap with three trigger_touch entities.

The first is the original setup, calling a routine every frame (60/s) with one argument (the player1 if you step on the plate).

The center one uses wait 0.2 and pass_self, it will call another function 5/s with the trigger as argument.

The center one uses wait 0.5 and pass_self and pass_activator, it will call another function 2/s with the trigger and the entity (player1) as argument.
tels

tels

08.09.2014 16:29

reporter   ~0006965

Here is a patch adding the spawnarg documentation:

http://swift-mazes.com/pub/tdm-patches/tels_patch_e_trigger_2014-09-08.txt
tels

tels

08.09.2014 16:40

reporter  

smtest.pk4 (19,013 bytes)
tels

tels

08.09.2014 16:50

reporter   ~0006966

Updated the patches to take out the "wait < 0" checks (wait = -1 means "trigger only once") and also updated the testmap.
SteveL

SteveL

18.11.2014 21:32

reporter   ~0007143

Committed at rv6153 (code), rv14073 (def)

triggers.def

Trigger.h
Trigger.cpp
SteveL

SteveL

12.12.2014 08:20

reporter   ~0007249

Partially reverted at rv6391 -- removed the 2-frame delay at map start before trigger multis are enabled due to side effects on maps that target a trigger multi from the worldspawn. Trigger touch changes remain.

Issue History

Date Modified Username Field Change
22.08.2014 10:36 tels New Issue
07.09.2014 15:41 tels Note Added: 0006955
08.09.2014 15:28 tels File Added: smtest.pk4
08.09.2014 15:30 tels Note Added: 0006964
08.09.2014 16:29 tels Note Added: 0006965
08.09.2014 16:40 tels File Deleted: smtest.pk4
08.09.2014 16:40 tels File Added: smtest.pk4
08.09.2014 16:50 tels Note Added: 0006966
08.09.2014 17:07 tels Note Edited: 0006955
12.09.2014 19:18 tels Assigned To => SteveL
12.09.2014 19:18 tels Status new => assigned
18.11.2014 21:32 SteveL Note Added: 0007143
18.11.2014 21:32 SteveL Status assigned => resolved
18.11.2014 21:32 SteveL Resolution open => fixed
12.12.2014 08:20 SteveL Note Added: 0007249