MantisBT - opensim
View Issue Details
0008010opensim[REGION] Physics Enginespublic2016-08-26 16:332017-08-14 18:55
Kayaker Magic 
Robert Adams 
normalmajoralways
assignedopen 
OSGridOpenSim 0.90.9.0.0 Dev OSgr
 
 
Grid (1 Region per Sim)
BulletSim
Mono / Linux64
3.0
FireStorm
0008010: BulletSim does not always call collision events on collisions
In Mantis 8009 I reported that sometimes a small object passes through a larger one without generating collision events. Sometimes they do generate collision events. There is a third behavior that happens often: The bullet object bounces off the target object but does not generate any collision events in either object. Since it does bounce off, the collision is being detected, it is just not being reported to the scripts by calling the events.
To see this problem, put the target script below into a 4x0.5x4 meter box and name the box target. Put the bullet script into a 1x0.1x0.1 box. Mark the bullet physical and temporary and name it bullet. Put the bullet prim and the bullet script in a gun prim. Point the +x axis of the gun at the target and click it to fire. The distance and angle of the gun to target makes things fail at different rates. So move the gun around and try again until you see failures. With a 1 meter bullet you will see all three behavors: sometimes the bullet flies through with no collisions, sometimes it collides correctly, and sometimes it bounces off without generating any collisions (until it falls down to the ground and gets a land_collision_start).
  //target script
//put this in any prim, it tells you when it gets collision events
default
{
    collision_start(integer num)
    {
        llOwnerSay("collision start name="+llDetectedName(0));
    }
    collision(integer num)
    {
        llOwnerSay("collision name="+llDetectedName(0));
    }
    collision_end(integer num)
    {
        llOwnerSay("collision end name="+llDetectedName(0));
    }
   
}


//bullet script
//put this in a prim, mark the prim as PHYSICAL and TEMPORARY
//put the resulting prim in the inventory of a gun
default
{
    collision_start(integer num)
    {
        llOwnerSay("start hit="+llDetectedName(0));
        llDie();
    }
    land_collision_start(vector pos)
    {
        llOwnerSay("land pos="+(string)pos);
        llDie();
    }
    
}


//gun script
//put this script and a bullet in in a small (less than 0.5m tall) object
//when you click it, it fires a bullet in the local +X direction, so turn to aim with the build tools
//Don't wear this object, think of it as a cannon
default
{
    state_entry()
    {
        llSetText("touch to fire",<1,0,0>,1.0);
    }
    touch(integer num)
    {
        llOwnerSay("Bang!");
        llRezObject(llGetInventoryName(INVENTORY_OBJECT,0), //rez the first object in inventory
            llGetPos()+<0,0,0.5>,<30,0,0>*llGetRot(),llGetRot(),0);
    }
}
No tags attached.
Issue History
2016-08-26 16:33Kayaker MagicNew Issue
2016-09-27 11:38Robert AdamsAssigned To => Robert Adams
2016-09-27 11:38Robert AdamsStatusnew => assigned
2016-10-02 15:25Robert AdamsNote Added: 0031174
2017-08-14 18:55Robert AdamsNote Added: 0032250

Notes
(0031174)
Robert Adams   
2016-10-02 15:25   
First of all, thanks for the wonderful reproduction setup -- this problem was easy to duplicate. That said, I don't have a fix yet.

The problem with passing through the target is that the bullets are small (0.1x0.1x0.1) which is below some the default collision thresholds set for BulletSim. Using a bigger bullet (like 0.5x0.5x0.5) stops the passing through. I'll have to play with parameter settings to see if there is a region setting that works for the smaller bullets.

The bouncing off with no collision problem is a head scratcher. I originally thought the problem was that the collision event was not getting passed to the script engine. Looking that the physics logs, though, confirms that the bullet is bouncing off the target but no collision even is being reported by the Bullet engine. Should not be possible.

I twiddled the single sided mesh option as well as other parameters to try and enable the collision reporting with no effect. Even more odd is that sometimes the bullet bounces off and sometimes the collision is correctly reported. Makes me think there is some edge case in collision manifold computation.

Anyway, I will continue looking into this bug but don't have a resolution yet.
(0032250)
Robert Adams   
2017-08-14 18:55   
I found that BulletSim was not checking for collisions on all the simulation substeps. I have an updated version of BulletSim on the 'BulletSim2017' branch in the source repository. I'm concerned about performance so I will be testing before merging it into master.

But that fix fixes this problem and a lot of tunneling (physical objects going through) problems.