BulletSim: fix line endings in newly added files (Is it DOS or is it UNIX? Only it's hairdresser knows for sure)

0.7.4.1
Robert Adams 2012-07-25 14:59:00 -07:00
parent d7add2940a
commit 0a4c080e63
2 changed files with 301 additions and 301 deletions

View File

@ -1,123 +1,123 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyrightD * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the * * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Region.Physics.BulletSPlugin namespace OpenSim.Region.Physics.BulletSPlugin
{ {
public class BSConstraint : IDisposable public class BSConstraint : IDisposable
{ {
private BulletSim m_world; private BulletSim m_world;
private BulletBody m_body1; private BulletBody m_body1;
private BulletBody m_body2; private BulletBody m_body2;
private BulletConstraint m_constraint; private BulletConstraint m_constraint;
private bool m_enabled = false; private bool m_enabled = false;
public BSConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, public BSConstraint(BulletSim world, BulletBody obj1, BulletBody obj2,
Vector3 frame1, Quaternion frame1rot, Vector3 frame1, Quaternion frame1rot,
Vector3 frame2, Quaternion frame2rot Vector3 frame2, Quaternion frame2rot
) )
{ {
m_world = world; m_world = world;
m_body1 = obj1; m_body1 = obj1;
m_body2 = obj2; m_body2 = obj2;
/* /*
BulletSimAPI.AddConstraint(world.ID, m_body1.ID, m_body2.ID, BulletSimAPI.AddConstraint(world.ID, m_body1.ID, m_body2.ID,
frame1, frame1rot, frame1, frame1rot,
frame2, frame2rot, frame2, frame2rot,
linearLow, linearHigh, linearLow, linearHigh,
angularLow, angularHigh angularLow, angularHigh
); );
*/ */
m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr,
frame1, frame1rot, frame1, frame1rot,
frame2, frame2rot)); frame2, frame2rot));
m_enabled = true; m_enabled = true;
} }
public void Dispose() public void Dispose()
{ {
if (m_enabled) if (m_enabled)
{ {
// BulletSimAPI.RemoveConstraint(m_world.ID, m_body1.ID, m_body2.ID); // BulletSimAPI.RemoveConstraint(m_world.ID, m_body1.ID, m_body2.ID);
BulletSimAPI.DestroyConstraint2(m_world.Ptr, m_constraint.Ptr); BulletSimAPI.DestroyConstraint2(m_world.Ptr, m_constraint.Ptr);
m_enabled = false; m_enabled = false;
} }
} }
public BulletBody Body1 { get { return m_body1; } } public BulletBody Body1 { get { return m_body1; } }
public BulletBody Body2 { get { return m_body2; } } public BulletBody Body2 { get { return m_body2; } }
public bool SetLinearLimits(Vector3 low, Vector3 high) public bool SetLinearLimits(Vector3 low, Vector3 high)
{ {
bool ret = false; bool ret = false;
if (m_enabled) if (m_enabled)
ret = BulletSimAPI.SetLinearLimits2(m_constraint.Ptr, low, high); ret = BulletSimAPI.SetLinearLimits2(m_constraint.Ptr, low, high);
return ret; return ret;
} }
public bool SetAngularLimits(Vector3 low, Vector3 high) public bool SetAngularLimits(Vector3 low, Vector3 high)
{ {
bool ret = false; bool ret = false;
if (m_enabled) if (m_enabled)
ret = BulletSimAPI.SetAngularLimits2(m_constraint.Ptr, low, high); ret = BulletSimAPI.SetAngularLimits2(m_constraint.Ptr, low, high);
return ret; return ret;
} }
public bool UseFrameOffset(bool useOffset) public bool UseFrameOffset(bool useOffset)
{ {
bool ret = false; bool ret = false;
float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
if (m_enabled) if (m_enabled)
ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff); ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff);
return ret; return ret;
} }
public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce) public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce)
{ {
bool ret = false; bool ret = false;
float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse;
if (m_enabled) if (m_enabled)
ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce);
return ret; return ret;
} }
public bool CalculateTransforms() public bool CalculateTransforms()
{ {
bool ret = false; bool ret = false;
if (m_enabled) if (m_enabled)
{ {
BulletSimAPI.CalculateTransforms2(m_constraint.Ptr); BulletSimAPI.CalculateTransforms2(m_constraint.Ptr);
ret = true; ret = true;
} }
return ret; return ret;
} }
} }
} }

View File

@ -1,178 +1,178 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyrightD * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the * * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using log4net; using log4net;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Region.Physics.BulletSPlugin namespace OpenSim.Region.Physics.BulletSPlugin
{ {
public class BSConstraintCollection : IDisposable public class BSConstraintCollection : IDisposable
{ {
// private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly string LogHeader = "[CONSTRAINT COLLECTION]"; // private static readonly string LogHeader = "[CONSTRAINT COLLECTION]";
delegate bool ConstraintAction(BSConstraint constrain); delegate bool ConstraintAction(BSConstraint constrain);
private List<BSConstraint> m_constraints; private List<BSConstraint> m_constraints;
private BulletSim m_world; private BulletSim m_world;
public BSConstraintCollection(BulletSim world) public BSConstraintCollection(BulletSim world)
{ {
m_world = world; m_world = world;
m_constraints = new List<BSConstraint>(); m_constraints = new List<BSConstraint>();
} }
public void Dispose() public void Dispose()
{ {
this.Clear(); this.Clear();
} }
public void Clear() public void Clear()
{ {
foreach (BSConstraint cons in m_constraints) foreach (BSConstraint cons in m_constraints)
{ {
cons.Dispose(); cons.Dispose();
} }
m_constraints.Clear(); m_constraints.Clear();
} }
public BSConstraint CreateConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, public BSConstraint CreateConstraint(BulletSim world, BulletBody obj1, BulletBody obj2,
Vector3 frame1, Quaternion frame1rot, Vector3 frame1, Quaternion frame1rot,
Vector3 frame2, Quaternion frame2rot) Vector3 frame2, Quaternion frame2rot)
{ {
BSConstraint constrain = new BSConstraint(world, obj1, obj2, frame1, frame1rot, frame2, frame2rot); BSConstraint constrain = new BSConstraint(world, obj1, obj2, frame1, frame1rot, frame2, frame2rot);
this.AddConstraint(constrain); this.AddConstraint(constrain);
return constrain; return constrain;
} }
public bool AddConstraint(BSConstraint cons) public bool AddConstraint(BSConstraint cons)
{ {
// There is only one constraint between any bodies. Remove any old just to make sure. // There is only one constraint between any bodies. Remove any old just to make sure.
RemoveAndDestroyConstraint(cons.Body1, cons.Body2); RemoveAndDestroyConstraint(cons.Body1, cons.Body2);
m_constraints.Add(cons); m_constraints.Add(cons);
return true; return true;
} }
// Get the constraint between two bodies. There can be only one the way we're using them. // Get the constraint between two bodies. There can be only one the way we're using them.
public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint) public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint)
{ {
bool found = false; bool found = false;
BSConstraint foundConstraint = null; BSConstraint foundConstraint = null;
uint lookingID1 = body1.ID; uint lookingID1 = body1.ID;
uint lookingID2 = body2.ID; uint lookingID2 = body2.ID;
ForEachConstraint(delegate(BSConstraint constrain) ForEachConstraint(delegate(BSConstraint constrain)
{ {
if ((constrain.Body1.ID == lookingID1 && constrain.Body2.ID == lookingID2) if ((constrain.Body1.ID == lookingID1 && constrain.Body2.ID == lookingID2)
|| (constrain.Body1.ID == lookingID2 && constrain.Body2.ID == lookingID1)) || (constrain.Body1.ID == lookingID2 && constrain.Body2.ID == lookingID1))
{ {
foundConstraint = constrain; foundConstraint = constrain;
found = true; found = true;
} }
return found; return found;
}); });
returnConstraint = foundConstraint; returnConstraint = foundConstraint;
return found; return found;
} }
public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2) public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2)
{ {
// return BulletSimAPI.RemoveConstraint(m_world.ID, obj1.ID, obj2.ID); // return BulletSimAPI.RemoveConstraint(m_world.ID, obj1.ID, obj2.ID);
bool ret = false; bool ret = false;
BSConstraint constrain; BSConstraint constrain;
if (this.TryGetConstraint(body1, body2, out constrain)) if (this.TryGetConstraint(body1, body2, out constrain))
{ {
// remove the constraint from our collection // remove the constraint from our collection
m_constraints.Remove(constrain); m_constraints.Remove(constrain);
// tell the engine that all its structures need to be freed // tell the engine that all its structures need to be freed
constrain.Dispose(); constrain.Dispose();
// we destroyed something // we destroyed something
ret = true; ret = true;
} }
return ret; return ret;
} }
public bool RemoveAndDestroyConstraint(BulletBody body1) public bool RemoveAndDestroyConstraint(BulletBody body1)
{ {
// return BulletSimAPI.RemoveConstraintByID(m_world.ID, obj.ID); // return BulletSimAPI.RemoveConstraintByID(m_world.ID, obj.ID);
List<BSConstraint> toRemove = new List<BSConstraint>(); List<BSConstraint> toRemove = new List<BSConstraint>();
uint lookingID = body1.ID; uint lookingID = body1.ID;
ForEachConstraint(delegate(BSConstraint constrain) ForEachConstraint(delegate(BSConstraint constrain)
{ {
if (constrain.Body1.ID == lookingID || constrain.Body2.ID == lookingID) if (constrain.Body1.ID == lookingID || constrain.Body2.ID == lookingID)
{ {
toRemove.Add(constrain); toRemove.Add(constrain);
} }
return false; return false;
}); });
lock (m_constraints) lock (m_constraints)
{ {
foreach (BSConstraint constrain in toRemove) foreach (BSConstraint constrain in toRemove)
{ {
m_constraints.Remove(constrain); m_constraints.Remove(constrain);
constrain.Dispose(); constrain.Dispose();
} }
} }
return (toRemove.Count > 0); return (toRemove.Count > 0);
} }
public bool RecalculateAllConstraints() public bool RecalculateAllConstraints()
{ {
foreach (BSConstraint constrain in m_constraints) foreach (BSConstraint constrain in m_constraints)
{ {
constrain.CalculateTransforms(); constrain.CalculateTransforms();
} }
return true; return true;
} }
// Lock the constraint list and loop through it. // Lock the constraint list and loop through it.
// The constraint action returns 'true' if it wants the loop aborted. // The constraint action returns 'true' if it wants the loop aborted.
private void ForEachConstraint(ConstraintAction action) private void ForEachConstraint(ConstraintAction action)
{ {
lock (m_constraints) lock (m_constraints)
{ {
foreach (BSConstraint constrain in m_constraints) foreach (BSConstraint constrain in m_constraints)
{ {
if (action(constrain)) if (action(constrain))
break; break;
} }
} }
} }
} }
} }