EveTriggerVolume implementation - #69
Conversation
Stop unregistered the updateable but kept the action's reference to the emitter, so the emitter outlived the action that was driving it.
Volumes gain a persisted enabled attribute, so a placement can switch between trigger shapes without editing the shape list, and a name accessor so per-placement names can be read back off a volume. Implemented for the box, sphere and ellipsoid shapes. Only EveTriggerVolume honours the flag so far: fog volumes, post process volumes, lighting overrides, procedural containers and distribution placement generators still evaluate every volume they are given.
A top-level scene object whose trigger region is a list of IEveVolume shapes placed relative to its own translation and rotation, editable in Graphite like any other space object. Each synchronous update it evaluates the tracked position against the enabled volumes and keeps the inside/outside state, exposed read-only as isInside and intensity. A local bounding sphere over the enabled volumes acts as the broad phase for the point test and provides the bounds for picking, falling back to a unit radius so an object with no volumes set up yet stays selectable.
SetCallback stores a Python callable that is invoked as callback( name, entered ) whenever the tracked position crosses the threshold. Transitions are detected during update, so the call is deferred to the post-update point on the main thread; the object is locked while the callback is queued and unlocked once it has run, so it cannot be destroyed in between.
The highest intensity among the exclusion volumes is subtracted from the trigger intensity and clamped at zero, so a region can have holes in it without modelling the remainder as separate shapes.
Draws the trigger volumes - green while the tracked position is inside, white otherwise - the exclusion volumes in red, and the broad-phase bounding sphere, each under its own debug option. forceTriggered pins the trigger into the entered state so a setup can be exercised in Graphite with no ball attached.
External parameters expose per-placement values for dungeon asset manipulations, and the translation/rotation curve slots let the client attach the object's own destiny ball instead of driving the object from the static translation and rotation attributes. The callback name now prefers the first enabled volume's name: external parameters in a .red file cannot reference the root object, so per-placement names are bound to a volume, and the client overwrites the root name attribute with the destiny ball ID when adding the object to the scene.
- some docs fixes
- documentation fixes
| void Tr2ActionBindRTPC::Stop( ITr2ActionController& controller ) | ||
| { | ||
| controller.UnRegisterUpdateable( *this ); | ||
| m_emitter = nullptr; |
There was a problem hiding this comment.
How is this related to the PR? I vaguely remember this change as fixing a memory leak. Should it be in a separate PR?
| translation = m_translation; | ||
| } | ||
|
|
||
| m_worldTransform = RotationMatrix( m_rotation ) * TranslationMatrix( translation ); |
There was a problem hiding this comment.
Why are you not taking ball's rotation into account?
| } | ||
| else | ||
| { | ||
| translation = m_translation; |
There was a problem hiding this comment.
Isn't it awkward that m_translation is only used until the volume is attached to the ball?
| if( inside != m_isInside ) | ||
| { | ||
| m_isInside = inside; | ||
| QueueCallback( inside ); |
There was a problem hiding this comment.
As we discussed before, I don't see the reason to queue these callbacks: UpdateTriggerState is only called from UpdateSyncronous, always on the main thread. It should be safe to call Python directly in this context, or am I missing something?
There was a problem hiding this comment.
I completely forgot to address this one after our discussion.
Description
EVETriggerVolumesimply triggers a Python callback when a tracked position crosses into or out of a volume region.When authoring a trigger volume in Graphite you will see more options (e.g trigger a Node graph) but these don't directly affect trinity.
gTriDev->AddPostUpdateCallbackwith the objectLock()ed, soPython is only touched at post-update on the main thread , similar to what
TriEventCurvedoes.EveBoxVolume/EveSphereVolume/EveEllipsoidVolumethrough theIEveVolumeinterface.
IEveSpaceObject2,IWorldPosition,IInitializeandITr2DebugRenderable.Testing
Tested for Frontier, the volume authoring code changes will be a separate PR for platformtools together with monolith changes.
In the demo volumes will trigger 3 custom callbacks:
demo.mp4