* This is a very icky implementation of physical linkset prim using fixed joints. This will change quite drastically, however it's fun to play with.
* To play with this you must link your prim before setting it physical, otherwise they won't link in the physics engine properly. This will also be fixed. * Currently the linked prim are extremely unstable because I have yet to implement combining of forces with the same normal. This will also be fixed. In fact, the whole PhysicsActor, ODEPrim relationship will be reworked to consider groups from the get-go. * This implementation is better then it crashing your sim, so I'm commiting it for now.0.6.0-stable
parent
d6039b40a4
commit
0a5c48b1c8
|
@ -120,8 +120,8 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
private int m_update_physics = 1;
|
||||
private int m_update_entitymovement = 1;
|
||||
private int m_update_entities = 20; // Run through all objects checking for updates
|
||||
private int m_update_entitiesquick = 1; // Run through objects that have scheduled updates checking for updates
|
||||
private int m_update_entities = 1; // Run through all objects checking for updates
|
||||
private int m_update_entitiesquick = 200; // Run through objects that have scheduled updates checking for updates
|
||||
private int m_update_presences = 1; // Update scene presence movements
|
||||
private int m_update_events = 1;
|
||||
private int m_update_backup = 200;
|
||||
|
|
|
@ -1758,10 +1758,13 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
lock (m_parts)
|
||||
{
|
||||
m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_physicalPrim);
|
||||
foreach (SceneObjectPart part in m_parts.Values)
|
||||
{
|
||||
if (part.LocalID != m_rootPart.LocalID)
|
||||
{
|
||||
part.ApplyPhysics(m_rootPart.ObjectFlags, m_physicalPrim);
|
||||
|
||||
}
|
||||
// Hack to get the physics scene geometries in the right spot
|
||||
ResetChildPrimPhysicsPositions();
|
||||
|
||||
|
|
|
@ -1306,9 +1306,12 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
|
||||
PhysActor.OnOutOfBounds -= PhysicsOutOfBounds;
|
||||
PhysActor.delink();
|
||||
}
|
||||
|
||||
PhysActor.IsPhysical = UsePhysics;
|
||||
|
||||
|
||||
// If we're not what we're supposed to be in the physics scene, recreate ourselves.
|
||||
//m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor);
|
||||
/// that's not wholesome. Had to make Scene public
|
||||
|
@ -1331,6 +1334,14 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
|
||||
PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
|
||||
if (ParentID != 0 && ParentID != LocalID)
|
||||
{
|
||||
if (ParentGroup.RootPart.PhysActor != null)
|
||||
{
|
||||
PhysActor.link(ParentGroup.RootPart.PhysActor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,7 +349,15 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
|
|||
get { return true; }
|
||||
set { }
|
||||
}
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
|
||||
}
|
||||
public void SetAcceleration(PhysicsVector accel)
|
||||
{
|
||||
_acceleration = accel;
|
||||
|
|
|
@ -832,7 +832,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin
|
|||
}
|
||||
}
|
||||
}
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
|
||||
}
|
||||
public override float Mass
|
||||
{
|
||||
get { return ActorMass; }
|
||||
|
|
|
@ -132,6 +132,10 @@ namespace OpenSim.Region.Physics.Manager
|
|||
|
||||
public abstract void CrossingFailure();
|
||||
|
||||
public abstract void link(PhysicsActor obj);
|
||||
|
||||
public abstract void delink();
|
||||
|
||||
public virtual void RequestPhysicsterseUpdate()
|
||||
{
|
||||
// Make a temporary copy of the event to avoid possibility of
|
||||
|
@ -353,6 +357,16 @@ namespace OpenSim.Region.Physics.Manager
|
|||
set { return; }
|
||||
}
|
||||
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void AddForce(PhysicsVector force)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -490,7 +490,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
return m_density*AVvolume;
|
||||
}
|
||||
}
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
|
||||
}
|
||||
private void standupStraight()
|
||||
{
|
||||
|
||||
|
|
|
@ -90,6 +90,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
public IntPtr prev_geom;
|
||||
public IntPtr _triMeshData;
|
||||
|
||||
private IntPtr _linkJointGroup = (IntPtr)0;
|
||||
private PhysicsActor _parent = null;
|
||||
private PhysicsActor m_taintparent = null;
|
||||
|
||||
|
||||
private bool iscolliding = false;
|
||||
private bool m_isphysical = false;
|
||||
private bool m_isSelected = false;
|
||||
|
@ -113,6 +118,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
private PhysicsVector _target_velocity;
|
||||
public d.Mass pMass;
|
||||
|
||||
private IntPtr m_linkJoint = (IntPtr)0;
|
||||
|
||||
private int debugcounter = 0;
|
||||
|
||||
public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
|
||||
|
@ -719,6 +726,45 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
if (m_taintVelocity != PhysicsVector.Zero)
|
||||
changevelocity(timestep);
|
||||
|
||||
if (m_taintparent != _parent)
|
||||
changelink(timestep);
|
||||
}
|
||||
|
||||
private void changelink(float timestep)
|
||||
{
|
||||
while (ode.lockquery())
|
||||
{
|
||||
}
|
||||
ode.dlock(_parent_scene.world);
|
||||
|
||||
if (_parent == null && m_taintparent != null)
|
||||
{
|
||||
if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim)
|
||||
{
|
||||
OdePrim obj = (OdePrim)m_taintparent;
|
||||
if (obj.Body != (IntPtr)0 && Body != (IntPtr)0)
|
||||
{
|
||||
_linkJointGroup = d.JointGroupCreate(0);
|
||||
m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup);
|
||||
d.JointAttach(m_linkJoint, obj.Body, Body);
|
||||
d.JointSetFixed(m_linkJoint);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (_parent != null && m_taintparent == null)
|
||||
{
|
||||
if (Body != (IntPtr)0 && _linkJointGroup != (IntPtr)0)
|
||||
d.JointGroupDestroy(_linkJointGroup);
|
||||
|
||||
_linkJointGroup = (IntPtr)0;
|
||||
m_linkJoint = (IntPtr)0;
|
||||
|
||||
}
|
||||
ode.dunlock(_parent_scene.world);
|
||||
|
||||
_parent = m_taintparent;
|
||||
}
|
||||
|
||||
private void changeSelectedStatus(float timestep)
|
||||
|
@ -970,8 +1016,25 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
enableBody();
|
||||
//Prim auto disable after 20 frames,
|
||||
//if you move it, re-enable the prim manually.
|
||||
|
||||
if (_parent != null)
|
||||
{
|
||||
if (m_linkJoint != (IntPtr)0)
|
||||
{
|
||||
d.JointDestroy(m_linkJoint);
|
||||
m_linkJoint = (IntPtr)0;
|
||||
}
|
||||
}
|
||||
d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
|
||||
if (_parent != null)
|
||||
{
|
||||
OdePrim odParent = (OdePrim)_parent;
|
||||
if (Body != (IntPtr)0 && odParent.Body != (IntPtr)0)
|
||||
{
|
||||
m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup);
|
||||
d.JointAttach(m_linkJoint, Body, odParent.Body);
|
||||
d.JointSetFixed(m_linkJoint);
|
||||
}
|
||||
}
|
||||
d.BodyEnable(Body);
|
||||
|
||||
}
|
||||
|
@ -1652,9 +1715,26 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
m_taintparent = obj;
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
m_taintparent = null;
|
||||
}
|
||||
|
||||
public void UpdatePositionAndVelocity()
|
||||
{
|
||||
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
|
||||
if (_parent != null)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
PhysicsVector pv = new PhysicsVector(0, 0, 0);
|
||||
bool lastZeroFlag = _zeroFlag;
|
||||
if (Body != (IntPtr)0)
|
||||
|
@ -1802,6 +1882,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
_zeroFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetMomentum(PhysicsVector momentum)
|
||||
{
|
||||
|
|
|
@ -477,7 +477,15 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
get { return true; }
|
||||
set { }
|
||||
}
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
|
||||
}
|
||||
public void SetAcceleration(PhysicsVector accel)
|
||||
{
|
||||
_acceleration = accel;
|
||||
|
@ -659,7 +667,15 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
{
|
||||
set { return; }
|
||||
}
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
|
||||
}
|
||||
public override bool Selected
|
||||
{
|
||||
set { return; }
|
||||
|
|
|
@ -366,6 +366,16 @@ namespace OpenSim.Region.Physics.PhysXPlugin
|
|||
{
|
||||
}
|
||||
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void SetMomentum(PhysicsVector momentum)
|
||||
{
|
||||
}
|
||||
|
@ -582,6 +592,16 @@ namespace OpenSim.Region.Physics.PhysXPlugin
|
|||
set { }
|
||||
}
|
||||
|
||||
public override void link(PhysicsActor obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void delink()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override float Mass
|
||||
{
|
||||
get { return 0f; }
|
||||
|
|
Loading…
Reference in New Issue