45 using System.Collections.Generic;
46 using System.Reflection;
47 using System.Runtime.InteropServices;
48 using System.Threading;
52 using OpenSim.Framework;
53 using OpenSim.Region.PhysicsModules.SharedBase;
55 namespace OpenSim.
Region.PhysicsModule.ubOde
59 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
61 private bool m_isphysical;
62 private bool m_fakeisphysical;
63 private bool m_isphantom;
64 private bool m_fakeisphantom;
65 internal bool m_isVolumeDetect;
66 private bool m_fakeisVolumeDetect;
70 private bool m_iscolliding;
72 internal bool m_isSelected;
73 private bool m_delaySelect;
74 private bool m_lastdoneSelected;
75 internal bool m_outbounds;
77 private byte m_angularlocks = 0;
79 private Quaternion m_lastorientation;
80 private Quaternion _orientation;
82 private Vector3 _position;
83 private Vector3 _velocity;
84 private Vector3 m_torque;
85 private Vector3 m_lastVelocity;
86 private Vector3 m_lastposition;
87 private Vector3 m_rotationalVelocity;
88 private Vector3 _size;
89 private Vector3 _acceleration;
90 private IntPtr Amotor;
92 private Vector3 m_force;
93 private Vector3 m_forceacc;
94 private Vector3 m_angularForceacc;
96 private float m_invTimeStep;
97 private float m_timeStep;
99 private Vector3 m_PIDTarget;
100 private float m_PIDTau;
101 private bool m_usePID;
103 private float m_PIDHoverHeight;
104 private float m_PIDHoverTau;
105 private bool m_useHoverPID;
107 private float m_targetHoverHeight;
108 private float m_groundHeight;
109 private float m_waterHeight;
110 private float m_buoyancy;
112 private int body_autodisable_frames;
113 public int bodydisablecontrol = 0;
114 private float m_gravmod = 1.0f;
121 private const CollisionCategories m_default_collisionFlagsPhysical = (CollisionCategories.Geom |
122 CollisionCategories.Character |
123 CollisionCategories.Land |
124 CollisionCategories.VolumeDtc);
127 private bool m_collidesWater;
130 private bool m_NoColide;
138 private uint m_localID;
140 private IMesh m_mesh;
141 private object m_meshlock =
new object();
144 private UUID? m_assetID;
159 private List<OdePrim> childrenPrim =
new List<OdePrim>();
162 private int m_colliderfilter = 0;
166 private float m_density;
167 private byte m_shapetype;
169 private bool m_lastUpdateSent;
173 private Vector3 _target_velocity;
179 private bool m_hasOBB =
true;
181 private float m_physCost;
182 private float m_streamCost;
190 private Vector3 fakepos;
192 private Quaternion fakeori;
194 private int m_eventsubscription;
195 private int m_cureventsubscription;
197 private bool SentEmptyCollisionsEvent;
203 internal int m_material = (int)
Material.Wood;
205 private float bounce;
210 public override bool IsPhysical
212 get {
return m_fakeisphysical; }
215 m_fakeisphysical = value;
220 m_lastVelocity = Vector3.Zero;
221 AddChange(
changes.Physical, value);
225 public override bool IsVolumeDtc
227 get {
return m_fakeisVolumeDetect; }
230 m_fakeisVolumeDetect = value;
231 AddChange(
changes.VolumeDtc, value);
237 get {
return m_fakeisphantom; }
240 m_fakeisphantom = value;
241 AddChange(
changes.Phantom, value);
245 public override bool Building
247 get {
return m_building; }
252 AddChange(
changes.building, value);
259 cdata.bounce = bounce;
262 cdata.softcolide =
false;
268 veh = ((
OdePrim)_parent).m_vehicle;
273 cdata.mu *= veh.FrictionFactor;
278 public override float PhysicsCost
286 public override float StreamCost
294 public override int PhysicsActorType
296 get {
return (
int)ActorTypes.Prim; }
302 get {
return false; }
306 public override uint LocalID
308 get {
return m_localID; }
309 set { m_localID = value; }
323 public override bool Grabbed
328 public override bool Selected
333 m_isSelected = value;
334 AddChange(
changes.Selected, value);
338 public override bool Flying
341 get {
return false; }
345 public override bool IsColliding
347 get {
return m_iscolliding; }
352 m_colliderfilter += 2;
353 if (m_colliderfilter > 2)
354 m_colliderfilter = 2;
359 if (m_colliderfilter < 0)
360 m_colliderfilter = 0;
363 if (m_colliderfilter == 0)
364 m_iscolliding =
false;
366 m_iscolliding =
true;
370 public override bool CollidingGround
372 get {
return false; }
376 public override bool CollidingObj
378 get {
return false; }
383 public override bool ThrottleUpdates {
get;set;}
385 public override bool Stopped
387 get {
return _zeroFlag; }
404 AddChange(
changes.Position, value);
408 public override Vector3
Size
410 get {
return _size; }
413 if (value.IsFinite())
415 _parent_scene.m_meshWorker.ChangeActorPhysRep(
this, _pbs, value, m_shapetype);
419 m_log.WarnFormat(
"[PHYSICS]: Got NaN Size on object {0}", Name);
424 public override float Mass
426 get {
return primMass; }
429 public override Vector3
Force
431 get {
return m_force; }
434 if (value.IsFinite())
436 AddChange(
changes.Force, value);
440 m_log.WarnFormat(
"[PHYSICS]: NaN in Force Applied to an Object {0}", Name);
447 m_fakeisVolumeDetect = (param != 0);
448 AddChange(
changes.VolumeDtc, m_fakeisVolumeDetect);
451 public override Vector3 GeometricCenter
463 public override Vector3 CenterOfMass
467 lock (_parent_scene.OdeLock)
469 d.AllocateODEDataForThread(0);
472 if (!childPrim && Body != IntPtr.Zero)
474 dtmp = d.BodyGetPosition(Body);
475 return new Vector3(dtmp.X, dtmp.Y, dtmp.Z);
477 else if (prim_geom != IntPtr.Zero)
480 d.GeomCopyQuaternion(prim_geom, out dq);
487 Vector3 Ptot = m_OBBOffset * q;
488 dtmp = d.GeomGetPosition(prim_geom);
528 _parent_scene.m_meshWorker.ChangeActorPhysRep(
this, value, _size, m_shapetype);
532 public override byte PhysicsShapeType
541 _parent_scene.m_meshWorker.ChangeActorPhysRep(
this, _pbs, _size, value);
555 if (value.IsFinite())
557 AddChange(
changes.Velocity, value);
561 m_log.WarnFormat(
"[PHYSICS]: Got NaN Velocity in Object {0}", Name);
567 public override Vector3
Torque
571 if (!IsPhysical || Body == IntPtr.Zero)
579 if (value.IsFinite())
581 AddChange(
changes.Torque, value);
585 m_log.WarnFormat(
"[PHYSICS]: Got NaN Torque in Object {0}", Name);
590 public override float CollisionScore
592 get {
return m_collisionscore; }
593 set { m_collisionscore = value; }
596 public override bool Kinematic
598 get {
return false; }
602 public override Quaternion Orientation
614 if (QuaternionIsFinite(value))
621 AddChange(
changes.Orientation, value);
624 m_log.WarnFormat(
"[PHYSICS]: Got NaN quaternion Orientation from Scene in Object {0}", Name);
631 get {
return _acceleration; }
635 public override Vector3 RotationalVelocity
639 Vector3 pv = Vector3.Zero;
643 if (m_rotationalVelocity.ApproxEquals(pv, 0.0001f))
646 return m_rotationalVelocity;
650 if (value.IsFinite())
652 AddChange(
changes.AngVelocity, value);
656 m_log.WarnFormat(
"[PHYSICS]: Got NaN RotationalVelocity in Object {0}", Name);
663 get {
return m_buoyancy; }
666 AddChange(
changes.Buoyancy,value);
670 public override bool FloatOnWater
674 AddChange(
changes.CollidesWater, value);
682 if (value.IsFinite())
684 AddChange(
changes.PIDTarget,value);
687 m_log.WarnFormat(
"[PHYSICS]: Got NaN PIDTarget from Scene on Object {0}", Name);
699 AddChange(
changes.PIDActive,value);
703 public override float PIDTau
710 float mint = (0.05f > m_timeStep ? 0.05f : m_timeStep);
724 AddChange(
changes.PIDHoverHeight,value);
731 return m_useHoverPID;
735 AddChange(
changes.PIDHoverActive, value);
743 AddChange(
changes.PIDHoverType,value);
754 float mint = (0.05f > m_timeStep ? 0.05f : m_timeStep);
760 AddChange(
changes.PIDHoverTau, tmp);
764 public override Quaternion APIDTarget { set {
return; } }
766 public override bool APIDActive { set {
return; } }
768 public override float APIDStrength { set {
return; } }
770 public override float APIDDamping { set {
return; } }
777 if (m_vehicle == null)
778 return (
int)Vehicle.TYPE_NONE;
780 return (
int)m_vehicle.Type;
784 AddChange(
changes.VehicleType, value);
790 strVehicleFloatParam fp =
new strVehicleFloatParam();
793 AddChange(
changes.VehicleFloatParam, fp);
798 strVehicleVectorParam fp =
new strVehicleVectorParam();
801 AddChange(
changes.VehicleVectorParam, fp);
806 strVehicleQuatParam fp =
new strVehicleQuatParam();
809 AddChange(
changes.VehicleRotationParam, fp);
814 strVehicleBoolParam bp =
new strVehicleBoolParam();
817 AddChange(
changes.VehicleFlags, bp);
822 AddChange(
changes.SetVehicle, vdata);
826 _acceleration = accel;
829 public override void AddForce(Vector3 force,
bool pushforce)
831 if (force.IsFinite())
834 AddChange(
changes.AddForce, force);
836 AddChange(
changes.AddForce, force * m_invTimeStep);
840 m_log.WarnFormat(
"[PHYSICS]: Got Invalid linear force vector from Scene in Object {0}", Name);
847 if (force.IsFinite())
850 AddChange(
changes.AddAngForce, force);
856 m_log.WarnFormat(
"[PHYSICS]: Got Invalid Angular force vector from Scene in Object {0}", Name);
864 _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f);
865 _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f);
866 _position.Z = Util.Clip(_position.Z + 0.2f, -100f, 50000f);
868 m_lastposition = _position;
873 d.AllocateODEDataForThread(0);
875 m_lastVelocity = _velocity;
876 if (m_vehicle != null && m_vehicle.Type !=
Vehicle.TYPE_NONE)
879 if(Body != IntPtr.Zero)
880 d.BodySetLinearVel(Body, 0, 0, 0);
881 if (prim_geom != IntPtr.Zero)
882 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
885 changeDisable(
false);
886 base.RequestPhysicsterseUpdate();
896 m_material = pMaterial;
897 mu = _parent_scene.m_materialContactsData[pMaterial].mu;
898 bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
901 public override float Density
905 return m_density * 100f;
909 m_density = value / 100f;
913 public override float GravModifier
922 if (m_vehicle != null)
923 m_vehicle.GravMod = m_gravmod;
926 public override float Friction
938 public override float Restitution
952 AddChange(
changes.Remove, null);
962 AddChange(
changes.DeLink, null);
968 AddChange(
changes.AngLock, axislock);
974 m_eventsubscription = ms;
975 m_cureventsubscription = 0;
976 if (CollisionEventsThisFrame == null)
978 SentEmptyCollisionsEvent =
false;
983 if (CollisionEventsThisFrame != null)
985 CollisionEventsThisFrame.Clear();
986 CollisionEventsThisFrame = null;
988 m_eventsubscription = 0;
989 _parent_scene.RemoveCollisionEventReporting(
this);
994 if (CollisionEventsThisFrame == null)
997 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1002 if (CollisionEventsThisFrame == null)
1005 if (m_cureventsubscription < m_eventsubscription)
1008 m_cureventsubscription = 0;
1010 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
1012 if (!SentEmptyCollisionsEvent || ncolisions > 0)
1014 base.SendCollisionUpdate(CollisionEventsThisFrame);
1016 if (ncolisions == 0)
1018 SentEmptyCollisionsEvent =
true;
1019 _parent_scene.RemoveCollisionEventReporting(
this);
1023 SentEmptyCollisionsEvent =
false;
1024 CollisionEventsThisFrame.Clear();
1029 internal void AddCollisionFrameTime(
int t)
1031 if (m_cureventsubscription < 50000)
1032 m_cureventsubscription += t;
1037 if (m_eventsubscription > 0)
1050 if (!pos.IsFinite())
1054 m_log.WarnFormat(
"[PHYSICS]: Got nonFinite Object create Position for {0}", Name);
1059 m_timeStep = parent_scene.ODE_STEPSIZE;
1060 m_invTimeStep = 1f / m_timeStep;
1062 m_density = parent_scene.geomDefaultDensity;
1063 body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
1065 prim_geom = IntPtr.Zero;
1066 collide_geom = IntPtr.Zero;
1069 if (!size.IsFinite())
1071 size =
new Vector3(0.5f, 0.5f, 0.5f);
1072 m_log.WarnFormat(
"[PHYSICS]: Got nonFinite Object create Size for {0}", Name);
1075 if (size.X <= 0) size.X = 0.01f;
1076 if (size.Y <= 0) size.Y = 0.01f;
1077 if (size.Z <= 0) size.Z = 0.01f;
1081 if (!QuaternionIsFinite(rotation))
1083 rotation = Quaternion.Identity;
1084 m_log.WarnFormat(
"[PHYSICS]: Got nonFinite Object create Rotation for {0}", Name);
1092 _parent_scene = parent_scene;
1093 m_targetSpace = IntPtr.Zero;
1097 m_isphysical =
false;
1101 m_isphysical = pisPhysical;
1103 m_fakeisphysical = m_isphysical;
1105 m_isVolumeDetect =
false;
1106 m_fakeisVolumeDetect =
false;
1108 m_force = Vector3.Zero;
1110 m_iscolliding =
false;
1111 m_colliderfilter = 0;
1114 _triMeshData = IntPtr.Zero;
1116 m_shapetype = _shapeType;
1118 m_lastdoneSelected =
false;
1119 m_isSelected =
false;
1120 m_delaySelect =
false;
1122 m_isphantom = pisPhantom;
1123 m_fakeisphantom = pisPhantom;
1125 mu = parent_scene.m_materialContactsData[(int)
Material.Wood].mu;
1131 ODEPhysRepData repData = _parent_scene.m_meshWorker.NewActorPhysRep(
this, _pbs, _size, m_shapetype);
1133 primVolume = repData.volume;
1134 m_OBB = repData.OBB;
1135 m_OBBOffset = repData.OBBOffset;
1137 UpdatePrimBodyData();
1140 private void resetCollisionAccounting()
1142 m_collisionscore = 0;
1145 private void UpdateCollisionCatFlags()
1147 if(m_isphysical && m_disabled)
1149 m_collisionCategories = 0;
1150 m_collisionFlags = 0;
1153 else if (m_isSelected)
1155 m_collisionCategories = CollisionCategories.Selected;
1156 m_collisionFlags = 0;
1159 else if (m_isVolumeDetect)
1161 m_collisionCategories = CollisionCategories.VolumeDtc;
1163 m_collisionFlags = CollisionCategories.Geom | CollisionCategories.Character;
1165 m_collisionFlags = 0;
1167 else if (m_isphantom)
1169 m_collisionCategories = CollisionCategories.Phantom;
1171 m_collisionFlags = CollisionCategories.Land;
1173 m_collisionFlags = 0;
1177 m_collisionCategories = CollisionCategories.Geom;
1179 m_collisionFlags = m_default_collisionFlagsPhysical;
1181 m_collisionFlags = m_default_collisionFlagsNotPhysical;
1185 private void ApplyCollisionCatFlags()
1187 if (prim_geom != IntPtr.Zero)
1189 if (!childPrim && childrenPrim.Count > 0)
1191 foreach (OdePrim prm
in childrenPrim)
1193 if (m_isphysical && m_disabled)
1195 prm.m_collisionCategories = 0;
1196 prm.m_collisionFlags = 0;
1201 if (prm.m_isSelected)
1203 prm.m_collisionCategories = CollisionCategories.Selected;
1204 prm.m_collisionFlags = 0;
1206 else if (prm.m_isVolumeDetect)
1208 prm.m_collisionCategories = CollisionCategories.VolumeDtc;
1210 prm.m_collisionFlags = CollisionCategories.Geom | CollisionCategories.Character;
1212 prm.m_collisionFlags = 0;
1214 else if (prm.m_isphantom)
1216 prm.m_collisionCategories = CollisionCategories.Phantom;
1218 prm.m_collisionFlags = CollisionCategories.Land;
1220 prm.m_collisionFlags = 0;
1224 prm.m_collisionCategories = m_collisionCategories;
1225 prm.m_collisionFlags = m_collisionFlags;
1229 if (prm.prim_geom != IntPtr.Zero)
1233 d.GeomSetCategoryBits(prm.prim_geom, 0);
1237 d.GeomSetCollideBits(prm.prim_geom, 0);
1241 d.GeomSetCategoryBits(prm.prim_geom, (uint)prm.m_collisionCategories);
1242 d.GeomSetCollideBits(prm.prim_geom, (uint)prm.m_collisionFlags);
1250 d.GeomSetCategoryBits(prim_geom, 0);
1252 if (collide_geom != prim_geom && collide_geom != IntPtr.Zero)
1254 d.GeomSetCategoryBits(collide_geom, 0);
1260 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
1261 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
1262 if (collide_geom != prim_geom && collide_geom != IntPtr.Zero)
1264 d.GeomSetCategoryBits(collide_geom, (uint)m_collisionCategories);
1265 d.GeomSetCollideBits(collide_geom, (uint)m_collisionFlags);
1271 private void createAMotor(byte axislock)
1273 if (Body == IntPtr.Zero)
1276 if (Amotor != IntPtr.Zero)
1278 d.JointDestroy(Amotor);
1279 Amotor = IntPtr.Zero;
1286 if((axislock & 0x02) != 0)
1291 if((axislock & 0x04) != 0)
1296 if((axislock & 0x08) != 0)
1305 d.BodySetTorque(
Body, 0, 0, 0);
1306 d.BodySetAngularVel(Body, 0, 0, 0);
1308 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
1309 d.JointAttach(Amotor, Body, IntPtr.Zero);
1311 d.JointSetAMotorMode(Amotor, 0);
1313 d.JointSetAMotorNumAxes(Amotor, axisnum);
1329 ax = (
new Vector3(1, 0, 0)) * curr;
1330 d.JointSetAMotorAxis(Amotor, 0, 0, ax.X, ax.Y, ax.Z);
1331 d.JointSetAMotorAngle(Amotor, 0, 0);
1332 d.JointSetAMotorParam(Amotor, (int)d.JointParam.LoStop, 0f);
1333 d.JointSetAMotorParam(Amotor, (int)d.JointParam.HiStop, 0f);
1334 d.JointSetAMotorParam(Amotor, (int)d.JointParam.Vel, 0);
1335 d.JointSetAMotorParam(Amotor, (int)d.JointParam.FudgeFactor, 0.0001f);
1336 d.JointSetAMotorParam(Amotor, (int)d.JointParam.Bounce, 0f);
1337 d.JointSetAMotorParam(Amotor, (int)d.JointParam.CFM, 0f);
1338 d.JointSetAMotorParam(Amotor, (int)d.JointParam.FMax, 5e8f);
1339 d.JointSetAMotorParam(Amotor, (int)d.JointParam.StopCFM, 0f);
1340 d.JointSetAMotorParam(Amotor, (int)d.JointParam.StopERP, 0.8f);
1347 ax = (
new Vector3(0, 1, 0)) * curr;
1348 d.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z);
1349 d.JointSetAMotorAngle(Amotor, i, 0);
1350 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.LoStop, 0f);
1351 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.HiStop, 0f);
1352 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Vel, 0);
1353 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FudgeFactor, 0.0001f);
1354 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Bounce, 0f);
1355 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.CFM, 0f);
1356 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FMax, 5e8f);
1357 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopCFM, 0f);
1358 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopERP, 0.8f);
1365 ax = (
new Vector3(0, 0, 1)) * curr;
1366 d.JointSetAMotorAxis(Amotor, i, 0, ax.X, ax.Y, ax.Z);
1367 d.JointSetAMotorAngle(Amotor, i, 0);
1368 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.LoStop, 0f);
1369 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.HiStop, 0f);
1370 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Vel, 0);
1371 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FudgeFactor, 0.0001f);
1372 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.Bounce, 0f);
1373 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.CFM, 0f);
1374 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.FMax, 5e8f);
1375 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopCFM, 0f);
1376 d.JointSetAMotorParam(Amotor, j + (int)d.JointParam.StopERP, 0.8f);
1381 private void SetGeom(IntPtr geom)
1385 if (prim_geom != IntPtr.Zero)
1390 d.GeomSetCategoryBits(prim_geom, 0);
1397 d.GeomSetCollideBits(prim_geom, 0);
1398 d.GeomDisable(prim_geom);
1403 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
1404 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
1407 UpdatePrimBodyData();
1408 _parent_scene.actor_name_map[prim_geom] =
this;
1427 m_log.Warn(
"Setting bad Geom");
1430 private bool GetMeshGeom()
1432 IntPtr vertices, indices;
1433 int vertexCount, indexCount;
1434 int vertexStride, triStride;
1436 IMesh mesh = m_mesh;
1441 mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount);
1442 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount);
1444 if (vertexCount == 0 || indexCount == 0)
1446 m_log.WarnFormat(
"[PHYSICS]: Invalid mesh data on OdePrim {0}, mesh {1} at {2}",
1447 Name, _pbs.SculptEntry ? _pbs.SculptTexture.ToString() :
"primMesh",_position.ToString());
1450 m_OBBOffset = Vector3.Zero;
1451 m_OBB = _size * 0.5f;
1454 m_streamCost = 1.0f;
1456 _parent_scene.mesher.ReleaseMesh(mesh);
1457 m_meshState = MeshState.MeshFailed;
1462 if (vertexCount > 64000 || indexCount > 64000)
1464 m_log.WarnFormat(
"[PHYSICS]: large mesh data on OdePrim {0}, mesh {1} at {2}, {3} vertices, {4} indexes",
1465 Name, _pbs.SculptEntry ? _pbs.SculptTexture.ToString() :
"primMesh",
1466 _position.ToString() ,vertexCount , indexCount );
1468 IntPtr geo = IntPtr.Zero;
1472 _triMeshData = d.GeomTriMeshDataCreate();
1474 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
1475 d.GeomTriMeshDataPreprocess(_triMeshData);
1477 geo = d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null);
1482 m_log.ErrorFormat(
"[PHYSICS]: SetGeom Mesh failed for {0} exception: {1}", Name, e);
1483 if (_triMeshData != IntPtr.Zero)
1487 d.GeomTriMeshDataDestroy(_triMeshData);
1493 _triMeshData = IntPtr.Zero;
1496 m_OBBOffset = Vector3.Zero;
1497 m_OBB = _size * 0.5f;
1499 m_streamCost = 1.0f;
1501 _parent_scene.mesher.ReleaseMesh(mesh);
1502 m_meshState = MeshState.MeshFailed;
1507 m_physCost = 0.0013f * (float)indexCount;
1509 m_streamCost = 1.0f;
1516 private void CreateGeom()
1518 bool hasMesh =
false;
1522 if ((m_meshState &
MeshState.MeshNoColide) != 0)
1525 else if(m_mesh != null)
1536 IntPtr geo = IntPtr.Zero;
1539 && _size.X == _size.Y && _size.Y == _size.Z)
1543 geo = d.CreateSphere(m_targetSpace, _size.X * 0.5f);
1547 m_log.WarnFormat(
"[PHYSICS]: Create sphere failed: {0}", e);
1555 geo = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1559 m_log.Warn(
"[PHYSICS]: Create box failed: {0}", e);
1564 m_streamCost = 1.0f;
1569 private void RemoveGeom()
1571 if (prim_geom != IntPtr.Zero)
1573 _parent_scene.actor_name_map.Remove(prim_geom);
1577 d.GeomDestroy(prim_geom);
1578 if (_triMeshData != IntPtr.Zero)
1580 d.GeomTriMeshDataDestroy(_triMeshData);
1581 _triMeshData = IntPtr.Zero;
1586 m_log.ErrorFormat(
"[PHYSICS]: PrimGeom destruction failed for {0} exception {1}", Name, e);
1589 prim_geom = IntPtr.Zero;
1590 collide_geom = IntPtr.Zero;
1591 m_targetSpace = IntPtr.Zero;
1595 m_log.ErrorFormat(
"[PHYSICS]: PrimGeom destruction BAD {0}", Name);
1602 _parent_scene.mesher.ReleaseMesh(m_mesh);
1613 private void SetInStaticSpace(OdePrim prim)
1615 IntPtr targetSpace = _parent_scene.MoveGeomToStaticSpace(prim.prim_geom, prim._position, prim.m_targetSpace);
1616 prim.m_targetSpace = targetSpace;
1617 collide_geom = IntPtr.Zero;
1623 if (!childPrim && !m_isSelected)
1625 if (m_isphysical && Body != IntPtr.Zero)
1627 UpdateCollisionCatFlags();
1628 ApplyCollisionCatFlags();
1635 resetCollisionAccounting();
1638 private void disableBodySoft()
1643 if (m_isphysical && Body != IntPtr.Zero)
1646 m_collisionFlags = CollisionCategories.Selected;
1648 m_collisionCategories = 0;
1649 m_collisionFlags = 0;
1650 ApplyCollisionCatFlags();
1651 d.BodyDisable(Body);
1656 private void MakeBody()
1667 if (prim_geom == IntPtr.Zero)
1669 m_log.Warn(
"[PHYSICS]: Unable to link the linkset. Root has no geom yet");
1673 if (Body != IntPtr.Zero)
1676 m_log.Warn(
"[PHYSICS]: MakeBody called having a body");
1679 if (d.GeomGetBody(prim_geom) != IntPtr.Zero)
1681 d.GeomSetBody(prim_geom, IntPtr.Zero);
1682 m_log.Warn(
"[PHYSICS]: MakeBody root geom already had a body");
1689 Body = d.BodyCreate(_parent_scene.world);
1691 objdmass = primdMass;
1694 myrot.X = _orientation.X;
1695 myrot.Y = _orientation.Y;
1696 myrot.Z = _orientation.Z;
1697 myrot.W = _orientation.W;
1699 d.RfromQ(out mymat, ref myrot);
1700 d.MassRotate(ref objdmass, ref mymat);
1703 d.BodySetRotation(
Body, ref mymat);
1706 if (childrenPrim.Count > 0)
1713 rcm.X = _position.X;
1714 rcm.Y = _position.Y;
1715 rcm.Z = _position.Z;
1719 foreach (OdePrim prm
in childrenPrim)
1721 if (prm.prim_geom == IntPtr.Zero)
1723 m_log.Warn(
"[PHYSICS]: Unable to link one of the linkset elements, skipping it. No geom yet");
1727 tmpdmass = prm.primdMass;
1730 quat.X = prm._orientation.X;
1731 quat.Y = prm._orientation.Y;
1732 quat.Z = prm._orientation.Z;
1733 quat.W = prm._orientation.W;
1734 d.RfromQ(out mat, ref quat);
1735 d.MassRotate(ref tmpdmass, ref mat);
1737 Vector3 ppos = prm._position;
1742 d.MassTranslate(ref tmpdmass,
1747 d.MassAdd(ref objdmass, ref tmpdmass);
1750 if (d.GeomGetBody(prm.prim_geom) != IntPtr.Zero)
1752 d.GeomSetBody(prm.prim_geom, IntPtr.Zero);
1753 m_log.Warn(
"[PHYSICS]: MakeBody child geom already had a body");
1756 d.GeomClearOffset(prm.prim_geom);
1757 d.GeomSetBody(prm.prim_geom, Body);
1759 d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat);
1764 d.GeomClearOffset(prim_geom);
1766 d.GeomSetBody(prim_geom, Body);
1768 d.BodySetPosition(Body, _position.X + objdmass.c.X, _position.Y + objdmass.c.Y, _position.Z + objdmass.c.Z);
1769 d.GeomSetOffsetWorldPosition(prim_geom, _position.X, _position.Y, _position.Z);
1771 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z);
1776 d.RfromQ(out mymat, ref myrot);
1777 d.MassRotate(ref objdmass, ref mymat);
1779 d.BodySetMass(Body, ref objdmass);
1780 _mass = objdmass.mass;
1783 d.BodySetGravityMode(Body,
false);
1785 d.BodySetAutoDisableFlag(Body,
true);
1786 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
1787 d.BodySetAutoDisableAngularThreshold(Body, 0.05f);
1788 d.BodySetAutoDisableLinearThreshold(Body, 0.05f);
1789 d.BodySetDamping(Body, .004f, .001f);
1791 if (m_targetSpace != IntPtr.Zero)
1793 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1794 if (d.SpaceQuery(m_targetSpace, prim_geom))
1795 d.SpaceRemove(m_targetSpace, prim_geom);
1798 if (childrenPrim.Count == 0)
1800 collide_geom = prim_geom;
1801 m_targetSpace = _parent_scene.ActiveSpace;
1805 m_targetSpace = d.HashSpaceCreate(_parent_scene.ActiveSpace);
1806 d.HashSpaceSetLevels(m_targetSpace, -2, 8);
1807 d.SpaceSetSublevel(m_targetSpace, 3);
1808 d.SpaceSetCleanup(m_targetSpace,
false);
1815 d.GeomSetCollideBits(m_targetSpace, 0);
1816 collide_geom = m_targetSpace;
1819 d.SpaceAdd(m_targetSpace, prim_geom);
1823 m_isSelected =
true;
1824 m_delaySelect =
false;
1827 m_collisionscore = 0;
1829 UpdateCollisionCatFlags();
1830 ApplyCollisionCatFlags();
1832 _parent_scene.addActivePrim(
this);
1836 foreach (OdePrim prm
in childrenPrim)
1838 if (prm.prim_geom == IntPtr.Zero)
1841 Vector3 ppos = prm._position;
1842 d.GeomSetOffsetWorldPosition(prm.prim_geom, ppos.X, ppos.Y, ppos.Z);
1844 if (prm.m_targetSpace != m_targetSpace)
1846 if (prm.m_targetSpace != IntPtr.Zero)
1848 _parent_scene.waitForSpaceUnlock(prm.m_targetSpace);
1849 if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom))
1850 d.SpaceRemove(prm.m_targetSpace, prm.prim_geom);
1852 prm.m_targetSpace = m_targetSpace;
1853 d.SpaceAdd(m_targetSpace, prm.prim_geom);
1856 prm.m_collisionscore = 0;
1859 prm.m_disabled =
false;
1861 _parent_scene.addActivePrim(prm);
1866 if (m_angularlocks != 0 && _parent == null)
1868 createAMotor(m_angularlocks);
1871 if (m_isSelected || m_disabled)
1873 d.BodyDisable(Body);
1878 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z);
1879 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
1881 bodydisablecontrol = 0;
1883 _parent_scene.addActiveGroups(
this);
1886 private void DestroyBody()
1888 if (Body != IntPtr.Zero)
1890 _parent_scene.remActivePrim(
this);
1892 collide_geom = IntPtr.Zero;
1895 m_collisionCategories = 0;
1896 else if (m_isSelected)
1897 m_collisionCategories = CollisionCategories.Selected;
1898 else if (m_isVolumeDetect)
1899 m_collisionCategories = CollisionCategories.VolumeDtc;
1900 else if (m_isphantom)
1901 m_collisionCategories = CollisionCategories.Phantom;
1903 m_collisionCategories = CollisionCategories.Geom;
1905 m_collisionFlags = 0;
1907 if (prim_geom != IntPtr.Zero)
1911 d.GeomSetCategoryBits(prim_geom, 0);
1912 d.GeomSetCollideBits(prim_geom, 0);
1916 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
1917 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
1919 UpdateDataFromGeom();
1920 d.GeomSetBody(prim_geom, IntPtr.Zero);
1921 SetInStaticSpace(
this);
1928 foreach (OdePrim prm
in childrenPrim)
1930 _parent_scene.remActivePrim(prm);
1932 if (prm.m_isSelected)
1933 prm.m_collisionCategories = CollisionCategories.Selected;
1934 else if (prm.m_isVolumeDetect)
1935 prm.m_collisionCategories = CollisionCategories.VolumeDtc;
1936 else if (prm.m_isphantom)
1937 prm.m_collisionCategories = CollisionCategories.Phantom;
1939 prm.m_collisionCategories = CollisionCategories.Geom;
1941 prm.m_collisionFlags = 0;
1943 if (prm.prim_geom != IntPtr.Zero)
1947 d.GeomSetCategoryBits(prm.prim_geom, 0);
1948 d.GeomSetCollideBits(prm.prim_geom, 0);
1952 d.GeomSetCategoryBits(prm.prim_geom, (uint)prm.m_collisionCategories);
1953 d.GeomSetCollideBits(prm.prim_geom, (uint)prm.m_collisionFlags);
1955 prm.UpdateDataFromGeom();
1956 SetInStaticSpace(prm);
1958 prm.Body = IntPtr.Zero;
1959 prm._mass = prm.primMass;
1960 prm.m_collisionscore = 0;
1963 if (Amotor != IntPtr.Zero)
1965 d.JointDestroy(Amotor);
1966 Amotor = IntPtr.Zero;
1968 _parent_scene.remActiveGroup(
this);
1969 d.BodyDestroy(Body);
1974 m_collisionscore = 0;
1977 private void FixInertia(Vector3 NewPos,Quaternion newrot)
1985 d.BodyGetMass(Body, out tmpdmass);
1986 objdmass = tmpdmass;
1992 dobjpos = d.BodyGetPosition(Body);
1995 tmpdmass = primdMass;
1998 mat = d.GeomGetOffsetRotation(prim_geom);
1999 d.MassRotate(ref tmpdmass, ref mat);
2001 thispos = d.GeomGetOffsetPosition(prim_geom);
2002 d.MassTranslate(ref tmpdmass,
2008 DMassSubPartFromObj(ref tmpdmass, ref objdmass);
2011 tmpdmass = primdMass;
2015 d.GeomSetOffsetWorldPosition(prim_geom, NewPos.X, NewPos.Y, NewPos.Z);
2016 _orientation = newrot;
2021 d.GeomSetOffsetWorldQuaternion(prim_geom, ref quat);
2023 mat = d.GeomGetOffsetRotation(prim_geom);
2024 d.MassRotate(ref tmpdmass, ref mat);
2026 thispos = d.GeomGetOffsetPosition(prim_geom);
2027 d.MassTranslate(ref tmpdmass,
2032 d.MassAdd(ref objdmass, ref tmpdmass);
2035 IntPtr g = d.BodyGetFirstGeom(Body);
2036 while (g != IntPtr.Zero)
2038 thispos = d.GeomGetOffsetPosition(g);
2039 thispos.X -= objdmass.c.X;
2040 thispos.Y -= objdmass.c.Y;
2041 thispos.Z -= objdmass.c.Z;
2042 d.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z);
2043 g = d.dBodyGetNextGeom(g);
2045 d.BodyVectorToWorld(Body,objdmass.c.X, objdmass.c.Y, objdmass.c.Z,out thispos);
2047 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z);
2048 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z);
2049 d.BodySetMass(Body, ref objdmass);
2050 _mass = objdmass.mass;
2053 private void FixInertia(Vector3 NewPos)
2063 d.BodyGetMass(Body, out objdmass);
2066 primmass = primdMass;
2068 primmat = d.GeomGetOffsetRotation(prim_geom);
2069 d.MassRotate(ref primmass, ref primmat);
2071 tmpdmass = primmass;
2073 thispos = d.GeomGetOffsetPosition(prim_geom);
2074 d.MassTranslate(ref tmpdmass,
2080 DMassSubPartFromObj(ref tmpdmass, ref objdmass);
2084 d.GeomSetOffsetWorldPosition(prim_geom, NewPos.X, NewPos.Y, NewPos.Z);
2086 thispos = d.GeomGetOffsetPosition(prim_geom);
2087 d.MassTranslate(ref primmass,
2092 d.MassAdd(ref objdmass, ref primmass);
2095 IntPtr g = d.BodyGetFirstGeom(Body);
2096 while (g != IntPtr.Zero)
2098 thispos = d.GeomGetOffsetPosition(g);
2099 thispos.X -= objdmass.c.X;
2100 thispos.Y -= objdmass.c.Y;
2101 thispos.Z -= objdmass.c.Z;
2102 d.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z);
2103 g = d.dBodyGetNextGeom(g);
2106 d.BodyVectorToWorld(Body, objdmass.c.X, objdmass.c.Y, objdmass.c.Z, out thispos);
2109 dobjpos = d.BodyGetPosition(Body);
2111 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z);
2112 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z);
2113 d.BodySetMass(Body, ref objdmass);
2114 _mass = objdmass.mass;
2117 private void FixInertia(Quaternion newrot)
2127 d.BodyGetMass(Body, out objdmass);
2130 tmpdmass = primdMass;
2131 mat = d.GeomGetOffsetRotation(prim_geom);
2132 d.MassRotate(ref tmpdmass, ref mat);
2134 thispos = d.GeomGetOffsetPosition(prim_geom);
2135 d.MassTranslate(ref tmpdmass,
2141 DMassSubPartFromObj(ref tmpdmass, ref objdmass);
2144 _orientation = newrot;
2149 d.GeomSetOffsetWorldQuaternion(prim_geom, ref quat);
2151 tmpdmass = primdMass;
2152 mat = d.GeomGetOffsetRotation(prim_geom);
2153 d.MassRotate(ref tmpdmass, ref mat);
2154 d.MassTranslate(ref tmpdmass,
2159 d.MassAdd(ref objdmass, ref tmpdmass);
2162 IntPtr g = d.BodyGetFirstGeom(Body);
2163 while (g != IntPtr.Zero)
2165 thispos = d.GeomGetOffsetPosition(g);
2166 thispos.X -= objdmass.c.X;
2167 thispos.Y -= objdmass.c.Y;
2168 thispos.Z -= objdmass.c.Z;
2169 d.GeomSetOffsetPosition(g, thispos.X, thispos.Y, thispos.Z);
2170 g = d.dBodyGetNextGeom(g);
2173 d.BodyVectorToWorld(Body, objdmass.c.X, objdmass.c.Y, objdmass.c.Z, out thispos);
2175 dobjpos = d.BodyGetPosition(Body);
2177 d.BodySetPosition(Body, dobjpos.X + thispos.X, dobjpos.Y + thispos.Y, dobjpos.Z + thispos.Z);
2178 d.MassTranslate(ref objdmass, -objdmass.c.X, -objdmass.c.Y, -objdmass.c.Z);
2179 d.BodySetMass(Body, ref objdmass);
2180 _mass = objdmass.mass;
2184 #region Mass Calculation
2186 private void UpdatePrimBodyData()
2188 primMass = m_density * primVolume;
2192 if (primMass > _parent_scene.maximumMassObject)
2193 primMass = _parent_scene.maximumMassObject;
2197 d.MassSetBoxTotal(out primdMass, primMass, 2.0f * m_OBB.X, 2.0f * m_OBB.Y, 2.0f * m_OBB.Z);
2199 d.MassTranslate(ref primdMass,
2204 primOOBradiusSQ = m_OBB.LengthSquared();
2206 if (_triMeshData != IntPtr.Zero)
2208 float pc = m_physCost;
2209 float psf = primOOBradiusSQ;
2220 m_streamCost = 1.0f;
2235 if (this.m_localID != prim.m_localID)
2242 if (!childrenPrim.Contains(prim))
2243 childrenPrim.Add(prim);
2247 foreach (
OdePrim prm
in prim.childrenPrim)
2249 if (!childrenPrim.Contains(prm))
2251 if (prm.
Body != IntPtr.Zero)
2254 d.GeomSetBody(prm.prim_geom, IntPtr.Zero);
2257 prm.Body = IntPtr.Zero;
2260 childrenPrim.Add(prm);
2266 prim.childrenPrim.Clear();
2268 if (prim.
Body != IntPtr.Zero)
2271 d.GeomSetBody(prim.prim_geom, IntPtr.Zero);
2273 prim.Body = IntPtr.Zero;
2276 prim.childPrim =
true;
2277 prim._parent =
this;
2283 private void UpdateChildsfromgeom()
2285 if (childrenPrim.Count > 0)
2287 foreach (
OdePrim prm
in childrenPrim)
2288 prm.UpdateDataFromGeom();
2292 private void UpdateDataFromGeom()
2294 if (prim_geom != IntPtr.Zero)
2297 d.GeomCopyQuaternion(prim_geom, out qtmp);
2298 _orientation.X = qtmp.X;
2299 _orientation.Y = qtmp.Y;
2300 _orientation.Z = qtmp.Z;
2301 _orientation.W = qtmp.W;
2309 _orientation.Normalize();
2311 d.Vector3 lpos = d.GeomGetPosition(prim_geom);
2312 _position.X = lpos.X;
2313 _position.Y = lpos.Y;
2314 _position.Z = lpos.Z;
2318 private void ChildDelink(OdePrim odePrim,
bool remakebodies)
2321 if (odePrim !=
this && !childrenPrim.Contains(odePrim))
2326 if (odePrim ==
this)
2328 OdePrim newroot = null;
2331 if (childrenPrim.Count > 0)
2333 newroot = childrenPrim[0];
2334 childrenPrim.RemoveAt(0);
2335 foreach (OdePrim prm
in childrenPrim)
2337 newroot.childrenPrim.Add(prm);
2339 childrenPrim.Clear();
2341 if (newroot != null)
2343 newroot.childPrim =
false;
2344 newroot._parent = null;
2355 childrenPrim.Remove(odePrim);
2356 odePrim.childPrim =
false;
2357 odePrim._parent = null;
2370 if (odePrim !=
this && !childrenPrim.Contains(odePrim))
2375 if (odePrim ==
this)
2380 if (childrenPrim.Count > 0)
2382 newroot = childrenPrim[0];
2383 childrenPrim.RemoveAt(0);
2384 foreach (
OdePrim prm
in childrenPrim)
2386 newroot.childrenPrim.Add(prm);
2388 childrenPrim.Clear();
2390 if (newroot != null)
2392 newroot.childPrim =
false;
2393 newroot._parent = null;
2405 childrenPrim.Remove(odePrim);
2406 odePrim.childPrim =
false;
2407 odePrim._parent = null;
2418 private void changeadd()
2422 private void changeAngularLock(byte newLocks)
2425 if (Body != IntPtr.Zero)
2429 if (_parent == null)
2433 createAMotor(newLocks);
2437 if (Amotor != IntPtr.Zero)
2439 d.JointDestroy(Amotor);
2440 Amotor = IntPtr.Zero;
2446 m_angularlocks = newLocks;
2449 private void changeLink(OdePrim NewParent)
2451 if (_parent == null && NewParent != null)
2453 NewParent.ParentPrim(
this);
2455 else if (_parent != null)
2457 if (_parent is OdePrim)
2459 if (NewParent != _parent)
2461 (_parent as OdePrim).ChildDelink(
this,
false);
2464 if (NewParent != null)
2466 NewParent.ParentPrim(
this);
2471 _parent = NewParent;
2480 m_forceacc = Vector3.Zero;
2481 m_angularForceacc = Vector3.Zero;
2483 _velocity = Vector3.Zero;
2484 _acceleration = Vector3.Zero;
2485 m_rotationalVelocity = Vector3.Zero;
2486 _target_velocity = Vector3.Zero;
2487 if (m_vehicle != null && m_vehicle.Type !=
Vehicle.TYPE_NONE)
2491 base.RequestPhysicsterseUpdate();
2494 if (Body != IntPtr.Zero)
2496 d.BodySetForce(Body, 0f, 0f, 0f);
2497 d.BodySetTorque(Body, 0f, 0f, 0f);
2498 d.BodySetLinearVel(Body, 0f, 0f, 0f);
2499 d.BodySetAngularVel(Body, 0f, 0f, 0f);
2503 private void changePhantomStatus(
bool newval)
2505 m_isphantom = newval;
2507 UpdateCollisionCatFlags();
2508 ApplyCollisionCatFlags();
2536 private void changeSelectedStatus(
bool newval)
2538 if (m_lastdoneSelected == newval)
2541 m_lastdoneSelected = newval;
2542 DoSelectedStatus(newval);
2545 private void CheckDelaySelect()
2549 DoSelectedStatus(m_isSelected);
2553 private void DoSelectedStatus(
bool newval)
2555 m_isSelected = newval;
2560 if (!childPrim && Body != IntPtr.Zero)
2561 d.BodyDisable(Body);
2563 if (m_delaySelect || m_isphysical)
2565 m_collisionCategories = CollisionCategories.Selected;
2566 m_collisionFlags = 0;
2570 foreach (OdePrim prm
in childrenPrim)
2572 prm.m_collisionCategories = m_collisionCategories;
2573 prm.m_collisionFlags = m_collisionFlags;
2575 if (prm.prim_geom != IntPtr.Zero)
2580 d.GeomSetCategoryBits(prm.prim_geom, 0);
2581 d.GeomSetCollideBits(prm.prim_geom, 0);
2585 d.GeomSetCategoryBits(prm.prim_geom, (uint)m_collisionCategories);
2586 d.GeomSetCollideBits(prm.prim_geom, (uint)m_collisionFlags);
2589 prm.m_delaySelect =
false;
2596 if (prim_geom != IntPtr.Zero)
2600 d.GeomSetCategoryBits(prim_geom, 0);
2601 d.GeomSetCollideBits(prim_geom, 0);
2602 if (collide_geom != prim_geom && collide_geom != IntPtr.Zero)
2604 d.GeomSetCategoryBits(collide_geom, 0);
2605 d.GeomSetCollideBits(collide_geom, 0);
2611 d.GeomSetCategoryBits(prim_geom, (uint)m_collisionCategories);
2612 d.GeomSetCollideBits(prim_geom, (uint)m_collisionFlags);
2613 if (collide_geom != prim_geom && collide_geom != IntPtr.Zero)
2615 d.GeomSetCategoryBits(collide_geom, (uint)m_collisionCategories);
2616 d.GeomSetCollideBits(collide_geom, (uint)m_collisionFlags);
2621 m_delaySelect =
false;
2623 else if(!m_isphysical)
2625 m_delaySelect =
true;
2632 if (Body != IntPtr.Zero && !m_disabled)
2641 UpdateCollisionCatFlags();
2642 ApplyCollisionCatFlags();
2644 m_delaySelect =
false;
2647 resetCollisionAccounting();
2650 private void changePosition(Vector3 newPos)
2662 else if (m_forcePosOrRotation && _position != newPos && Body != IntPtr.Zero)
2665 if (!d.BodyIsEnabled(Body))
2674 if (_position != newPos)
2676 d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
2679 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
2688 if (prim_geom != IntPtr.Zero)
2690 if (newPos != _position)
2692 d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
2695 m_targetSpace = _parent_scene.MoveGeomToStaticSpace(prim_geom, _position, m_targetSpace);
2700 if (givefakepos < 0)
2703 resetCollisionAccounting();
2706 private void changeOrientation(Quaternion newOri)
2715 _orientation = newOri;
2728 if (newOri != _orientation)
2735 d.GeomSetQuaternion(prim_geom, ref myrot);
2736 _orientation = newOri;
2737 if (Body != IntPtr.Zero && m_angularlocks != 0)
2738 createAMotor(m_angularlocks);
2740 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
2749 if (prim_geom != IntPtr.Zero)
2751 if (newOri != _orientation)
2758 d.GeomSetQuaternion(prim_geom, ref myrot);
2759 _orientation = newOri;
2764 if (givefakeori < 0)
2766 resetCollisionAccounting();
2769 private void changePositionAndOrientation(Vector3 newPos, Quaternion newOri)
2774 if (childPrim && m_building)
2777 _orientation = newOri;
2781 if (newOri != _orientation)
2788 d.GeomSetQuaternion(prim_geom, ref myrot);
2789 _orientation = newOri;
2790 if (Body != IntPtr.Zero && m_angularlocks != 0)
2791 createAMotor(m_angularlocks);
2793 if (_position != newPos)
2795 d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
2798 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
2810 if (prim_geom != IntPtr.Zero)
2812 if (newOri != _orientation)
2819 d.GeomSetQuaternion(prim_geom, ref myrot);
2820 _orientation = newOri;
2823 if (newPos != _position)
2825 d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
2828 m_targetSpace = _parent_scene.MoveGeomToStaticSpace(prim_geom, _position, m_targetSpace);
2833 if (givefakepos < 0)
2836 if (givefakeori < 0)
2838 resetCollisionAccounting();
2841 private void changeDisable(
bool disable)
2855 private void changePhysicsStatus(
bool NewStatus)
2859 m_isphysical = NewStatus;
2865 if (Body == IntPtr.Zero)
2870 if (Body != IntPtr.Zero)
2878 resetCollisionAccounting();
2881 private void changeSize(Vector3 newSize)
2889 private void changeAddPhysRep(ODEPhysRepData repData)
2891 _size = repData.size;
2893 m_shapetype = repData.shapetype;
2895 m_mesh = repData.mesh;
2897 m_assetID = repData.assetID;
2898 m_meshState = repData.meshState;
2900 m_hasOBB = repData.hasOBB;
2901 m_OBBOffset = repData.OBBOffset;
2902 m_OBB = repData.OBB;
2904 primVolume = repData.volume;
2908 if (prim_geom != IntPtr.Zero)
2910 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
2912 myrot.X = _orientation.X;
2913 myrot.Y = _orientation.Y;
2914 myrot.Z = _orientation.Z;
2915 myrot.W = _orientation.W;
2916 d.GeomSetQuaternion(prim_geom, ref myrot);
2921 SetInStaticSpace(
this);
2922 UpdateCollisionCatFlags();
2923 ApplyCollisionCatFlags();
2928 if ((m_meshState &
MeshState.NeedMask) != 0)
2930 repData.size = _size;
2932 repData.shapetype = m_shapetype;
2933 _parent_scene.m_meshWorker.RequestMesh(repData);
2937 private void changePhysRepData(ODEPhysRepData repData)
2941 OdePrim parent = (OdePrim)_parent;
2943 bool chp = childPrim;
2949 parent.DestroyBody();
2959 _size = repData.size;
2961 m_shapetype = repData.shapetype;
2963 m_mesh = repData.mesh;
2965 m_assetID = repData.assetID;
2966 m_meshState = repData.meshState;
2968 m_hasOBB = repData.hasOBB;
2969 m_OBBOffset = repData.OBBOffset;
2970 m_OBB = repData.OBB;
2972 primVolume = repData.volume;
2976 if (prim_geom != IntPtr.Zero)
2978 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
2980 myrot.X = _orientation.X;
2981 myrot.Y = _orientation.Y;
2982 myrot.Z = _orientation.Z;
2983 myrot.W = _orientation.W;
2984 d.GeomSetQuaternion(prim_geom, ref myrot);
3001 SetInStaticSpace(
this);
3002 UpdateCollisionCatFlags();
3003 ApplyCollisionCatFlags();
3006 resetCollisionAccounting();
3008 if ((m_meshState &
MeshState.NeedMask) != 0)
3010 repData.size = _size;
3012 repData.shapetype = m_shapetype;
3013 _parent_scene.m_meshWorker.RequestMesh(repData);
3017 private void changeFloatOnWater(
bool newval)
3019 m_collidesWater = newval;
3021 UpdateCollisionCatFlags();
3022 ApplyCollisionCatFlags();
3025 private void changeSetTorque(Vector3 newtorque)
3029 if (m_isphysical && Body != IntPtr.Zero)
3033 else if (!d.BodyIsEnabled(Body))
3037 m_torque = newtorque;
3041 private void changeForce(Vector3 force)
3044 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
3048 private void changeAddForce(Vector3 theforce)
3050 m_forceacc += theforce;
3056 if (m_isphysical && Body != IntPtr.Zero)
3060 else if (!d.BodyIsEnabled(Body))
3064 m_collisionscore = 0;
3069 private void changeAddAngularImpulse(Vector3 aimpulse)
3071 m_angularForceacc += aimpulse * m_invTimeStep;
3076 if (m_isphysical && Body != IntPtr.Zero)
3080 else if (!d.BodyIsEnabled(Body))
3084 m_collisionscore = 0;
3088 private void changevelocity(Vector3 newVel)
3090 float len = newVel.LengthSquared();
3091 if (len > 100000.0f)
3093 len = 100.0f / (float)Math.Sqrt(len);
3099 if (Body != IntPtr.Zero)
3103 else if (!d.BodyIsEnabled(Body))
3106 d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z);
3113 private void changeangvelocity(Vector3 newAngVel)
3115 float len = newAngVel.LengthSquared();
3116 if (len > _parent_scene.maxAngVelocitySQ)
3118 len = _parent_scene.maximumAngularVelocity / (float)Math.Sqrt(len);
3124 if (Body != IntPtr.Zero)
3128 else if (!d.BodyIsEnabled(Body))
3132 d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z);
3136 m_rotationalVelocity = newAngVel;
3139 private void changeVolumedetetion(
bool newVolDtc)
3141 m_isVolumeDetect = newVolDtc;
3142 m_fakeisVolumeDetect = newVolDtc;
3143 UpdateCollisionCatFlags();
3144 ApplyCollisionCatFlags();
3150 if (newbuilding == m_building)
3153 if ((
bool)newbuilding)
3166 if (!childPrim && childrenPrim.Count > 0)
3168 foreach (OdePrim prm
in childrenPrim)
3169 prm.changeBuilding(m_building);
3175 if (m_vehicle == null)
3177 m_vehicle.DoSetVehicle(vdata);
3180 private void changeVehicleType(
int value)
3182 if (value == (
int)
Vehicle.TYPE_NONE)
3184 if (m_vehicle != null)
3189 if (m_vehicle == null)
3190 m_vehicle =
new ODEDynamics(
this);
3192 m_vehicle.ProcessTypeChange((
Vehicle)value);
3196 private void changeVehicleFloatParam(strVehicleFloatParam fp)
3198 if (m_vehicle == null)
3201 m_vehicle.ProcessFloatVehicleParam((
Vehicle)fp.param, fp.value);
3204 private void changeVehicleVectorParam(strVehicleVectorParam vp)
3206 if (m_vehicle == null)
3208 m_vehicle.ProcessVectorVehicleParam((
Vehicle)vp.param, vp.value);
3211 private void changeVehicleRotationParam(strVehicleQuatParam qp)
3213 if (m_vehicle == null)
3215 m_vehicle.ProcessRotationVehicleParam((
Vehicle)qp.param, qp.value);
3218 private void changeVehicleFlags(strVehicleBoolParam bp)
3220 if (m_vehicle == null)
3222 m_vehicle.ProcessVehicleFlags(bp.param, bp.value);
3225 private void changeBuoyancy(
float b)
3230 private void changePIDTarget(Vector3 trg)
3235 private void changePIDTau(
float tau)
3240 private void changePIDActive(
bool val)
3245 private void changePIDHoverHeight(
float val)
3247 m_PIDHoverHeight = val;
3249 m_useHoverPID =
false;
3254 m_PIDHoverType = type;
3257 private void changePIDHoverTau(
float tau)
3259 m_PIDHoverTau = tau;
3262 private void changePIDHoverActive(
bool active)
3264 m_useHoverPID = active;
3271 if (!childPrim && m_isphysical && Body != IntPtr.Zero &&
3272 !m_disabled && !m_isSelected && !m_building && !m_outbounds)
3274 if (!d.BodyIsEnabled(Body))
3277 if (m_vehicle != null && m_vehicle.Type !=
Vehicle.TYPE_NONE)
3280 if (++bodydisablecontrol < 50)
3284 d.BodySetAngularVel(Body,0f,0f,0f);
3285 d.BodySetLinearVel(Body,0f,0f,0f);
3288 bodydisablecontrol = -4;
3291 if(bodydisablecontrol < 0)
3292 bodydisablecontrol ++;
3294 d.Vector3 lpos = d.GeomGetPosition(prim_geom);
3296 if (m_vehicle != null && m_vehicle.Type !=
Vehicle.TYPE_NONE)
3307 float m_mass = _mass;
3309 if (m_usePID && m_PIDTau > 0)
3314 (m_PIDTarget.X - lpos.X),
3315 (m_PIDTarget.Y - lpos.Y),
3316 (m_PIDTarget.Z - lpos.Z)
3319 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.02f))
3321 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
3322 d.BodySetLinearVel(Body, 0, 0, 0);
3329 float tmp = 1 / m_PIDTau;
3330 _target_velocity *= tmp;
3333 tmp = _target_velocity.Length();
3337 _target_velocity *= tmp;
3339 else if (tmp < 0.05f)
3342 _target_velocity *= tmp;
3345 d.Vector3 vel = d.BodyGetLinearVel(Body);
3346 fx = (_target_velocity.X - vel.X) * m_invTimeStep;
3347 fy = (_target_velocity.Y - vel.Y) * m_invTimeStep;
3348 fz = (_target_velocity.Z - vel.Z) * m_invTimeStep;
3354 else if (m_useHoverPID && m_PIDHoverTau != 0 && m_PIDHoverHeight != 0)
3360 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(lpos.X, lpos.Y);
3362 switch (m_PIDHoverType)
3364 case PIDHoverType.Ground:
3365 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
3368 case PIDHoverType.GroundAndWater:
3369 m_waterHeight = _parent_scene.GetWaterLevel();
3370 if (m_groundHeight > m_waterHeight)
3371 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
3373 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
3379 if (m_targetHoverHeight > m_groundHeight || m_isVolumeDetect)
3381 d.Vector3 vel = d.BodyGetLinearVel(Body);
3383 fz = (m_targetHoverHeight - lpos.Z);
3386 if (Math.Abs(fz) < 0.01f)
3388 d.BodySetPosition(Body, lpos.X, lpos.Y, m_targetHoverHeight);
3389 d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
3394 fz /= m_PIDHoverTau;
3396 float tmp = Math.Abs(fz);
3398 fz = 50 * Math.Sign(fz);
3400 fz = 0.1f * Math.Sign(fz);
3402 fz = ((fz - vel.Z) * m_invTimeStep);
3408 float b = (1.0f - m_buoyancy) * m_gravmod;
3409 fx = _parent_scene.gravityx * b;
3410 fy = _parent_scene.gravityy * b;
3411 fz = _parent_scene.gravityz * b;
3427 m_forceacc = Vector3.Zero;
3430 if (fx != 0 || fy != 0 || fz != 0)
3432 d.BodyAddForce(Body, fx, fy, fz);
3439 trq += m_angularForceacc;
3440 m_angularForceacc = Vector3.Zero;
3441 if (trq.X != 0 || trq.Y != 0 || trq.Z != 0)
3443 d.BodyAddTorque(Body, trq.X, trq.Y, trq.Z);
3457 if (_parent == null && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero)
3459 bool bodyenabled = d.BodyIsEnabled(Body);
3461 if(bodydisablecontrol < 0)
3464 if (bodyenabled || !_zeroFlag)
3466 bool lastZeroFlag = _zeroFlag;
3468 d.Vector3 lpos = d.GeomGetPosition(prim_geom);
3471 if (lpos.Z < -100 || lpos.Z > 100000f)
3475 lpos.Z = Util.Clip(lpos.Z, -100f, 100000f);
3476 _acceleration.X = 0;
3477 _acceleration.Y = 0;
3478 _acceleration.Z = 0;
3483 m_rotationalVelocity.X = 0;
3484 m_rotationalVelocity.Y = 0;
3485 m_rotationalVelocity.Z = 0;
3487 d.BodySetLinearVel(Body, 0, 0, 0);
3488 d.BodySetAngularVel(Body, 0, 0, 0);
3489 d.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z);
3490 m_lastposition = _position;
3491 m_lastorientation = _orientation;
3493 base.RequestPhysicsterseUpdate();
3499 base.RaiseOutOfBounds(_position);
3505 _position.X = Util.Clip(lpos.X, -2f, -0.1f);
3508 else if (lpos.X > _parent_scene.WorldExtents.X)
3510 _position.X = Util.Clip(lpos.X, _parent_scene.WorldExtents.X + 0.1f, _parent_scene.WorldExtents.X + 2f);
3515 _position.Y = Util.Clip(lpos.Y, -2f, -0.1f);
3518 else if (lpos.Y > _parent_scene.WorldExtents.Y)
3520 _position.Y = Util.Clip(lpos.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f);
3526 m_lastposition = _position;
3527 m_lastorientation = _orientation;
3529 d.Vector3 dtmp = d.BodyGetAngularVel(Body);
3530 m_rotationalVelocity.X = dtmp.X;
3531 m_rotationalVelocity.Y = dtmp.Y;
3532 m_rotationalVelocity.Z = dtmp.Z;
3534 dtmp = d.BodyGetLinearVel(Body);
3535 _velocity.X = dtmp.X;
3536 _velocity.Y = dtmp.Y;
3537 _velocity.Z = dtmp.Z;
3539 d.BodySetLinearVel(Body, 0, 0, 0);
3540 d.BodySetAngularVel(Body, 0, 0, 0);
3541 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
3543 UnSubscribeEvents();
3545 base.RequestPhysicsterseUpdate();
3550 d.GeomCopyQuaternion(prim_geom, out ori);
3576 (Math.Abs(_position.X - lpos.X) < poserror)
3577 && (Math.Abs(_position.Y - lpos.Y) < poserror)
3578 && (Math.Abs(_position.Z - lpos.Z) < poserror)
3579 && (Math.Abs(_orientation.X - ori.X) < angerror)
3580 && (Math.Abs(_orientation.Y - ori.Y) < angerror)
3581 && (Math.Abs(_orientation.Z - ori.Z) < angerror)
3589 if (!(_zeroFlag && lastZeroFlag))
3591 _position.X = lpos.X;
3592 _position.Y = lpos.Y;
3593 _position.Z = lpos.Z;
3595 _orientation.X = ori.X;
3596 _orientation.Y = ori.Y;
3597 _orientation.Z = ori.Z;
3598 _orientation.W = ori.W;
3602 if (_zeroFlag || lastZeroFlag)
3605 _velocity = Vector3.Zero;
3606 _acceleration = Vector3.Zero;
3607 m_rotationalVelocity = Vector3.Zero;
3611 d.Vector3 vel = d.BodyGetLinearVel(Body);
3613 _acceleration = _velocity;
3615 if ((Math.Abs(vel.X) < 0.005f) &&
3616 (Math.Abs(vel.Y) < 0.005f) &&
3617 (Math.Abs(vel.Z) < 0.005f))
3619 _velocity = Vector3.Zero;
3620 float t = -m_invTimeStep;
3621 _acceleration = _acceleration * t;
3625 _velocity.X = vel.X;
3626 _velocity.Y = vel.Y;
3627 _velocity.Z = vel.Z;
3628 _acceleration = (_velocity - _acceleration) * m_invTimeStep;
3631 if ((Math.Abs(_acceleration.X) < 0.01f) &&
3632 (Math.Abs(_acceleration.Y) < 0.01f) &&
3633 (Math.Abs(_acceleration.Z) < 0.01f))
3635 _acceleration = Vector3.Zero;
3638 vel = d.BodyGetAngularVel(Body);
3639 if ((Math.Abs(vel.X) < 0.0001) &&
3640 (Math.Abs(vel.Y) < 0.0001) &&
3641 (Math.Abs(vel.Z) < 0.0001)
3644 m_rotationalVelocity = Vector3.Zero;
3648 m_rotationalVelocity.X = vel.X;
3649 m_rotationalVelocity.Y = vel.Y;
3650 m_rotationalVelocity.Z = vel.Z;
3656 if (!m_lastUpdateSent)
3658 base.RequestPhysicsterseUpdate();
3660 m_lastUpdateSent =
true;
3665 base.RequestPhysicsterseUpdate();
3666 m_lastUpdateSent =
false;
3671 internal static bool QuaternionIsFinite(Quaternion q)
3673 if (Single.IsNaN(q.X) || Single.IsInfinity(q.X))
3675 if (Single.IsNaN(q.Y) || Single.IsInfinity(q.Y))
3677 if (Single.IsNaN(q.Z) || Single.IsInfinity(q.Z))
3679 if (Single.IsNaN(q.W) || Single.IsInfinity(q.W))
3684 internal static void DMassSubPartFromObj(ref d.Mass part, ref d.Mass theobj)
3687 float smass = part.mass;
3688 theobj.mass -= smass;
3690 smass *= 1.0f / (theobj.mass); ;
3692 theobj.c.X -= part.c.X * smass;
3693 theobj.c.Y -= part.c.Y * smass;
3694 theobj.c.Z -= part.c.Z * smass;
3696 theobj.I.M00 -= part.I.M00;
3697 theobj.I.M01 -= part.I.M01;
3698 theobj.I.M02 -= part.I.M02;
3699 theobj.I.M10 -= part.I.M10;
3700 theobj.I.M11 -= part.I.M11;
3701 theobj.I.M12 -= part.I.M12;
3702 theobj.I.M20 -= part.I.M20;
3703 theobj.I.M21 -= part.I.M21;
3704 theobj.I.M22 -= part.I.M22;
3707 private void donullchange()
3713 if (prim_geom == IntPtr.Zero && what !=
changes.Add && what !=
changes.AddPhysRep && what !=
changes.Remove)
3725 case changes.AddPhysRep:
3729 case changes.Remove:
3732 if (_parent != null)
3734 OdePrim parent = (OdePrim)_parent;
3735 parent.ChildRemove(
this,
false);
3738 ChildRemove(
this,
false);
3742 m_targetSpace = IntPtr.Zero;
3743 UnSubscribeEvents();
3747 OdePrim tmp = (OdePrim)arg;
3751 case changes.DeLink:
3755 case changes.Position:
3756 changePosition((Vector3)arg);
3759 case changes.Orientation:
3760 changeOrientation((Quaternion)arg);
3763 case changes.PosOffset:
3767 case changes.OriOffset:
3771 case changes.Velocity:
3772 changevelocity((Vector3)arg);
3779 case changes.AngVelocity:
3780 changeangvelocity((Vector3)arg);
3784 changeForce((Vector3)arg);
3787 case changes.Torque:
3788 changeSetTorque((Vector3)arg);
3791 case changes.AddForce:
3792 changeAddForce((Vector3)arg);
3795 case changes.AddAngForce:
3796 changeAddAngularImpulse((Vector3)arg);
3799 case changes.AngLock:
3800 changeAngularLock((byte)arg);
3804 changeSize((Vector3)arg);
3811 case changes.PhysRepData:
3815 case changes.CollidesWater:
3816 changeFloatOnWater((
bool)arg);
3819 case changes.VolumeDtc:
3820 changeVolumedetetion((
bool)arg);
3823 case changes.Phantom:
3824 changePhantomStatus((
bool)arg);
3827 case changes.Physical:
3828 changePhysicsStatus((
bool)arg);
3831 case changes.Selected:
3832 changeSelectedStatus((
bool)arg);
3835 case changes.disabled:
3836 changeDisable((
bool)arg);
3839 case changes.building:
3840 changeBuilding((
bool)arg);
3843 case changes.VehicleType:
3844 changeVehicleType((
int)arg);
3847 case changes.VehicleFlags:
3848 changeVehicleFlags((strVehicleBoolParam) arg);
3851 case changes.VehicleFloatParam:
3852 changeVehicleFloatParam((strVehicleFloatParam) arg);
3855 case changes.VehicleVectorParam:
3856 changeVehicleVectorParam((strVehicleVectorParam) arg);
3859 case changes.VehicleRotationParam:
3860 changeVehicleRotationParam((strVehicleQuatParam) arg);
3863 case changes.SetVehicle:
3867 case changes.Buoyancy:
3868 changeBuoyancy((
float)arg);
3871 case changes.PIDTarget:
3872 changePIDTarget((Vector3)arg);
3875 case changes.PIDTau:
3876 changePIDTau((
float)arg);
3879 case changes.PIDActive:
3880 changePIDActive((
bool)arg);
3883 case changes.PIDHoverHeight:
3884 changePIDHoverHeight((
float)arg);
3887 case changes.PIDHoverType:
3891 case changes.PIDHoverTau:
3892 changePIDHoverTau((
float)arg);
3895 case changes.PIDHoverActive:
3896 changePIDHoverActive((
bool)arg);
3914 _parent_scene.AddChange((
PhysicsActor)
this, what, arg);
3918 private struct strVehicleBoolParam
3924 private struct strVehicleFloatParam
3930 private struct strVehicleQuatParam
3933 public Quaternion value;
3936 private struct strVehicleVectorParam
3939 public Vector3 value;
override void LockAngularMotion(byte axislock)
override void CrossingFailure()
override void SetVolumeDetect(int param)
Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more ...
override void SetVehicle(object vdata)
void UpdatePositionAndVelocity(int frame)
override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
delegate void SetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun)
OdePrim(String primName, ODEScene parent_scene, Vector3 pos, Vector3 size, Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical, bool pisPhantom, byte _shapeType, uint plocalID)
override void AddAngularForce(Vector3 force, bool pushforce)
ContactData[] m_materialContactsData
Used to pass collision information to OnCollisionUpdate listeners.
override void VehicleRotationParam(int param, Quaternion value)
void ChildRemove(OdePrim odePrim, bool reMakeBody)
IntPtr m_targetSpace
The physics space which contains prim geometry
float GetTerrainHeightAtXY(float x, float y)
override void SubscribeEvents(int ms)
override void SetMaterial(int pMaterial)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
override bool SubscribedEvents()
override void SetMomentum(Vector3 momentum)
override void VehicleFloatParam(int param, float value)
void SetAcceleration(Vector3 accel)
void changeBuilding(bool newbuilding)
bool DoAChange(changes what, object arg)
void AddChange(changes what, object arg)
bool m_forcePosOrRotation
override void VehicleVectorParam(int param, Vector3 value)
override void getContactData(ref ContactData cdata)
void ParentPrim(OdePrim prim)
Add a child prim to this parent prim.
void changeSetVehicle(VehicleData vdata)
override void VehicleFlags(int param, bool value)
Material
Material type for a primitive
override void AddForce(Vector3 force, bool pushforce)
override void UnSubscribeEvents()
override void link(PhysicsActor obj)