本文整理汇总了C#中OpenSim.Region.Physics.OdePlugin.OdePrim类的典型用法代码示例。如果您正苦于以下问题:C# OdePrim类的具体用法?C# OdePrim怎么用?C# OdePrim使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OdePrim类属于OpenSim.Region.Physics.OdePlugin命名空间,在下文中一共展示了OdePrim类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPrim
private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
PrimitiveBaseShape pbs, bool isphysical, uint localID)
{
Vector3 pos = position;
Vector3 siz = size;
Quaternion rot = rotation;
OdePrim newPrim;
lock (OdeLock)
{
newPrim = new OdePrim(name, this, pos, siz, rot, pbs, isphysical);
lock (_prims)
_prims.Add(newPrim);
}
newPrim.LocalID = localID;
return newPrim;
}
示例2: addActivePrim
public void addActivePrim(OdePrim activatePrim)
{
// adds active prim.. (ones that should be iterated over in collisions_optimized
lock (_activeprims)
{
if (!_activeprims.Contains(activatePrim))
_activeprims.Add(activatePrim);
//else
// m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent");
}
}
示例3: ChildDelink
private void ChildDelink(OdePrim odePrim)
{
// Okay, we have a delinked child.. need to rebuild the body.
lock (childrenPrim)
{
foreach (OdePrim prm in childrenPrim)
{
prm.childPrim = true;
prm.disableBody();
//prm.m_taintparent = null;
//prm._parent = null;
//prm.m_taintPhysics = false;
//prm.m_disabled = true;
//prm.childPrim = false;
}
}
disableBody();
lock (childrenPrim)
{
//Console.WriteLine("childrenPrim.Remove " + odePrim);
childrenPrim.Remove(odePrim);
}
if (Body != IntPtr.Zero)
{
_parent_scene.remActivePrim(this);
}
lock (childrenPrim)
{
foreach (OdePrim prm in childrenPrim)
{
//Console.WriteLine("ChildDelink calls ParentPrim");
AddChildPrim(prm);
}
}
}
示例4: RemovePrimThreadLocked
/// <summary>
/// This is called from within simulate but outside the locked portion
/// We need to do our own locking here
/// (Note: As of 20110801 this no longer appears to be true - this is being called within lock (odeLock) in
/// Simulate() -- justincc).
///
/// Essentially, we need to remove the prim from our space segment, whatever segment it's in.
///
/// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory
/// that the space was using.
/// </summary>
/// <param name="prim"></param>
internal void RemovePrimThreadLocked(OdePrim prim)
{
// m_log.DebugFormat("[ODE SCENE]: Removing physical prim {0} {1}", prim.Name, prim.LocalID);
lock (prim)
{
RemoveCollisionEventReporting(prim);
if (prim.prim_geom != IntPtr.Zero)
{
prim.ResetTaints();
if (prim.IsPhysical)
{
prim.disableBody();
if (prim.childPrim)
{
prim.childPrim = false;
prim.Body = IntPtr.Zero;
prim.m_disabled = true;
prim.IsPhysical = false;
}
}
// we don't want to remove the main space
// If the geometry is in the targetspace, remove it from the target space
//m_log.Warn(prim.m_targetSpace);
//if (prim.m_targetSpace != IntPtr.Zero)
//{
//if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
//{
//if (d.GeomIsSpace(prim.m_targetSpace))
//{
//waitForSpaceUnlock(prim.m_targetSpace);
//d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
prim.m_targetSpace = IntPtr.Zero;
//}
//else
//{
// m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
//((OdePrim)prim).m_targetSpace.ToString());
//}
//}
//}
//m_log.Warn(prim.prim_geom);
if (!prim.RemoveGeom())
m_log.Warn("[ODE SCENE]: Unable to remove prim from physics scene");
lock (_prims)
_prims.Remove(prim);
//If there are no more geometries in the sub-space, we don't need it in the main space anymore
//if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
//{
//if (prim.m_targetSpace != null)
//{
//if (d.GeomIsSpace(prim.m_targetSpace))
//{
//waitForSpaceUnlock(prim.m_targetSpace);
//d.SpaceRemove(space, prim.m_targetSpace);
// free up memory used by the space.
//d.SpaceDestroy(prim.m_targetSpace);
//int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
//resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
//}
//else
//{
//m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
//((OdePrim) prim).m_targetSpace.ToString());
//}
//}
//}
if (SupportsNINJAJoints)
RemoveAllJointsConnectedToActorThreadLocked(prim);
}
}
}
示例5: ChildSetGeom
private void ChildSetGeom(OdePrim odePrim)
{
// m_log.DebugFormat(
// "[ODE PRIM]: ChildSetGeom {0} {1} for {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID);
//if (IsPhysical && Body != IntPtr.Zero)
lock (childrenPrim)
{
foreach (OdePrim prm in childrenPrim)
{
//prm.childPrim = true;
prm.disableBody();
//prm.m_taintparent = null;
//prm._parent = null;
//prm.m_taintPhysics = false;
//prm.m_disabled = true;
//prm.childPrim = false;
}
}
disableBody();
// Spurious - Body == IntPtr.Zero after disableBody()
// if (Body != IntPtr.Zero)
// {
// _parent_scene.DeactivatePrim(this);
// }
lock (childrenPrim)
{
foreach (OdePrim prm in childrenPrim)
{
//Console.WriteLine("ChildSetGeom calls ParentPrim");
AddChildPrim(prm);
}
}
}
示例6: AddChildPrim
/// <summary>
/// Add a child prim to this parent prim.
/// </summary>
/// <param name="prim">Child prim</param>
public void AddChildPrim(OdePrim prim)
{
//Console.WriteLine("AddChildPrim " + Name);
if (this.m_localID != prim.m_localID)
{
if (Body == IntPtr.Zero)
{
Body = d.BodyCreate(_parent_scene.world);
setMass();
}
if (Body != IntPtr.Zero)
{
lock (childrenPrim)
{
if (!childrenPrim.Contains(prim))
{
//Console.WriteLine("childrenPrim.Add " + prim);
childrenPrim.Add(prim);
foreach (OdePrim prm in childrenPrim)
{
d.Mass m2;
d.MassSetZero(out m2);
d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z);
d.Quaternion quat = new d.Quaternion();
quat.W = prm._orientation.W;
quat.X = prm._orientation.X;
quat.Y = prm._orientation.Y;
quat.Z = prm._orientation.Z;
d.Matrix3 mat = new d.Matrix3();
d.RfromQ(out mat, ref quat);
d.MassRotate(ref m2, ref mat);
d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z);
d.MassAdd(ref pMass, ref m2);
}
foreach (OdePrim prm in childrenPrim)
{
prm.m_collisionCategories |= CollisionCategories.Body;
prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind);
if (prm.prim_geom == IntPtr.Zero)
{
m_log.WarnFormat(
"[PHYSICS]: Unable to link one of the linkset elements {0} for parent {1}. No geom yet",
prm.Name, prim.Name);
continue;
}
//Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name);
d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories);
d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags);
d.Quaternion quat = new d.Quaternion();
quat.W = prm._orientation.W;
quat.X = prm._orientation.X;
quat.Y = prm._orientation.Y;
quat.Z = prm._orientation.Z;
d.Matrix3 mat = new d.Matrix3();
d.RfromQ(out mat, ref quat);
if (Body != IntPtr.Zero)
{
d.GeomSetBody(prm.prim_geom, Body);
prm.childPrim = true;
d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z);
//d.GeomSetOffsetPosition(prim.prim_geom,
// (Position.X - prm.Position.X) - pMass.c.X,
// (Position.Y - prm.Position.Y) - pMass.c.Y,
// (Position.Z - prm.Position.Z) - pMass.c.Z);
d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat);
//d.GeomSetOffsetRotation(prm.prim_geom, ref mat);
d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z);
d.BodySetMass(Body, ref pMass);
}
else
{
m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name);
}
prm.m_interpenetrationcount = 0;
prm.m_collisionscore = 0;
prm.m_disabled = false;
// The body doesn't already have a finite rotation mode set here
if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
{
prm.createAMotor(m_angularlock);
}
prm.Body = Body;
_parent_scene.addActivePrim(prm);
}
m_collisionCategories |= CollisionCategories.Body;
//.........这里部分代码省略.........
示例7: ChildRemove
protected void ChildRemove(OdePrim odePrim, bool reMakeBody)
{
// Okay, we have a delinked child.. destroy all body and remake
if (odePrim != this && !childrenPrim.Contains(odePrim))
return;
DestroyBody();
if (odePrim == this)
{
OdePrim newroot = null;
lock (childrenPrim)
{
if (childrenPrim.Count > 0)
{
newroot = childrenPrim[0];
childrenPrim.RemoveAt(0);
foreach (OdePrim prm in childrenPrim)
{
newroot.childrenPrim.Add(prm);
}
childrenPrim.Clear();
}
if (newroot != null)
{
newroot.childPrim = false;
newroot._parent = null;
newroot.MakeBody();
}
}
if (reMakeBody)
MakeBody();
return;
}
else
{
lock (childrenPrim)
{
childrenPrim.Remove(odePrim);
odePrim.childPrim = false;
odePrim._parent = null;
if (reMakeBody)
odePrim.MakeBody();
}
}
MakeBody();
}
示例8: AddChange
public void AddChange(OdePrim prim, changes what, Object arg)
{
ODEchangeitem item = new ODEchangeitem();
item.prim = prim;
item.what = what;
item.arg = arg;
ChangesQueue.Enqueue(item);
}
示例9: ParentPrim
/// <summary>
/// Add a child prim to this parent prim.
/// </summary>
/// <param name="prim">Child prim</param>
// I'm the parent
// prim is the child
public void ParentPrim(OdePrim prim)
{
//Console.WriteLine("ParentPrim " + m_primName);
if (this.m_localID != prim.m_localID)
{
DestroyBody(); // for now we need to rebuil entire object on link change
lock (childrenPrim)
{
// adopt the prim
if (!childrenPrim.Contains(prim))
childrenPrim.Add(prim);
// see if this prim has kids and adopt them also
// should not happen for now
foreach (OdePrim prm in prim.childrenPrim)
{
if (!childrenPrim.Contains(prm))
{
if (prm.Body != IntPtr.Zero)
{
if (prm.prim_geom != IntPtr.Zero)
d.GeomSetBody(prm.prim_geom, IntPtr.Zero);
if(prm.Body != prim.Body)
prm.DestroyBody(); // don't loose bodies around
prm.Body = IntPtr.Zero;
}
childrenPrim.Add(prm);
prm._parent = this;
}
}
}
//Remove old children from the prim
prim.childrenPrim.Clear();
prim.childPrim = true;
prim._parent = this;
if (prim.Body != IntPtr.Zero)
{
if (prim.prim_geom != IntPtr.Zero)
d.GeomSetBody(prim.prim_geom, IntPtr.Zero);
prim.DestroyBody(); // don't loose bodies around
prim.Body = IntPtr.Zero;
}
MakeBody(); // full nasty reconstruction
}
}
示例10: ChildDelink
private void ChildDelink(OdePrim odePrim)
{
// Okay, we have a delinked child.. destroy all body and remake
if (odePrim != this && !childrenPrim.Contains(odePrim))
return;
DestroyBody();
if (odePrim == this) // delinking the root prim
{
OdePrim newroot = null;
lock (childrenPrim)
{
if (childrenPrim.Count > 0)
{
newroot = childrenPrim[0];
childrenPrim.RemoveAt(0);
foreach (OdePrim prm in childrenPrim)
{
newroot.childrenPrim.Add(prm);
}
childrenPrim.Clear();
}
if (newroot != null)
{
newroot.childPrim = false;
newroot._parent = null;
newroot.MakeBody();
}
}
}
else
{
lock (childrenPrim)
{
childrenPrim.Remove(odePrim);
odePrim.childPrim = false;
odePrim._parent = null;
// odePrim.UpdateDataFromGeom();
odePrim.MakeBody();
}
}
MakeBody();
}
示例11: SetInStaticSpace
//sets non physical prim m_targetSpace to right space in spaces grid for static prims
// should only be called for non physical prims unless they are becoming non physical
private void SetInStaticSpace(OdePrim prim)
{
IntPtr targetSpace = _parent_scene.MoveGeomToStaticSpace(prim.prim_geom, prim._position, prim.m_targetSpace);
prim.m_targetSpace = targetSpace;
}
示例12: ChildSetGeom
private void ChildSetGeom(OdePrim odePrim)
{
// well..
DestroyBody();
MakeBody();
}
示例13: CalculateMass
//.........这里部分代码省略.........
// use the common volume formula for all
volume = _size.X*_size.Y*_size.Z;
break;
}
// Calculate Path cut effect on volume
// Not exact, in the triangle hollow example
// They should never be zero or less then zero..
// we'll ignore it if it's less then zero
// ProfileEnd and ProfileBegin are values
// from 0 to 50000
// Turning them back into percentages so that I can cut that percentage off the volume
float PathCutEndAmount = _pbs.ProfileEnd;
float PathCutStartAmount = _pbs.ProfileBegin;
if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f)
{
float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount)/50000f);
// Check the return amount for sanity
if (pathCutAmount >= 0.99f)
pathCutAmount = 0.99f;
volume = volume - (volume*pathCutAmount);
}
UInt16 taperX = _pbs.PathScaleX;
UInt16 taperY = _pbs.PathScaleY;
float taperFactorX = 0;
float taperFactorY = 0;
// Mass = density * volume
if (taperX != 100)
{
if (taperX > 100)
{
taperFactorX = 1.0f - ((float)taperX / 200);
//m_log.Warn("taperTopFactorX: " + extr.taperTopFactorX.ToString());
}
else
{
taperFactorX = 1.0f - ((100 - (float)taperX) / 100);
//m_log.Warn("taperBotFactorX: " + extr.taperBotFactorX.ToString());
}
volume = (float)volume * ((taperFactorX / 3f) + 0.001f);
}
if (taperY != 100)
{
if (taperY > 100)
{
taperFactorY = 1.0f - ((float)taperY / 200);
//m_log.Warn("taperTopFactorY: " + extr.taperTopFactorY.ToString());
}
else
{
taperFactorY = 1.0f - ((100 - (float)taperY) / 100);
//m_log.Warn("taperBotFactorY: " + extr.taperBotFactorY.ToString());
}
volume = (float)volume * ((taperFactorY / 3f) + 0.001f);
}
returnMass = m_density*volume;
if (returnMass <= 0) returnMass = 0.0001f;//ckrinke: Mass must be greater then zero.
// Recursively calculate mass
bool HasChildPrim = false;
lock (childrenPrim)
{
if (childrenPrim.Count > 0)
{
HasChildPrim = true;
}
}
if (HasChildPrim)
{
OdePrim[] childPrimArr = new OdePrim[0];
lock (childrenPrim)
childPrimArr = childrenPrim.ToArray();
for (int i = 0; i < childPrimArr.Length; i++)
{
if (childPrimArr[i] != null && !childPrimArr[i].m_taintremove)
returnMass += childPrimArr[i].CalculateMass();
// failsafe, this shouldn't happen but with OpenSim, you never know :)
if (i > 256)
break;
}
}
return returnMass;
}
示例14: remActivePrim
public void remActivePrim(OdePrim deactivatePrim)
{
lock (_activeprims)
{
_activeprims.Remove(deactivatePrim);
}
}
示例15: changeLink
private void changeLink(OdePrim NewParent)
{
if (_parent == null && NewParent != null)
{
NewParent.ParentPrim(this);
}
else if (_parent != null)
{
if (_parent is OdePrim)
{
if (NewParent != _parent)
{
(_parent as OdePrim).ChildDelink(this);
childPrim = false;
if (NewParent != null)
{
NewParent.ParentPrim(this);
}
}
}
}
_parent = NewParent;
}