Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008009opensim[REGION] Physics Enginespublic2016-08-26 16:192016-08-26 17:36
ReporterKayaker Magic 
Assigned To 
PlatformOSgridOSOpenSim 0.9OS Version0.9.0.0 Dev OSgr
Product Version 
Target VersionFixed in Version 
Summary0008009: BulletSim doesn't work reliably for bullets
DescriptionI asked Robert Adams this question at the developers meeting once, and his answer was “make your bullets longer”. But I thought I would submit this anyway to get it into the system.

When a small object collides with a larger one, the small one has a large probability of passing through the larger one without generating any collision events in either object. This makes weapons fail to work, since many of the bullets miss by tunneling through what you are trying to shoot.

For example, if I fire a 10cm sphere at 30m/s towards a 4x0.5x4 meter box (broadside), the cannonball will pass through the thin wall often without generating any collision events. At some distances and angles it fails every time, so move the gun around and turn it to different angles until it starts failing. If you make the target box 4x4x4 meters, then the cannonball will only occasionally pass through without a collision.

Following Robert's advice, I changed my cannonball into a rod and firing it in the long direction. When I got to a 2x0.1x0.1 meter rod moving at 30m/s, the probability of passing through a 0.5 meter wall without colliding appears to finally be 0. But I feel like a caveman throwing spears at everything. OK, I can make a visible cannonball with an invisible spear linked to it. However, this will strike early or bounce funny depending on the relative positions of the ball and rod.

I once took apart a gun in SL and noticed that the bullet was a long, thin, stretched, squashed, sliced and diced torus. I assume the reason for this strange object was to increase the probability of it hitting things by making the physics model of the bullet very complicated. I don't think current versions of Havoc still requires this kind of craziness any more. I tested a 10cm cannonball at 30m/s at a 0.5m thick wall in InWorldz using PhysX and in OpenSim 0.9 with ODE. In both of those physics engines the cannonball collides 100% of the time. Caveman spears are not necessary with PhysX or ODE, only with BulletSim.
Steps To ReproduceBelow is a simple set of scripts for demonstrating this. Put the “target script” in something like a 4x0.5x4 box. It just calls out collisions when they happen. Bump into it with your avatar to test it. Then shoot bullets at it.

Put the “bullet script” in various prims and try firing them with the gun script below. Mark the bullet prim PHYSICAL. Marking it TEMPORARY is also a good idea because these things have a tendency to fly off and get lost. Take it into inventory before you set it down, 'cause it will delete itself on any collision.

Put a bullet prim and the “gun script” in a prim. Keep the prim 0.5m in the Z direction to avoid any issues with the bullet rezzing inside the gun. Make this prim long (in the X direction) so you know where it is pointing. 1x0.5x0.5 is a good size. It fires in it's local positive X direction, so you can aim it with the build tools. Aim it at the target prim and click to fire. It fires the first object it finds in inventory, so you can place any bullet in it. You can have several in there and the first one alphabetically will be used. Rename them to change the order and which bullet will be used.
To see the failure you have to try the gun at different distances and angles.

Additional Informationdefault
    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
    collision_start(integer num)
        llOwnerSay("start hit="+llDetectedName(0));
    land_collision_start(vector pos)
        llOwnerSay("land pos="+(string)pos);

//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
        llSetText("touch to fire",<1,0,0>,1.0);
    touch(integer num)
        llRezObject(llGetInventoryName(INVENTORY_OBJECT,0), //rez the first object in inventory
TagsNo tags attached.
Git Revision or version number
Run Mode Grid (1 Region per Sim)
Physics EngineBulletSim
Script Engine
EnvironmentMono / Linux64
Mono Version3.0
Attached Files

- Relationships

-  Notes
UbitUmarov (administrator)
2016-08-26 17:36

I think you where luck with ode
ode does collisions each 20ms approximately, At 30ms a object moves 0.6m.
to make things worse, most collisions are not by volume interception but by surfaces. In this case if the movement in the time step is larger that half the size of the smaller prim, collision will fail or be wrong. This means your bullet needs to have a ugly 1.2m
It happens that on ODE ( and ubODE) pure boxes (no holes cuts etc ) are Volume colliders, so if both are volume colliders, the large object size will count.
Real spheres ( x=y=z, no holes etc) are also volume colliders.
don't even consider torus.. those are heavy meshs for physics.
rods are cylinders so meshs.
Use long a thin box.
so thing you where luck on that test with ODE.
can't tell how this objects are on bullet.
Havok, phyx and bullet do have a pseudo time continuous collision methods to reduce this can tell if they are in use or not at sl and Inworldz. Those heavy so usually are disabled. ODE doesn't have :(

- Issue History
Date Modified Username Field Change
2016-08-26 16:19 Kayaker Magic New Issue
2016-08-26 17:36 UbitUmarov Note Added: 0031063

Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker