Scene Graph Collision Bugs

Summary

When using the entity.FindSweepHits or entity.FindOverlapHits functions. They seems to output the entire history of the collisions rather than just the currently occurring collisions.

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

Write a verse scene graph component which checks for collision of itself with other objects in a loop. Here is a script with a simple movement mechanism and a collision check:


using { /Verse.org }
using { /Verse.org/Native }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SceneGraph }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Assets }
using { /UnrealEngine.com/Temporary/Diagnostics }

blob_component := class<final_super>(component):

@editable
CheckCollision : logic = false

@editable
var Direction : vector3 = vector3{ X := 0.0, Y := 0.0, Z := 0.0 }

var CumulativeTime : float = 0.0

@editable
var Speed : float = 25.0

var MaybeCancelable : ?cancelable = false

PostPhysics(Delta : float) : void = 
    set CumulativeTime += Delta

    if(CumulativeTime >= 2.5*6):
        set Speed = Speed * -1
        set CumulativeTime = 0.0
    
    CurrentTransform := Entity.GetGlobalTransform()
    NewTranslation := CurrentTransform.Translation + Delta*Speed*Direction

    Entity.SetGlobalTransform(transform{ 
        Translation := NewTranslation, 
        Rotation := CurrentTransform.Rotation, 
        Scale := CurrentTransform.Scale
    })


OnInitialized<override>():void = 
    Print("On initialized")

OnAddedToScene<override>():void=
    Print("On added to scene")



EntityEntered(MyEntity : entity) : void = 
    Print("Entity Entered")


OnBeginSimulation<override>():void =
    (super:)OnBeginSimulation()

    set MaybeCancelable = option. TickEvents.PostPhysics.Subscribe(PostPhysics)

    Print("OnBeginSimulation")

    if:
        CheckCollision?
        MeshComponent := Entity.GetComponent[mesh_component]
    then:
        Print("Has meseh component")
        MeshComponent.EntityEnteredEvent.Subscribe(EntityEntered)



var LoopCount : int = 0


OnSimulate<override>()<suspends>:void =
    Print("OnSimulate")

    if(CheckCollision?):

        loop:
            Print("LoopCount: {LoopCount}")
            set LoopCount += 1
            Sleep(0.5)
            Hits := Entity.FindSweepHits(vector3{ X := 0.0, Y := 0.0, Z := 0.0})
            for(Hit : Hits):
                Print("Hit")

OnEndSimulation<override>():void = 
    Print("On End simulation")

    if(Cancelable := MaybeCancelable?):
        Cancelable.Cancel()

OnRemovingFromScene<override>():void = 
    Print("On removing from scene")

OnUninitializing<override>():void = 
    Print("On uninitializing")

To use it, simply attach the component to two entities in the scene and ensure they are configured to overlap during their oscillation. 

### Expected Result
While overlapping, there are printed results from the overlap hits. When not overlapping, there are no results. 

### Observed Result
It can be observed that while the EntityEnteredEvent, and EntityExitedEvent fire correctly, but the number of hits continuously build up.

### Platform(s)
UEFN







### Additional Notes
This occurs with both the Sweep and Overlap functions. It seems that these functions may be wrappers of the event system, and the EntityExitedEvent is failing to cause a removal from whatever data structure the collisions are stored in.