Upgrade to 64 bit version of BulletSim
parent
7c542be833
commit
16aa0f73e5
|
@ -93,6 +93,7 @@ public class BSCharacter : PhysicsActor
|
||||||
_size = size;
|
_size = size;
|
||||||
_orientation = Quaternion.Identity;
|
_orientation = Quaternion.Identity;
|
||||||
_velocity = Vector3.Zero;
|
_velocity = Vector3.Zero;
|
||||||
|
_buoyancy = 0f; // characters return a buoyancy of zero
|
||||||
_scale = new Vector3(1f, 1f, 1f);
|
_scale = new Vector3(1f, 1f, 1f);
|
||||||
float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH);
|
float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH);
|
||||||
_mass = _density*AVvolume;
|
_mass = _density*AVvolume;
|
||||||
|
@ -105,8 +106,8 @@ public class BSCharacter : PhysicsActor
|
||||||
shapeData.Velocity = _velocity;
|
shapeData.Velocity = _velocity;
|
||||||
shapeData.Scale = _scale;
|
shapeData.Scale = _scale;
|
||||||
shapeData.Mass = _mass;
|
shapeData.Mass = _mass;
|
||||||
shapeData.Flying = isFlying ? ShapeData.numericTrue : ShapeData.numericFalse;
|
shapeData.Buoyancy = isFlying ? 0f : 1f;
|
||||||
shapeData.Dynamic = ShapeData.numericFalse;
|
shapeData.Static = ShapeData.numericFalse;
|
||||||
|
|
||||||
BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
|
BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
|
||||||
|
|
||||||
|
@ -268,7 +269,8 @@ public class BSCharacter : PhysicsActor
|
||||||
_flying = value;
|
_flying = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject(delegate()
|
||||||
{
|
{
|
||||||
BulletSimAPI.SetObjectFlying(_scene.WorldID, LocalID, _flying);
|
// simulate flying by changing the effect of gravity
|
||||||
|
BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 0f : 1f);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,7 +417,7 @@ public class BSCharacter : PhysicsActor
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
|
// m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
|
||||||
|
|
||||||
// The following says we're colliding this simulation step
|
// The following makes IsColliding() and IsCollidingGround() work
|
||||||
_collidingStep = _scene.SimulationStep;
|
_collidingStep = _scene.SimulationStep;
|
||||||
if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID)
|
if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,6 +106,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
_size = size;
|
_size = size;
|
||||||
_scale = new OMV.Vector3(1f, 1f, 1f); // the scale will be set by CreateGeom depending on object type
|
_scale = new OMV.Vector3(1f, 1f, 1f); // the scale will be set by CreateGeom depending on object type
|
||||||
_orientation = rotation;
|
_orientation = rotation;
|
||||||
|
_buoyancy = 1f;
|
||||||
_mesh = mesh;
|
_mesh = mesh;
|
||||||
_hullKey = 0;
|
_hullKey = 0;
|
||||||
_pbs = pbs;
|
_pbs = pbs;
|
||||||
|
@ -181,7 +182,6 @@ public sealed class BSPrim : PhysicsActor
|
||||||
_isSelected = value;
|
_isSelected = value;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject(delegate()
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("{0}: Selected={1}, localID={2}", LogHeader, _isSelected, _localID);
|
|
||||||
SetObjectDynamic();
|
SetObjectDynamic();
|
||||||
// SyncUpdated = true;
|
// SyncUpdated = true;
|
||||||
});
|
});
|
||||||
|
@ -287,6 +287,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
|
|
||||||
public override OMV.Vector3 Position {
|
public override OMV.Vector3 Position {
|
||||||
get {
|
get {
|
||||||
|
// don't do the following GetObjectPosition because this function is called a zillion times
|
||||||
// _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
|
// _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
|
@ -332,10 +333,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
_isVolumeDetect = newValue;
|
_isVolumeDetect = newValue;
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject(delegate()
|
||||||
{
|
{
|
||||||
// make the object ghostly or not (walk throughable)
|
SetObjectDynamic();
|
||||||
BulletSimAPI.SetObjectGhost(_scene.WorldID, LocalID, _isVolumeDetect);
|
|
||||||
// set whether we hear about collisions
|
|
||||||
BulletSimAPI.SetObjectCollidable(_scene.WorldID, LocalID, !IsPhantom);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -390,40 +388,39 @@ public sealed class BSPrim : PhysicsActor
|
||||||
_scene.TaintedObject(delegate()
|
_scene.TaintedObject(delegate()
|
||||||
{
|
{
|
||||||
SetObjectDynamic();
|
SetObjectDynamic();
|
||||||
m_log.DebugFormat("{0}: ID={1}, IsPhysical={2}, IsSelected={3}, mass={4}", LogHeader, _localID, _isPhysical, _isSelected, _mass);
|
|
||||||
// SyncUpdated = true;
|
// SyncUpdated = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An object is static (does not move) if selected or not physical
|
||||||
|
private bool IsStatic
|
||||||
|
{
|
||||||
|
get { return _isSelected || !IsPhysical; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// An object is solid if it's not phantom and if it's not doing VolumeDetect
|
||||||
|
private bool IsSolid
|
||||||
|
{
|
||||||
|
get { return !IsPhantom && !_isVolumeDetect; }
|
||||||
|
}
|
||||||
|
|
||||||
// make gravity work if the object is physical and not selected
|
// make gravity work if the object is physical and not selected
|
||||||
// no locking here because only called when it is safe
|
// no locking here because only called when it is safe
|
||||||
private void SetObjectDynamic()
|
private void SetObjectDynamic()
|
||||||
{
|
{
|
||||||
// a selected object is not physical
|
// non-physical things work best with a mass of zero
|
||||||
if (_isSelected || !_isPhysical)
|
_mass = IsStatic ? 0f : CalculateMass();
|
||||||
{
|
BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass);
|
||||||
_mass = 0f; // non-physical things work best with a mass of zero
|
// m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}, mass={4}", LogHeader, _localID, IsStatic, IsSolid, _mass);
|
||||||
BulletSimAPI.SetObjectDynamic(_scene.WorldID, _localID, false, _mass);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_mass = CalculateMass();
|
|
||||||
BulletSimAPI.SetObjectDynamic(_scene.WorldID, _localID, true, _mass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prims don't fly
|
||||||
public override bool Flying {
|
public override bool Flying {
|
||||||
get { return _flying; }
|
get { return _flying; }
|
||||||
set {
|
set { _flying = value; }
|
||||||
_flying = value;
|
|
||||||
_scene.TaintedObject(delegate()
|
|
||||||
{
|
|
||||||
BulletSimAPI.SetObjectFlying(_scene.WorldID, LocalID, _flying);
|
|
||||||
// SyncUpdated = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public override bool
|
public override bool SetAlwaysRun {
|
||||||
SetAlwaysRun {
|
|
||||||
get { return _setAlwaysRun; }
|
get { return _setAlwaysRun; }
|
||||||
set { _setAlwaysRun = value; }
|
set { _setAlwaysRun = value; }
|
||||||
}
|
}
|
||||||
|
@ -432,11 +429,11 @@ public sealed class BSPrim : PhysicsActor
|
||||||
set { _throttleUpdates = value; }
|
set { _throttleUpdates = value; }
|
||||||
}
|
}
|
||||||
public override bool IsColliding {
|
public override bool IsColliding {
|
||||||
get { return _isColliding; }
|
get { return (_collidingStep == _scene.SimulationStep); }
|
||||||
set { _isColliding = value; }
|
set { _isColliding = value; }
|
||||||
}
|
}
|
||||||
public override bool CollidingGround {
|
public override bool CollidingGround {
|
||||||
get { return _collidingGround; }
|
get { return (_collidingGroundStep == _scene.SimulationStep); }
|
||||||
set { _collidingGround = value; }
|
set { _collidingGround = value; }
|
||||||
}
|
}
|
||||||
public override bool CollidingObj {
|
public override bool CollidingObj {
|
||||||
|
@ -468,7 +465,12 @@ public sealed class BSPrim : PhysicsActor
|
||||||
}
|
}
|
||||||
public override float Buoyancy {
|
public override float Buoyancy {
|
||||||
get { return _buoyancy; }
|
get { return _buoyancy; }
|
||||||
set { _buoyancy = value; }
|
set { _buoyancy = value;
|
||||||
|
_scene.TaintedObject(delegate()
|
||||||
|
{
|
||||||
|
BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for MoveTo
|
// Used for MoveTo
|
||||||
|
@ -1003,11 +1005,11 @@ public sealed class BSPrim : PhysicsActor
|
||||||
shape.Velocity = _velocity;
|
shape.Velocity = _velocity;
|
||||||
shape.Scale = _scale;
|
shape.Scale = _scale;
|
||||||
shape.Mass = _isPhysical ? _mass : 0f;
|
shape.Mass = _isPhysical ? _mass : 0f;
|
||||||
|
shape.Buoyancy = _buoyancy;
|
||||||
shape.MeshKey = _hullKey;
|
shape.MeshKey = _hullKey;
|
||||||
shape.Collidable = (!IsPhantom) ? ShapeData.numericTrue : ShapeData.numericFalse;
|
shape.Collidable = (!IsPhantom) ? ShapeData.numericTrue : ShapeData.numericFalse;
|
||||||
shape.Flying = _flying ? ShapeData.numericTrue : ShapeData.numericFalse;
|
|
||||||
shape.Friction = _friction;
|
shape.Friction = _friction;
|
||||||
shape.Dynamic = _isPhysical ? ShapeData.numericTrue : ShapeData.numericFalse;
|
shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rebuild the geometry and object.
|
// Rebuild the geometry and object.
|
||||||
|
@ -1044,7 +1046,7 @@ public sealed class BSPrim : PhysicsActor
|
||||||
public void UpdateProperties(EntityProperties entprop)
|
public void UpdateProperties(EntityProperties entprop)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
// we assign to the local variables so the normal set action does not happen
|
// assign to the local variables so the normal set action does not happen
|
||||||
if (_position != entprop.Position)
|
if (_position != entprop.Position)
|
||||||
{
|
{
|
||||||
_position = entprop.Position;
|
_position = entprop.Position;
|
||||||
|
|
|
@ -35,23 +35,24 @@ using OpenSim.Region.Physics.Manager;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Region.Framework;
|
using OpenSim.Region.Framework;
|
||||||
|
|
||||||
// TODOs for BulletSim (both BSScene and BSPrim)
|
// TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim)
|
||||||
// Does NeedsMeshing() really need to exclude all the different shapes?
|
// Does NeedsMeshing() really need to exclude all the different shapes?
|
||||||
// Based on material, set density and friction
|
// Based on material, set density and friction
|
||||||
// More efficient memory usage in passing hull information from BSPrim to BulletSim
|
// More efficient memory usage in passing hull information from BSPrim to BulletSim
|
||||||
// Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly?
|
// Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly?
|
||||||
// In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground)
|
// In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground)
|
||||||
|
// At the moment, physical and phantom causes object to drop through the terrain
|
||||||
// LinkSets
|
// LinkSets
|
||||||
// Freeing of memory of linksets in BulletSim::DestroyObject
|
// Freeing of memory of linksets in BulletSim::DestroyObject
|
||||||
// Set child prims phantom since the physicality is handled by the parent prim
|
// Set child prims phantom since the physicality is handled by the parent prim
|
||||||
// Linked children need rotation relative to parent (passed as world rotation)
|
// Linked children need rotation relative to parent (passed as world rotation)
|
||||||
// Should prim.link() and prim.delink() membership checking happen at taint time?
|
// Should prim.link() and prim.delink() membership checking happen at taint time?
|
||||||
// Pass collision enable flags to BulletSim code so collisions are not reported up unless they are really needed
|
|
||||||
// Set bouyancy(). Maybe generalize SetFlying() to SetBouyancy() and use the factor to change the gravity effect
|
|
||||||
// Test sculpties
|
// Test sculpties
|
||||||
// Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once
|
// Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once
|
||||||
// Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect
|
// Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect
|
||||||
// Parameterize BulletSim. Pass a structure of parameters to the C++ code. Capsule size, friction, ...
|
// Parameterize BulletSim. Pass a structure of parameters to the C++ code. Capsule size, friction, ...
|
||||||
|
// Use event subscription times to reduce the number of events passed up (_subscribedEventMS)
|
||||||
|
// Implement the genCollisions feature in BulletSim::SetObjectProperties (don't pass up unneeded collisions)
|
||||||
//
|
//
|
||||||
namespace OpenSim.Region.Physics.BulletSPlugin
|
namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,11 +59,11 @@ public struct ShapeData
|
||||||
public Vector3 Velocity;
|
public Vector3 Velocity;
|
||||||
public Vector3 Scale;
|
public Vector3 Scale;
|
||||||
public float Mass;
|
public float Mass;
|
||||||
|
public float Buoyancy;
|
||||||
public System.UInt64 MeshKey;
|
public System.UInt64 MeshKey;
|
||||||
public int Collidable;
|
public int Collidable;
|
||||||
public int Flying;
|
|
||||||
public float Friction;
|
public float Friction;
|
||||||
public int Dynamic;
|
public int Static; // true if a static object. Otherwise gravity, etc.
|
||||||
// note that bools are passed as ints since bool size changes by language
|
// note that bools are passed as ints since bool size changes by language
|
||||||
}
|
}
|
||||||
public struct SweepHit
|
public struct SweepHit
|
||||||
|
@ -148,7 +148,10 @@ public static extern bool SetObjectDynamic(uint worldID, uint id, bool isDynamic
|
||||||
public static extern bool SetObjectGhost(uint worldID, uint id, bool ghostly);
|
public static extern bool SetObjectGhost(uint worldID, uint id, bool ghostly);
|
||||||
|
|
||||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||||
public static extern bool SetObjectFlying(uint worldID, uint id, bool flying);
|
public static extern bool SetObjectProperties(uint worldID, uint id, bool isStatic, bool isSolid, bool genCollisions, float mass);
|
||||||
|
|
||||||
|
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||||
|
public static extern bool SetObjectBuoyancy(uint worldID, uint id, float buoyancy);
|
||||||
|
|
||||||
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
|
||||||
public static extern bool HasObject(uint worldID, uint id);
|
public static extern bool HasObject(uint worldID, uint id);
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue