mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
BulletSim: add ForEachMember(action) call for linkset.
This commit is contained in:
@@ -167,9 +167,8 @@ public abstract class BSLinkset
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
lock (m_linksetActivityLock)
|
lock (m_linksetActivityLock)
|
||||||
{
|
{
|
||||||
if (m_children.Contains(child))
|
ret = m_children.Contains(child);
|
||||||
ret = true;
|
/* Safer version but the above should work
|
||||||
/*
|
|
||||||
foreach (BSPhysObject bp in m_children)
|
foreach (BSPhysObject bp in m_children)
|
||||||
{
|
{
|
||||||
if (child.LocalID == bp.LocalID)
|
if (child.LocalID == bp.LocalID)
|
||||||
@@ -183,6 +182,25 @@ public abstract class BSLinkset
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Perform an action on each member of the linkset including root prim.
|
||||||
|
// The action is performed only on the objects that are physically in the linkset.
|
||||||
|
// Depends on the action on whether this should be done at taint time.
|
||||||
|
public delegate bool ForEachMemberAction(BSPhysObject obj);
|
||||||
|
public virtual bool ForEachMember(ForEachMemberAction action)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
lock (m_linksetActivityLock)
|
||||||
|
{
|
||||||
|
action(LinksetRoot);
|
||||||
|
foreach (BSPhysObject po in m_taintChildren)
|
||||||
|
{
|
||||||
|
if (action(po))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// When physical properties are changed the linkset needs to recalculate
|
// When physical properties are changed the linkset needs to recalculate
|
||||||
// its internal properties.
|
// its internal properties.
|
||||||
// May be called at runtime or taint-time (just pass the appropriate flag).
|
// May be called at runtime or taint-time (just pass the appropriate flag).
|
||||||
@@ -224,13 +242,15 @@ public abstract class BSLinkset
|
|||||||
|
|
||||||
protected virtual float ComputeLinksetMass()
|
protected virtual float ComputeLinksetMass()
|
||||||
{
|
{
|
||||||
float mass;
|
float mass = LinksetRoot.MassRaw;
|
||||||
lock (m_linksetActivityLock)
|
if (HasAnyChildren)
|
||||||
{
|
{
|
||||||
mass = LinksetRoot.MassRaw;
|
lock (m_linksetActivityLock)
|
||||||
foreach (BSPhysObject bp in m_taintChildren)
|
|
||||||
{
|
{
|
||||||
mass += bp.MassRaw;
|
foreach (BSPhysObject bp in m_children)
|
||||||
|
{
|
||||||
|
mass += bp.MassRaw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mass;
|
return mass;
|
||||||
|
|||||||
Reference in New Issue
Block a user