diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 246c669f4a..5805505947 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -10,7 +10,7 @@ people that make the day to day of OpenSim happen.
* dahlia
* Melanie Thielker
* Diva (Crista Lopes, University of California, Irvine)
-* Dan Lake (Intel)
+* dslake (Dan Lake, Intel)
* Marck
* Mic Bowman (Intel)
* BlueWall (James Hughes)
@@ -75,7 +75,7 @@ what it is today.
* daTwitch
* devalnor-#708
* dmiles (Daxtron Labs)
-* dslake (Intel)
+* dslake (Dan Lake, Intel)
* FredoChaplin
* Gerhard
* Godfrey
@@ -183,6 +183,10 @@ Some plugins are based on Cable Beach
Cable Beach is Copyright (c) 2008 Intel Corporation
see http://forge.opensimulator.org/gf/project/assetserver/
+Some plugins are based on Distributed Scene Graph (DSG)
+Distributed Scene Graph is Copyright (c) 2011 Intel Corporation
+
+
In addition, we would like to thank:
* The Mono Project
* The NANT Developers
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/BlockingUpdateQueue.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/BlockingUpdateQueue.cs
index 083cbc7f9d..26c1120f93 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/BlockingUpdateQueue.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/BlockingUpdateQueue.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/DSGClientManagerLoadBalancer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/DSGClientManagerLoadBalancer.cs
index eb6323e439..faeba1829e 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/DSGClientManagerLoadBalancer.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/DSGClientManagerLoadBalancer.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs
index 4f93976a1a..417b39f224 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs
index 3f585841f2..2a6b8c51d8 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs
index cfd48fc544..04ef381cd5 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs
index fc43b54940..7face79c6e 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs
index f9e0ae3a2f..1283896bc7 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs
index 6b2c9720af..e19b6244bd 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs
index c7d7c44abe..cd0bd020d7 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs
index a8368b5fdc..f7b8483284 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs
index 79582d1294..8a1715645a 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncUtil.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncUtil.cs
index 4d72b5dda1..3392aa251a 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncUtil.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncUtil.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs
index a4bd5f0c5b..03331c3812 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs
index 8c27328962..42d5132aa4 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs
index bb563c242c..66fe933675 100755
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -104,8 +108,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
//Register for Scene/SceneGraph events
- //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ClientManager_OnObjectCreate);
- m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ClientManager_OnObjectCreateBySync);
m_scene.EventManager.OnSymmetricSyncStop += ClientManager_OnSymmetricSyncStop;
}
@@ -169,21 +171,18 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private string LogHeader = "[ClientManagerSyncModule]";
///
- /// Script Engine's action upon an object is added to the local scene
+ /// Client Manager's action upon an object is added to the local scene
///
private void ClientManager_OnObjectCreateBySync(EntityBase entity)
{
- if (entity is SceneObjectGroup)
- {
- }
}
public void ClientManager_OnSymmetricSyncStop()
{
//remove all objects
- m_scene.DeleteAllSceneObjects();
+ //m_scene.DeleteAllSceneObjects();
}
#endregion //ScriptEngineSyncModule
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/GridDialogModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/GridDialogModule.cs
index 9bdfdf4b9a..ffd2c4b781 100755
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/GridDialogModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/GridDialogModule.cs
@@ -1,13 +1,16 @@
-
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -214,7 +217,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
Hashtable msgdata = new Hashtable();
msgdata["avatarID"] = avatarID.ToString();
msgdata["objectName"] = objectName;
- msgdata["objectID"] = objectID.ToString();
+ msgdata["objectID"] = objectID.ToString();
msgdata["ownerID"] = ownerID.ToString();
msgdata["ownerFirstName"] = ownerFirstName;
msgdata["ownerLastName"] = ownerLastName;
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs
index d0160f2ac9..e305901a33 100755
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -111,8 +115,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
//Register for Scene/SceneGraph events
- //m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(PhysicsEngine_OnObjectCreate);
- m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(PhysicsEngine_OnObjectCreateBySync);
m_scene.EventManager.OnSymmetricSyncStop += PhysicsEngine_OnSymmetricSyncStop;
}
@@ -176,7 +178,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private string LogHeader = "[PhysicsEngineSyncModule]";
///
- /// Script Engine's action upon an object is added to the local scene
+ /// Physics Engine's action upon an object is added to the local scene
///
private void PhysicsEngine_OnObjectCreateBySync(EntityBase entity)
{
@@ -193,4 +195,4 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
#endregion PhysicsEngineSyncModule members and functions
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs
index e1cde8ba1d..c62bc5aab9 100644
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -387,6 +391,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
data["partCount"] = OSD.FromInteger(children.Count);
data["actorID"] = OSD.FromString(m_actorID);
int partNum = 0;
+
+ string debugString = "";
foreach (SceneObjectPart part in children)
{
string partTempID = "part" + partNum;
@@ -394,8 +400,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
partNum++;
//m_log.DebugFormat("{0}: SendLinkObject to link {1},{2} with {3}, {4}", part.Name, part.UUID, root.Name, root.UUID);
+ debugString += part.UUID + ", ";
}
+ m_log.DebugFormat("SyncLinkObject: SendLinkObject to link parts {0} with {1}, {2}", debugString, root.Name, root.UUID);
+
SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.LinkObject, OSDParser.SerializeJsonString(data));
SendSpecialObjectUpdateToRelevantSyncConnectors(m_actorID, linkedGroup, rsm);
//SendSceneEventToRelevantSyncConnectors(m_actorID, rsm, linkedGroup);
@@ -1098,7 +1107,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_log.WarnFormat("SyncStateReport {0} -- Object count: {1}, Prim Count {2} ", m_scene.RegionInfo.RegionName, sogList.Count, primCount);
foreach (SceneObjectGroup sog in sogList)
{
- m_log.WarnFormat("SyncStateReport -- SOG: name {0}, UUID {1}, position {2}", sog.Name, sog.UUID, sog.AbsolutePosition);
+ m_log.WarnFormat("\n\n SyncStateReport -- SOG: name {0}, UUID {1}, position {2}", sog.Name, sog.UUID, sog.AbsolutePosition);
+
foreach (SceneObjectPart part in sog.Parts)
{
Vector3 pos = Vector3.Zero;
@@ -1106,7 +1116,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
pos = part.PhysActor.Position;
}
- string debugMsg = "Part " + part.Name + "," + part.UUID+", LocalID "+part.LocalId;
+ string debugMsg = "\nPart " + part.Name + "," + part.UUID+", LocalID "+part.LocalId + "ProfileShape "+part.Shape.ProfileShape;
+ if (part.TaskInventory.Count > 0)
+ {
+ debugMsg += ", has " + part.TaskInventory.Count + " inventory items";
+ }
if (part.ParentGroup.RootPart.UUID == part.UUID)
{
debugMsg += ", RootPart, ";
@@ -1133,8 +1147,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
debugMsg += ", attached avatar's localID = "+sp.LocalId;
}
- m_log.WarnFormat(debugMsg);
+
}
+ m_log.WarnFormat(debugMsg);
}
}
@@ -1181,7 +1196,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
estimateBytes += 4; //propertySyncInfo.LastUpdateSource, enum
estimateBytes += propertySyncInfo.LastUpdateSyncID.Length;
- if (valPair.Key == SceneObjectPartSyncProperties.Shape || valPair.Key == SceneObjectPartSyncProperties.TaskInventory)
+ if (valPair.Key == SceneObjectPartSyncProperties.Shape)
+ {
+ //The value is only a reference to SOP.Shape, shouldn't use too many bytes in memory
+
+ //estimateBytes += propertySyncInfo.LastUpdateValue
+ estimateBytes += ((String)propertySyncInfo.LastUpdateValueHash).Length;
+ }
+ else if (valPair.Key == SceneObjectPartSyncProperties.TaskInventory)
{
estimateBytes += ((String)propertySyncInfo.LastUpdateValue).Length;
estimateBytes += ((String)propertySyncInfo.LastUpdateValueHash).Length;
@@ -1547,6 +1569,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return false;
}
+ bool connected = false;
foreach (RegionSyncListenerInfo remoteListener in m_remoteSyncListeners)
{
SyncConnector syncConnector = new SyncConnector(m_syncConnectorNum++, remoteListener, this);
@@ -1555,10 +1578,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
syncConnector.StartCommThreads();
AddSyncConnector(syncConnector);
m_synced = true;
+ connected = true;
}
}
- return true;
+ return connected;
}
//To be called when a SyncConnector needs to be created by that the local listener receives a connection request
@@ -1844,14 +1868,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
primUUID = data["primUUID"].AsUUID();
SceneObjectPart sop = m_scene.GetSceneObjectPart(primUUID);
+ propertiesSyncInfo = m_primSyncInfoManager.DecodePrimProperties(data);
+
if (sop == null || sop.ParentGroup.IsDeleted)
{
- m_log.WarnFormat("{0}: HandleUpdatedPrimProperties -- prim {1} no longer in local SceneGraph. SOP == NULL? ({2}), Sender is {3}",
- LogHeader, primUUID, sop == null, senderActorID);
+ bool shape = false;
+ foreach (PropertySyncInfo p in propertiesSyncInfo)
+ {
+ // pString += p.Property.ToString() + " ";
+ if (p.Property == SceneObjectPartSyncProperties.Shape){
+ shape = true;
+ }
+ }
+ //m_log.WarnFormat("{0}: HandleUpdatedPrimProperties -- prim {1} not in local SceneGraph. SOP == NULL? ({2}), Sender is {3}, property == Shape? {4}",
+ // LogHeader, primUUID, sop == null, senderActorID, shape);
return;
}
- propertiesSyncInfo = m_primSyncInfoManager.DecodePrimProperties(data);
+ //propertiesSyncInfo = m_primSyncInfoManager.DecodePrimProperties(data);
if (propertiesSyncInfo.Count>0)
{
@@ -1863,14 +1897,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
pString += p.Property.ToString() + " ";
if (p.Property == SceneObjectPartSyncProperties.Shape)
{
- PrimitiveBaseShape shape = PropertySerializer.DeSerializeShape((String)p.LastUpdateValue);
+ //PrimitiveBaseShape shape = PropertySerializer.DeSerializeShape((String)p.LastUpdateValue);
+ PrimitiveBaseShape shape = (PrimitiveBaseShape)p.LastUpdateValue;
m_log.DebugFormat("Shape to be changed on SOP {0}, {1} to ProfileShape {2}", sop.Name, sop.UUID, shape.ProfileShape);
}
}
+ * */
- m_log.DebugFormat("ms {0}: HandleUpdatedPrimProperties, for prim {1},{2} with updated properties -- {3}", DateTime.Now.Millisecond, sop.Name, sop.UUID, pString);
-
- * */
+ //m_log.DebugFormat("ms {0}: HandleUpdatedPrimProperties, for prim {1},{2} with updated properties -- {3}", DateTime.Now.Millisecond, sop.Name, sop.UUID, pString);
List propertiesUpdated = m_primSyncInfoManager.UpdatePrimSyncInfoBySync(sop, propertiesSyncInfo);
@@ -1880,13 +1914,17 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
m_log.DebugFormat("AggregateScriptEvents updated: " + sop.AggregateScriptEvents);
}
+
+
if (propertiesUpdated.Contains(SceneObjectPartSyncProperties.Shape))
{
- String hashedShape = Util.Md5Hash((PropertySerializer.SerializeShape(sop)));
- m_log.DebugFormat("HandleUpdatedPrimProperties -- SOP {0},{1}, Shape updated, ProfileShape {2}, hashed value in SOP:{3}, in PrinSyncInfoManager: {4}",
- sop.Name, sop.UUID, sop.Shape.ProfileShape, hashedShape, m_primSyncInfoManager.GetPrimSyncInfo(sop.UUID).PropertiesSyncInfo[SceneObjectPartSyncProperties.Shape].LastUpdateValueHash);
+ string sopHashedShape = PropertySerializer.GetPropertyHashValue(PropertySerializer.SerializeShape(sop));
+ m_log.DebugFormat("HandleUpdatedPrimProperties -- SOP {0},{1}, Shape updated, ProfileShape {2}, hashed value for SOP.Shape:{3}, hashed value in PrinSyncInfoManager: {4}",
+ sop.Name, sop.UUID, sop.Shape.ProfileShape, sopHashedShape,
+ m_primSyncInfoManager.GetPrimSyncInfo(sop.UUID).PropertiesSyncInfo[SceneObjectPartSyncProperties.Shape].LastUpdateValueHash);
}
- * */
+ * */
+
if (propertiesUpdated.Count > 0)
{
@@ -2160,7 +2198,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
m_primSyncInfoManager.RemovePrimSyncInfo(part);
}
- m_scene.DeleteSceneObjectBySynchronization(sog);
+ m_scene.DeleteSceneObjectBySync(sog);
}
else
{
@@ -2219,7 +2257,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//break;
case SymmetricSyncMessage.MsgType.ChatBroadcast:
//HandleRemoteEvent_OnChatBroadcast(init_actorID, evSeqNum, data);
- HandleRemoveEvent_OnChatEvents(msg.Type, init_actorID, evSeqNum, data);
+ HandleRemoteEvent_OnChatEvents(msg.Type, init_actorID, evSeqNum, data);
break;
case SymmetricSyncMessage.MsgType.ObjectGrab:
HandleRemoteEvent_OnObjectGrab(init_actorID, evSeqNum, data);
@@ -2331,7 +2369,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
///
///
/// The args of the event
- private void HandleRemoveEvent_OnChatEvents(SymmetricSyncMessage.MsgType msgType, string actorID, ulong evSeqNum, OSDMap data)
+ private void HandleRemoteEvent_OnChatEvents(SymmetricSyncMessage.MsgType msgType, string actorID, ulong evSeqNum, OSDMap data)
{
OSChatMessage args = new OSChatMessage();
args.Channel = data["channel"].AsInteger();
@@ -3363,8 +3401,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
HashSet updatedProperties = updatedPrimProperties.Value;
//Sync the SOP data and cached property values in PrimSyncInfoManager again
- HashSet propertiesWithSyncInfoUpdated = m_primSyncInfoManager.UpdatePrimSyncInfoByLocal(sop, new List(updatedProperties));
- updatedProperties.UnionWith(propertiesWithSyncInfoUpdated);
+ //HashSet propertiesWithSyncInfoUpdated = m_primSyncInfoManager.UpdatePrimSyncInfoByLocal(sop, new List(updatedProperties));
+ //updatedProperties.UnionWith(propertiesWithSyncInfoUpdated);
SendPrimPropertyUpdates(sop, updatedProperties);
}
}
@@ -3381,7 +3419,17 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private void SendPrimPropertyUpdates(SceneObjectPart sop, HashSet updatedProperties)
{
- OSDMap syncData = m_primSyncInfoManager.EncodePrimProperties(sop, updatedProperties);
+ OSDMap syncData;
+ try
+ {
+ syncData = m_primSyncInfoManager.EncodePrimProperties(sop, updatedProperties);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("Error in EncodePrimProperties for SOP {0}, {1}, ErrorMessage -- {2}", sop.Name, sop.UUID, e.Message);
+ return;
+ }
+
if (syncData.Count > 0)
{
@@ -3405,7 +3453,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
m_log.DebugFormat("SendPrimPropertyUpdates -- prim {0}: Position: {1} ", sop.Name, sop.PhysActor.Position);
}
- * */
+
+
+ if (updatedProperties.Contains(SceneObjectPartSyncProperties.Shape))
+ {
+ String hashedShape = Util.Md5Hash((PropertySerializer.SerializeShape(sop)));
+ m_log.DebugFormat("SendPrimPropertyUpdates -- SOP {0},{1}, Shape updated, ProfileShape {2}, hashed value in SOP:{3}, in PrinSyncInfoManager: {4}",
+ sop.Name, sop.UUID, sop.Shape.ProfileShape, hashedShape, m_primSyncInfoManager.GetPrimSyncInfo(sop.UUID).PropertiesSyncInfo[SceneObjectPartSyncProperties.Shape].LastUpdateValueHash);
+ }
+ * */
SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedPrimProperties, OSDParser.SerializeJsonString(syncData));
SendPrimUpdateToRelevantSyncConnectors(sop.UUID, syncMsg);
@@ -3475,6 +3531,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
SceneObjectGroup group;
Dictionary primsSyncInfo;
+
SceneObjectDecoder(data, out group, out primsSyncInfo);
if (group == null)
@@ -3484,7 +3541,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
//DSG DEBUG
- //m_log.DebugFormat("calling AddNewSceneObjectByDecoding for SOG {0}, {1}", group.Name, group.UUID);
+ m_log.DebugFormat("calling AddNewSceneObjectByDecoding for SOG {0}, {1}", group.Name, group.UUID);
//Add the list of PrimSyncInfo to PrimSyncInfoManager's record.
m_primSyncInfoManager.InsertMultiPrimSyncInfo(primsSyncInfo);
@@ -3529,7 +3586,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
OSDMap rootData = (OSDMap)data["RootPart"];
//Decode and copy to the list of PrimSyncInfo
- PrimSyncInfo primSyncInfo = m_primSyncInfoManager.DecodeFullSetPrimProperties(rootData);
+ PrimSyncInfo primSyncInfo = null;
+ try
+ {
+ primSyncInfo = m_primSyncInfoManager.DecodeFullSetPrimProperties(rootData);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("SceneObjectDecoder: {0}", e.Message);
+ return;
+ }
SceneObjectPart root= primSyncInfo.PrimSyncInfoToSOP();
if (root != null)
@@ -3792,8 +3858,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
switch (m_property)
{
case SceneObjectPartSyncProperties.Shape:
+ string shapeString = PropertySerializer.SerializeShape((PrimitiveBaseShape)pSyncInfo.LastUpdateValue);
+ m_lastUpdateValueHash = PropertySerializer.GetPropertyHashValue(shapeString);
+ break;
case SceneObjectPartSyncProperties.TaskInventory:
- m_lastUpdateValueHash = GetPropertyHashValue((string)pSyncInfo.LastUpdateValue);
+ m_lastUpdateValueHash = PropertySerializer.GetPropertyHashValue((string)pSyncInfo.LastUpdateValue);
break;
}
}
@@ -3809,8 +3878,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
switch (property)
{
case SceneObjectPartSyncProperties.Shape:
+ string shapeString = PropertySerializer.SerializeShape((PrimitiveBaseShape)initValue);
+ m_lastUpdateValueHash = PropertySerializer.GetPropertyHashValue(shapeString);
+ break;
case SceneObjectPartSyncProperties.TaskInventory:
- m_lastUpdateValueHash = GetPropertyHashValue((string)initValue);
+ m_lastUpdateValueHash = PropertySerializer.GetPropertyHashValue((string)initValue);
break;
}
}
@@ -3914,13 +3986,17 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
switch (m_property)
{
case SceneObjectPartSyncProperties.Shape:
+ string shapeString = PropertySerializer.SerializeShape((PrimitiveBaseShape)m_lastUpdateValue);
+ m_lastUpdateValueHash = PropertySerializer.GetPropertyHashValue(shapeString);
+ break;
case SceneObjectPartSyncProperties.TaskInventory:
- m_lastUpdateValueHash = GetPropertyHashValue((string)m_lastUpdateValue);
+ m_lastUpdateValueHash = PropertySerializer.GetPropertyHashValue((string)m_lastUpdateValue);
break;
}
}
}
+
public bool IsHashValueEqual(string hashValue)
{
return m_lastUpdateValueHash.Equals(hashValue);
@@ -3939,201 +4015,207 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
public OSDMap ToOSDMap()
{
OSDMap propertyData = new OSDMap();
- propertyData["LastUpdateTimeStamp"] = LastUpdateTimeStamp;
- propertyData["LastUpdateSyncID"] = LastUpdateSyncID;
-
- switch (m_property)
+ lock (m_syncInfoLock)
{
- ///////////////////////////////////////
- //SOP properties with complex structure
- ///////////////////////////////////////
- case SceneObjectPartSyncProperties.Shape:
- case SceneObjectPartSyncProperties.TaskInventory:
- propertyData["Value"] = OSD.FromString((string)LastUpdateValue);
- break;
+ propertyData["LastUpdateTimeStamp"] = LastUpdateTimeStamp;
+ propertyData["LastUpdateSyncID"] = LastUpdateSyncID;
- ////////////////////////////
- //SOP properties, enum types
- ////////////////////////////
- case SceneObjectPartSyncProperties.AggregateScriptEvents:
- propertyData["Value"] = OSD.FromInteger((int)((scriptEvents)LastUpdateValue));
- break;
- case SceneObjectPartSyncProperties.Flags:
- case SceneObjectPartSyncProperties.LocalFlags:
- propertyData["Value"] = OSD.FromInteger((int)((PrimFlags)LastUpdateValue));
- break;
- ////////////////////////////
- //SOP properties, bool types
- ////////////////////////////
- case SceneObjectPartSyncProperties.AllowedDrop:
- case SceneObjectPartSyncProperties.IsAttachment:
- case SceneObjectPartSyncProperties.PassTouches:
- case SceneObjectPartSyncProperties.VolumeDetectActive:
- propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue);
- break;
+ switch (m_property)
+ {
+ ///////////////////////////////////////
+ //SOP properties with complex structure
+ ///////////////////////////////////////
+ case SceneObjectPartSyncProperties.Shape:
+ string shapeString = PropertySerializer.SerializeShape((PrimitiveBaseShape)LastUpdateValue);
+ propertyData["Value"] = OSD.FromString(shapeString);
+ break;
+ case SceneObjectPartSyncProperties.TaskInventory:
+ propertyData["Value"] = OSD.FromString((string)LastUpdateValue);
+ break;
- ////////////////////////////
- //SOP properties, Vector3 types
- ////////////////////////////
- case SceneObjectPartSyncProperties.AngularVelocity:
- case SceneObjectPartSyncProperties.AttachedPos:
- case SceneObjectPartSyncProperties.GroupPosition:
- case SceneObjectPartSyncProperties.OffsetPosition:
- case SceneObjectPartSyncProperties.Scale:
- case SceneObjectPartSyncProperties.SitTargetPosition:
- case SceneObjectPartSyncProperties.SitTargetPositionLL:
- case SceneObjectPartSyncProperties.SOP_Acceleration:
- case SceneObjectPartSyncProperties.Velocity:
- propertyData["Value"] = OSD.FromVector3((Vector3)LastUpdateValue);
- break;
+ ////////////////////////////
+ //SOP properties, enum types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.AggregateScriptEvents:
+ propertyData["Value"] = OSD.FromInteger((int)((scriptEvents)LastUpdateValue));
+ break;
+ case SceneObjectPartSyncProperties.Flags:
+ case SceneObjectPartSyncProperties.LocalFlags:
+ propertyData["Value"] = OSD.FromInteger((int)((PrimFlags)LastUpdateValue));
+ break;
+ ////////////////////////////
+ //SOP properties, bool types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.AllowedDrop:
+ case SceneObjectPartSyncProperties.IsAttachment:
+ case SceneObjectPartSyncProperties.PassTouches:
+ case SceneObjectPartSyncProperties.VolumeDetectActive:
+ propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue);
+ break;
- ////////////////////////////
- //SOP properties, UUID types
- ////////////////////////////
- case SceneObjectPartSyncProperties.AttachedAvatar:
- case SceneObjectPartSyncProperties.CollisionSound:
- case SceneObjectPartSyncProperties.CreatorID:
- case SceneObjectPartSyncProperties.FolderID:
- case SceneObjectPartSyncProperties.GroupID:
- case SceneObjectPartSyncProperties.LastOwnerID:
- case SceneObjectPartSyncProperties.OwnerID:
- case SceneObjectPartSyncProperties.Sound:
- propertyData["Value"] = OSD.FromUUID((UUID)LastUpdateValue);
- break;
+ ////////////////////////////
+ //SOP properties, Vector3 types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.AngularVelocity:
+ case SceneObjectPartSyncProperties.AttachedPos:
+ case SceneObjectPartSyncProperties.GroupPosition:
+ case SceneObjectPartSyncProperties.OffsetPosition:
+ case SceneObjectPartSyncProperties.Scale:
+ case SceneObjectPartSyncProperties.SitTargetPosition:
+ case SceneObjectPartSyncProperties.SitTargetPositionLL:
+ case SceneObjectPartSyncProperties.SOP_Acceleration:
+ case SceneObjectPartSyncProperties.Velocity:
+ propertyData["Value"] = OSD.FromVector3((Vector3)LastUpdateValue);
+ break;
- //case SceneObjectPartProperties.AttachedPos:
- ////////////////////////////
- //SOP properties, uint types
- ////////////////////////////
- case SceneObjectPartSyncProperties.AttachmentPoint:
- case SceneObjectPartSyncProperties.BaseMask:
- case SceneObjectPartSyncProperties.Category:
- case SceneObjectPartSyncProperties.EveryoneMask:
- case SceneObjectPartSyncProperties.GroupMask:
- case SceneObjectPartSyncProperties.InventorySerial:
- case SceneObjectPartSyncProperties.NextOwnerMask:
- case SceneObjectPartSyncProperties.OwnerMask:
- propertyData["Value"] = OSD.FromUInteger((uint)LastUpdateValue);
- break;
+ ////////////////////////////
+ //SOP properties, UUID types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.AttachedAvatar:
+ case SceneObjectPartSyncProperties.CollisionSound:
+ case SceneObjectPartSyncProperties.CreatorID:
+ case SceneObjectPartSyncProperties.FolderID:
+ case SceneObjectPartSyncProperties.GroupID:
+ case SceneObjectPartSyncProperties.LastOwnerID:
+ case SceneObjectPartSyncProperties.OwnerID:
+ case SceneObjectPartSyncProperties.Sound:
+ propertyData["Value"] = OSD.FromUUID((UUID)LastUpdateValue);
+ break;
- //case SceneObjectPartProperties.BaseMask:
- //case SceneObjectPartProperties.Category:
+ //case SceneObjectPartProperties.AttachedPos:
+ ////////////////////////////
+ //SOP properties, uint types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.AttachmentPoint:
+ case SceneObjectPartSyncProperties.BaseMask:
+ case SceneObjectPartSyncProperties.Category:
+ case SceneObjectPartSyncProperties.EveryoneMask:
+ case SceneObjectPartSyncProperties.GroupMask:
+ case SceneObjectPartSyncProperties.InventorySerial:
+ case SceneObjectPartSyncProperties.NextOwnerMask:
+ case SceneObjectPartSyncProperties.OwnerMask:
+ propertyData["Value"] = OSD.FromUInteger((uint)LastUpdateValue);
+ break;
- ////////////////////////////
- //SOP properties, byte types
- ////////////////////////////
- case SceneObjectPartSyncProperties.ClickAction:
- case SceneObjectPartSyncProperties.Material:
- case SceneObjectPartSyncProperties.ObjectSaleType:
- case SceneObjectPartSyncProperties.UpdateFlag:
- propertyData["Value"] = OSD.FromInteger((byte)LastUpdateValue);
- break;
- //case SceneObjectPartProperties.CollisionSound:
+ //case SceneObjectPartProperties.BaseMask:
+ //case SceneObjectPartProperties.Category:
- ////////////////////////////
- //SOP properties, float types
- ////////////////////////////
- case SceneObjectPartSyncProperties.CollisionSoundVolume:
- propertyData["Value"] = OSD.FromReal((float)LastUpdateValue);
- break;
+ ////////////////////////////
+ //SOP properties, byte types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.ClickAction:
+ case SceneObjectPartSyncProperties.Material:
+ case SceneObjectPartSyncProperties.ObjectSaleType:
+ case SceneObjectPartSyncProperties.UpdateFlag:
+ propertyData["Value"] = OSD.FromInteger((byte)LastUpdateValue);
+ break;
+ //case SceneObjectPartProperties.CollisionSound:
- ////////////////////////////
- //SOP properties, Color(struct type)
- ////////////////////////////
- case SceneObjectPartSyncProperties.Color:
- propertyData["Value"] = OSD.FromString(PropertySerializer.SerializeColor((System.Drawing.Color)LastUpdateValue));
- break;
+ ////////////////////////////
+ //SOP properties, float types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.CollisionSoundVolume:
+ propertyData["Value"] = OSD.FromReal((float)LastUpdateValue);
+ break;
- ////////////////////////////
- //SOP properties, int types
- ////////////////////////////
- case SceneObjectPartSyncProperties.CreationDate:
- case SceneObjectPartSyncProperties.LinkNum:
- case SceneObjectPartSyncProperties.OwnershipCost:
- case SceneObjectPartSyncProperties.SalePrice:
- case SceneObjectPartSyncProperties.ScriptAccessPin:
- propertyData["Value"] = OSD.FromInteger((int)LastUpdateValue);
- break;
+ ////////////////////////////
+ //SOP properties, Color(struct type)
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.Color:
+ propertyData["Value"] = OSD.FromString(PropertySerializer.SerializeColor((System.Drawing.Color)LastUpdateValue));
+ break;
- ////////////////////////////
- //SOP properties, string types
- ////////////////////////////
- case SceneObjectPartSyncProperties.CreatorData:
- case SceneObjectPartSyncProperties.Description:
- case SceneObjectPartSyncProperties.MediaUrl:
- case SceneObjectPartSyncProperties.Name:
- case SceneObjectPartSyncProperties.SitName:
- case SceneObjectPartSyncProperties.Text:
- case SceneObjectPartSyncProperties.TouchName:
- propertyData["Value"] = OSD.FromString((string)LastUpdateValue);
- break;
- ////////////////////////////
- //SOP properties, byte[] types
- ////////////////////////////
- case SceneObjectPartSyncProperties.ParticleSystem:
- case SceneObjectPartSyncProperties.TextureAnimation:
- propertyData["Value"] = OSD.FromBinary((byte[])LastUpdateValue);
- break;
+ ////////////////////////////
+ //SOP properties, int types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.CreationDate:
+ case SceneObjectPartSyncProperties.LinkNum:
+ case SceneObjectPartSyncProperties.OwnershipCost:
+ case SceneObjectPartSyncProperties.SalePrice:
+ case SceneObjectPartSyncProperties.ScriptAccessPin:
+ propertyData["Value"] = OSD.FromInteger((int)LastUpdateValue);
+ break;
- ////////////////////////////
- //SOP properties, Quaternion types
- ////////////////////////////
- case SceneObjectPartSyncProperties.RotationOffset:
- case SceneObjectPartSyncProperties.SitTargetOrientation:
- case SceneObjectPartSyncProperties.SitTargetOrientationLL:
- propertyData["Value"] = OSD.FromQuaternion((Quaternion)LastUpdateValue);
- break;
+ ////////////////////////////
+ //SOP properties, string types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.CreatorData:
+ case SceneObjectPartSyncProperties.Description:
+ case SceneObjectPartSyncProperties.MediaUrl:
+ case SceneObjectPartSyncProperties.Name:
+ case SceneObjectPartSyncProperties.SitName:
+ case SceneObjectPartSyncProperties.Text:
+ case SceneObjectPartSyncProperties.TouchName:
+ propertyData["Value"] = OSD.FromString((string)LastUpdateValue);
+ break;
+ ////////////////////////////
+ //SOP properties, byte[] types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.ParticleSystem:
+ case SceneObjectPartSyncProperties.TextureAnimation:
+ propertyData["Value"] = OSD.FromBinary((byte[])LastUpdateValue);
+ break;
- ////////////////////////////////////
- //PhysActor properties, float type
- ////////////////////////////////////
- case SceneObjectPartSyncProperties.Buoyancy:
- propertyData["Value"] = OSD.FromReal((float)LastUpdateValue);
- break;
+ ////////////////////////////
+ //SOP properties, Quaternion types
+ ////////////////////////////
+ case SceneObjectPartSyncProperties.RotationOffset:
+ case SceneObjectPartSyncProperties.SitTargetOrientation:
+ case SceneObjectPartSyncProperties.SitTargetOrientationLL:
+ propertyData["Value"] = OSD.FromQuaternion((Quaternion)LastUpdateValue);
+ break;
- ////////////////////////////////////
- //PhysActor properties, bool type
- ////////////////////////////////////
- case SceneObjectPartSyncProperties.Flying:
- case SceneObjectPartSyncProperties.IsColliding:
- case SceneObjectPartSyncProperties.CollidingGround:
- case SceneObjectPartSyncProperties.IsPhysical:
- case SceneObjectPartSyncProperties.Kinematic:
- propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue);
- break;
+ ////////////////////////////////////
+ //PhysActor properties, float type
+ ////////////////////////////////////
+ case SceneObjectPartSyncProperties.Buoyancy:
+ propertyData["Value"] = OSD.FromReal((float)LastUpdateValue);
+ break;
- ////////////////////////////////////
- //PhysActor properties, Vector3 type
- ////////////////////////////////////
- case SceneObjectPartSyncProperties.Force:
- case SceneObjectPartSyncProperties.PA_Acceleration:
- case SceneObjectPartSyncProperties.Position:
- case SceneObjectPartSyncProperties.RotationalVelocity:
- case SceneObjectPartSyncProperties.Size:
- case SceneObjectPartSyncProperties.Torque:
- propertyData["Value"] = OSD.FromVector3((Vector3)LastUpdateValue);
- break;
+ ////////////////////////////////////
+ //PhysActor properties, bool type
+ ////////////////////////////////////
+ case SceneObjectPartSyncProperties.Flying:
+ case SceneObjectPartSyncProperties.IsColliding:
+ case SceneObjectPartSyncProperties.CollidingGround:
+ case SceneObjectPartSyncProperties.IsPhysical:
+ case SceneObjectPartSyncProperties.Kinematic:
+ propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue);
+ break;
- ////////////////////////////////////
- //PhysActor properties, Quaternion type
- ////////////////////////////////////
- case SceneObjectPartSyncProperties.Orientation:
- propertyData["Value"] = OSD.FromQuaternion((Quaternion)LastUpdateValue);
- break;
+ ////////////////////////////////////
+ //PhysActor properties, Vector3 type
+ ////////////////////////////////////
+ case SceneObjectPartSyncProperties.Force:
+ case SceneObjectPartSyncProperties.PA_Acceleration:
+ case SceneObjectPartSyncProperties.Position:
+ case SceneObjectPartSyncProperties.RotationalVelocity:
+ case SceneObjectPartSyncProperties.Size:
+ case SceneObjectPartSyncProperties.Torque:
+ propertyData["Value"] = OSD.FromVector3((Vector3)LastUpdateValue);
+ break;
- ///////////////////////
- //SOG properties
- ///////////////////////
- case SceneObjectPartSyncProperties.AbsolutePosition:
- propertyData["Value"] = OSD.FromVector3((Vector3)LastUpdateValue);
- break;
- case SceneObjectPartSyncProperties.IsSelected:
- propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue);
- break;
+ ////////////////////////////////////
+ //PhysActor properties, Quaternion type
+ ////////////////////////////////////
+ case SceneObjectPartSyncProperties.Orientation:
+ propertyData["Value"] = OSD.FromQuaternion((Quaternion)LastUpdateValue);
+ break;
- default:
- DebugLog.WarnFormat("PrimSynInfo.PropertyToOSD -- no handler for property {0} ", m_property);
- break;
+ ///////////////////////
+ //SOG properties
+ ///////////////////////
+ case SceneObjectPartSyncProperties.AbsolutePosition:
+ propertyData["Value"] = OSD.FromVector3((Vector3)LastUpdateValue);
+ break;
+ case SceneObjectPartSyncProperties.IsSelected:
+ propertyData["Value"] = OSD.FromBoolean((bool)LastUpdateValue);
+ break;
+
+ default:
+ DebugLog.WarnFormat("PrimSynInfo.PropertyToOSD -- no handler for property {0} ", m_property);
+ break;
+ }
}
return propertyData;
}
@@ -4174,9 +4256,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//SOP properties with complex structure
///////////////////////////////////////
case SceneObjectPartSyncProperties.Shape:
+ string shapeString = propertyData["Value"].AsString();
+ PrimitiveBaseShape shape = PropertySerializer.DeSerializeShape(shapeString);
+ m_lastUpdateValue = (Object)shape;
+ m_lastUpdateValueHash = PropertySerializer.GetPropertyHashValue(shapeString);
+ break;
case SceneObjectPartSyncProperties.TaskInventory:
m_lastUpdateValue = (Object)propertyData["Value"].AsString();
- m_lastUpdateValueHash = Util.Md5Hash((string)m_lastUpdateValue);
+ m_lastUpdateValueHash = PropertySerializer.GetPropertyHashValue((string)m_lastUpdateValue);
break;
////////////////////////////
@@ -4389,17 +4476,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
}
- private string GetPropertyHashValue(string initValue)
- {
- return Util.Md5Hash(initValue);
- }
-
}
public class PropertySerializer
{
//TO BE TESTED
-
+ public static string GetPropertyHashValue(string initValue)
+ {
+ return Util.Md5Hash(initValue);
+ }
public static string SerializeShape(SceneObjectPart part)
{
@@ -4415,6 +4500,20 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return serializedShape;
}
+ public static string SerializeShape(PrimitiveBaseShape shape)
+ {
+ string serializedShape;
+ using (StringWriter sw = new StringWriter())
+ {
+ using (XmlTextWriter writer = new XmlTextWriter(sw))
+ {
+ SceneObjectSerializer.WriteShape(writer, shape, new Dictionary());
+ }
+ serializedShape = sw.ToString();
+ }
+ return serializedShape;
+ }
+
public static PrimitiveBaseShape DeSerializeShape(string shapeString)
{
if (shapeString == null || shapeString == String.Empty || shapeString == "")
@@ -4951,7 +5050,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
case SceneObjectPartSyncProperties.Shape:
string primShapeString = PropertySerializer.SerializeShape(part);
- string primShapeStringHash = Util.Md5Hash(primShapeString);
+ string primShapeStringHash = PropertySerializer.GetPropertyHashValue(primShapeString);
if (!m_propertiesSyncInfo[property].IsHashValueEqual(primShapeStringHash))
{
@@ -4960,7 +5059,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//value by copying that from PrimSyncInfoManager
if (lastUpdateTS > m_propertiesSyncInfo[property].LastUpdateTimeStamp)
{
- UpdatePropertyWithHashByLocal(property, lastUpdateTS, syncID, (Object)primShapeString, primShapeStringHash);
+ //UpdatePropertyWithHashByLocal(property, lastUpdateTS, syncID, (Object)primShapeString, primShapeStringHash);
+ UpdatePropertyWithHashByLocal(property, lastUpdateTS, syncID, part.Shape, primShapeStringHash);
//DSG DEBUG
//DebugLog.DebugFormat("CompareHashedValue_UpdateByLocal - Shape of {0}, {1} updated to ProfileShape {2}: SOP hashed shape: {3}, cached hash {4}",
@@ -6125,7 +6225,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
switch (property)
{
case SceneObjectPartSyncProperties.Shape:
- return (Object)PropertySerializer.SerializeShape(part);
+ //return (Object)PropertySerializer.SerializeShape(part);
+ return (Object)part.Shape;
case SceneObjectPartSyncProperties.TaskInventory:
return (Object)PropertySerializer.SerializeTaskInventory(part);
@@ -6346,7 +6447,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
switch (property)
{
case SceneObjectPartSyncProperties.Shape:
- PrimitiveBaseShape shapeVal = PropertySerializer.DeSerializeShape((string)pSyncInfo.LastUpdateValue);
+ //PrimitiveBaseShape shapeVal = PropertySerializer.DeSerializeShape((string)pSyncInfo.LastUpdateValue);
+ PrimitiveBaseShape shapeVal = (PrimitiveBaseShape)pSyncInfo.LastUpdateValue;
if (shapeVal != null)
{
part.Shape = shapeVal;
@@ -6676,6 +6778,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
part.ParentGroup.AbsolutePosition = (Vector3)pSyncInfo.LastUpdateValue;
PropertySyncInfo gPosSyncInfo;
+
+ if (part.IsAttachment)
+ return;
+
if (m_propertiesSyncInfo.ContainsKey(SceneObjectPartSyncProperties.GroupPosition))
{
gPosSyncInfo = m_propertiesSyncInfo[SceneObjectPartSyncProperties.GroupPosition];
@@ -7073,18 +7179,23 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
lock (m_primsInSyncLock)
{
+
if (m_primsInSync.ContainsKey(primUUID))
{
m_primsInSync[primUUID] = primSyncInfo;
return false;
}
+ /*
//copy the items from the old list and insert the new record
Dictionary newPrimsInSync = new Dictionary(m_primsInSync);
newPrimsInSync.Add(primUUID, primSyncInfo);
//replace the old list
m_primsInSync = newPrimsInSync;
+ * */
+
+ m_primsInSync.Add(primUUID, primSyncInfo);
}
return true;
}
@@ -7109,10 +7220,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_primsInSync[part.UUID] = primSyncInfo;
return false;
}
+ /*
Dictionary newPrimsInSync = new Dictionary(m_primsInSync);
newPrimsInSync.Add(part.UUID, primSyncInfo);
m_primsInSync = newPrimsInSync;
+ * */
+ m_primsInSync.Add(part.UUID, primSyncInfo);
}
return true;
}
@@ -7122,6 +7236,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
lock (m_primsInSyncLock)
{
//copy the old list, update the copied list
+ /*
Dictionary newPrimsInSync = new Dictionary(m_primsInSync);
foreach (KeyValuePair valPair in multiPrimsSyncInfo)
{
@@ -7137,6 +7252,19 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//replace the old list
m_primsInSync = newPrimsInSync;
+ * */
+
+ foreach (KeyValuePair valPair in multiPrimsSyncInfo)
+ {
+ UUID primUUID = valPair.Key;
+ PrimSyncInfo primSyncInfo = valPair.Value;
+ if (m_primsInSync.ContainsKey(primUUID))
+ {
+ m_primsInSync[primUUID] = primSyncInfo;
+ continue;
+ }
+ m_primsInSync.Add(primUUID, primSyncInfo);
+ }
}
}
@@ -7148,22 +7276,27 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
lock (m_primsInSyncLock)
{
+ /*
Dictionary newPrimsInSync = new Dictionary(m_primsInSync);
newPrimsInSync.Remove(part.UUID);
m_primsInSync = newPrimsInSync;
+ * */
+ m_primsInSync.Remove(part.UUID);
}
return true;
}
public PrimSyncInfo GetPrimSyncInfo(UUID primUUID)
{
- if (m_primsInSync.ContainsKey(primUUID))
+ lock (m_primsInSyncLock)
{
- return m_primsInSync[primUUID];
+ if (m_primsInSync.ContainsKey(primUUID))
+ {
+ return m_primsInSync[primUUID];
+ }
}
- else
- return null;
+ return null;
}
public bool SetSOPPhyscActorProperties(SceneObjectPart part)
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs
index 9ef2dcbfaf..7142604ef0 100755
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScenePersistenceSyncModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -109,7 +113,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//Register for Scene/SceneGraph events
m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScenePersistence_OnObjectCreate);
- m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScenePersistence_OnObjectCreateBySync);
+ //m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScenePersistence_OnObjectCreateBySync);
}
//Called after AddRegion() has been called for all region modules of the scene.
@@ -120,7 +124,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
if (!m_active)
return;
m_log.Warn(LogHeader + " RegionLoaded() called");
-
}
public void RemoveRegion(Scene scene)
@@ -220,4 +223,4 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs
index b21c328adb..3bcfed1e71 100755
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -105,6 +109,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//Register for Scene/SceneGraph events
//m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScriptEngine_OnObjectCreate);
+
+ //Don't subscribe to OnObjectCreate, only subscribe OnObjectCreateBySync.
m_scene.SceneGraph.OnObjectCreateBySync += new ObjectCreateBySyncDelegate(ScriptEngine_OnObjectCreateBySync);
m_scene.EventManager.OnSymmetricSyncStop += ScriptEngine_OnSymmetricSyncStop;
@@ -254,4 +260,4 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs
index b038ef7cd6..a9ff493643 100755
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -191,4 +195,4 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs
index ff89273b94..aaf1f17a22 100755
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -376,4 +380,4 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
return "msgsIn,msgsOut,bytesIn,bytesOut,queueSize,Mbps In,Mbps Out";
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncStatisticCollector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncStatisticCollector.cs
index 18fba4906c..cb098835e3 100755
--- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncStatisticCollector.cs
+++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncStatisticCollector.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
@@ -20,6 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
using System;
using System.Collections.Generic;
using System.IO;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index ee90859744..e224670756 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -112,6 +112,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
Object[] args = new Object[] { source };
m_MapService = ServerUtils.LoadPlugin(service, args);
+ if (m_MapService == null)
+ {
+ m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Unable to load LocalServiceModule from {0}. MapService module disabled. Please fix the configuration.", service);
+ return;
+ }
m_refreshTimer.Enabled = true;
m_refreshTimer.AutoReset = true;
@@ -202,7 +207,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
{
m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: upload maptile for {0}", scene.RegionInfo.RegionName);
- // Create a PNG map tile and upload it to the AddMapTile API
+ // Create a JPG map tile and upload it to the AddMapTile API
byte[] jpgData = Utils.EmptyBytes;
IMapImageGenerator tileGenerator = scene.RequestModuleInterface();
if (tileGenerator == null)
@@ -220,13 +225,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
}
}
+ if (jpgData == Utils.EmptyBytes)
+ {
+ m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: Tile image generation failed");
+ return;
+ }
+
string reason = string.Empty;
if (!m_MapService.AddMapTile((int)scene.RegionInfo.RegionLocX, (int)scene.RegionInfo.RegionLocY, jpgData, out reason))
{
m_log.DebugFormat("[MAP IMAGE SERVICE MODULE]: Unable to upload tile image for {0} at {1}-{2}: {3}",
scene.RegionInfo.RegionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, reason);
}
-
}
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Framework/Interfaces/IGridDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IGridDialogModule.cs
index 102dea44a4..d2d49fc04f 100755
--- a/OpenSim/Region/Framework/Interfaces/IGridDialogModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IGridDialogModule.cs
@@ -1,12 +1,16 @@
-/* Copyright 2011 (c) Intel Corporation
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The name of the copyright holder may not be used to endorse or promote products
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f5c145b2b5..f12527baec 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -702,16 +702,20 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectGroup sog = (SceneObjectGroup)e;
if (!sog.IsAttachment)
- DeleteSceneObjectBySynchronization((SceneObjectGroup)e);
+ DeleteSceneObjectBySync((SceneObjectGroup)e);
}
}
}
}
//Similar to DeleteSceneObject, except that this does not trigger SyncDeleteObject
- public void DeleteSceneObjectBySynchronization(SceneObjectGroup group)
+ public void DeleteSceneObjectBySync(SceneObjectGroup group)
{
+ bool silent = false;
+ bool syncDelete = false;
+ DeleteSceneObject(group, silent, syncDelete);
+ /*
// Serialise calls to RemoveScriptInstances to avoid
// deadlocking on m_parts inside SceneObjectGroup
lock (m_deleting_scene_object)
@@ -743,6 +747,7 @@ namespace OpenSim.Region.Framework.Scenes
bool silent = false; //do not suppress broadcasting changes to other clients, for debugging with viewers
group.DeleteGroupFromScene(silent);
+ * */
}
public void AddNewSceneObjectPartBySync(SceneObjectPart newPart, SceneObjectGroup parentGroup)
@@ -753,6 +758,7 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.AddNewSceneObjectPart(newPart, parentGroup);
}
+
public ObjectUpdateResult AddNewSceneObjectBySync(SceneObjectGroup sceneObject)
{
//if(attachToBackup)
@@ -790,7 +796,10 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- return m_sceneGraph.AddNewSceneObjectBySync(sceneObject);
+ if (m_sceneGraph.AddNewSceneObjectBySync(sceneObject))
+ return Scene.ObjectUpdateResult.New;
+ else
+ return Scene.ObjectUpdateResult.Error;
}
//return m_sceneGraph.AddNewSceneObjectBySync(group);
@@ -2668,12 +2677,25 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ ///
+ /// Synchronously delete the given object from the scene. This should be called by
+ /// deletion that is initiated locally.
+ ///
+ ///
+ ///
+ public void DeleteSceneObject(SceneObjectGroup group, bool silent)
+ {
+ DeleteSceneObject(group, silent, true);
+ }
+
///
/// Synchronously delete the given object from the scene.
///
/// Object Id
/// Suppress broadcasting changes to other clients.
- public void DeleteSceneObject(SceneObjectGroup group, bool silent)
+ /// "false" if this function is called by
+ /// receiving SymmetricSyncMessage.MsgType.RemovedObject, "true" otherwise.
+ public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool syncDelete)
{
// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID);
@@ -2715,7 +2737,7 @@ namespace OpenSim.Region.Framework.Scenes
//DSG SYNC
//Propagate the RemovedObject message
- if (RegionSyncModule != null)
+ if (RegionSyncModule != null && syncDelete)
{
//RegionSyncModule.SendDeleteObject(group, false);
RegionSyncModule.SyncDeleteObject(group, false);
@@ -3177,7 +3199,6 @@ namespace OpenSim.Region.Framework.Scenes
//public void AddNewClient2(IClientAPI client, bool managed)
public void AddNewClient2(IClientAPI client, bool isSyncedAvatar, bool rezAttachment)
{
-
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
bool vialogin = false;
@@ -3190,17 +3211,15 @@ namespace OpenSim.Region.Framework.Scenes
vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 ||
(aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
}
-
CheckHeartbeat();
-
- if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
+ ScenePresence sp = GetScenePresence(client.AgentId);
+ if ( sp == null) // ensure there is no SP here
{
m_log.DebugFormat("[SCENE ({0})]: Restoring agent {1} ({2})", m_regionName, client.Name, client.AgentId);
m_clientManager.Add(client);
SubscribeToClientEvents(client);
-
- ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit == null ? null : aCircuit.Appearance);
+ sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit == null ? null : aCircuit.Appearance);
sp.IsSyncedAvatar = isSyncedAvatar;
m_eventManager.TriggerOnNewPresence(sp);
@@ -3219,14 +3238,17 @@ namespace OpenSim.Region.Framework.Scenes
Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
}
}
-
- if (GetScenePresence(client.AgentId) != null)
+ sp = GetScenePresence(client.AgentId);
+ if (sp!= null)
{
m_LastLogin = Util.EnvironmentTickCount();
// Cache the user's name
- CacheUserName(aCircuit);
+ if (aCircuit == null)
+ CacheUserName(sp.Firstname, sp.Lastname, sp.UUID, string.Empty);
+ else
+ CacheUserName(aCircuit);
EventManager.TriggerOnNewClient(client);
if (vialogin)
EventManager.TriggerOnClientLogin(client);
@@ -3234,24 +3256,31 @@ namespace OpenSim.Region.Framework.Scenes
}
private void CacheUserName(AgentCircuitData aCircuit)
+ {
+ string homeURL = string.Empty;
+ string first = aCircuit.firstname, last = aCircuit.lastname;
+ UUID agentID = aCircuit.AgentID;
+
+ if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
+ homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
+ CacheUserName(first, last, agentID, homeURL);
+ }
+
+ private void CacheUserName(string first, string last, UUID agentID, string homeURL)
{
IUserManagement uMan = RequestModuleInterface();
if (uMan != null)
{
- string homeURL = string.Empty;
- string first = aCircuit.firstname, last = aCircuit.lastname;
- if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
- homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
- if (aCircuit.lastname.StartsWith("@"))
+ if (last.StartsWith("@"))
{
- string[] parts = aCircuit.firstname.Split('.');
+ string[] parts = first.Split('.');
if (parts.Length >= 2)
{
first = parts[0];
last = parts[1];
}
}
- uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
+ uMan.AddUser(agentID, first, last, homeURL);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 2cd4198123..86a65692c5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -2096,6 +2096,7 @@ namespace OpenSim.Region.Framework.Scenes
*/
//This is called when an object is added due to receiving a state synchronization message from Scene or an actor. Do similar things as the original AddSceneObject(),
//but call ScheduleGroupForFullUpdate_TimeStampUnchanged() instead, so as not to modify the timestamp or actorID, since the object was not created locally.
+ /*
public Scene.ObjectUpdateResult AddNewSceneObjectBySync(SceneObjectGroup sceneObject)
{
Scene.ObjectUpdateResult updateResult = Scene.ObjectUpdateResult.New;
@@ -2166,12 +2167,14 @@ namespace OpenSim.Region.Framework.Scenes
if (OnObjectCreateBySync != null)
OnObjectCreateBySync(sceneObject);
-
lock (SceneObjectGroupsByFullID)
- {
SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
+
+ lock (SceneObjectGroupsByFullPartID)
+ {
+ SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject;
foreach (SceneObjectPart part in children)
- SceneObjectGroupsByFullID[part.UUID] = sceneObject;
+ SceneObjectGroupsByFullPartID[part.UUID] = sceneObject;
}
lock (SceneObjectGroupsByLocalPartID)
@@ -2183,6 +2186,7 @@ namespace OpenSim.Region.Framework.Scenes
return updateResult;
}
+ * */
public void AddNewSceneObjectPart(SceneObjectPart newPart, SceneObjectGroup parentGroup)
{
@@ -2532,6 +2536,38 @@ namespace OpenSim.Region.Framework.Scenes
return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates, triggerSyncNewObject);
}
+ protected internal bool AddNewSceneObjectBySync(SceneObjectGroup sceneObject)
+ {
+ sceneObject.HasGroupChanged = true;
+ bool triggerSyncNewObject = false;
+ if (AddSceneObject(sceneObject, true, true, triggerSyncNewObject))
+ {
+ //Take some special care of the case of this object being an attachment,
+ //since localID of attachedAvatar is different in different sync node's
+ //Scene copies.
+ sceneObject.RootPart.SetAttachmentPoint(sceneObject.RootPart.AttachmentPoint);
+ if (sceneObject.IsAttachment)
+ {
+ ScenePresence avatar = m_parentScene.GetScenePresence(sceneObject.RootPart.AttachedAvatar);
+ //It is possible that the avatar has not been fully
+ //created locally when attachment objects are sync'ed.
+ //So we need to check if the avatar already exists.
+ //If not, handling of NewAvatar will evetually trigger
+ //calling of SetParentLocalId.
+ if (avatar != null)
+ sceneObject.RootPart.SetParentLocalId(avatar.LocalId);
+ }
+
+ sceneObject.HasGroupChanged = true;
+ sceneObject.ScheduleGroupForFullUpdate(null);
+
+ if (OnObjectCreateBySync != null)
+ OnObjectCreateBySync(sceneObject);
+ return true;
+ }
+ return false;
+ }
+
#endregion //DSG SYNC
}
}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index d47a948ca9..4e866f0365 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -1390,6 +1390,7 @@ namespace OpenSim.Region.Physics.OdePlugin
_position.Z = m_taintPosition.Z;
}
}
+ ChangingActorID = RegionSyncServerModule.ActorID;
this.RequestPhysicsterseUpdate();
}
diff --git a/OpenSim/Region/Physics/PEPlugin/PECharacter.cs b/OpenSim/Region/Physics/PEPlugin/PECharacter.cs
index 6918272781..e24855fcee 100755
--- a/OpenSim/Region/Physics/PEPlugin/PECharacter.cs
+++ b/OpenSim/Region/Physics/PEPlugin/PECharacter.cs
@@ -1,14 +1,15 @@
/*
- * Copyright (c) Intel Corporation
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * Neither the name of the Intel Corporation nor the
+ * * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
@@ -23,6 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
using System;
using System.Collections.Generic;
using System.Reflection;
diff --git a/OpenSim/Region/Physics/PEPlugin/PEPlugin.cs b/OpenSim/Region/Physics/PEPlugin/PEPlugin.cs
index 97b9267d96..b9b24a5597 100755
--- a/OpenSim/Region/Physics/PEPlugin/PEPlugin.cs
+++ b/OpenSim/Region/Physics/PEPlugin/PEPlugin.cs
@@ -1,14 +1,15 @@
/*
- * Copyright (c) Intel Corporation
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * Neither the name of the Intel Corporation nor the
+ * * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
@@ -23,6 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
using System;
using System.Collections.Generic;
using OpenSim.Framework;
diff --git a/OpenSim/Region/Physics/PEPlugin/PEPrim.cs b/OpenSim/Region/Physics/PEPlugin/PEPrim.cs
index ee70275130..48e04ac623 100755
--- a/OpenSim/Region/Physics/PEPlugin/PEPrim.cs
+++ b/OpenSim/Region/Physics/PEPlugin/PEPrim.cs
@@ -1,14 +1,15 @@
/*
- * Copyright (c) Intel Corporation
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * Neither the name of the Intel Corporation nor the
+ * * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
@@ -23,6 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
using System;
using System.Reflection;
using System.Collections.Generic;
diff --git a/OpenSim/Region/Physics/PEPlugin/PEScene.cs b/OpenSim/Region/Physics/PEPlugin/PEScene.cs
index d600f9facc..e04e25b871 100755
--- a/OpenSim/Region/Physics/PEPlugin/PEScene.cs
+++ b/OpenSim/Region/Physics/PEPlugin/PEScene.cs
@@ -1,14 +1,15 @@
/*
- * Copyright (c) Intel Corporation
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * Neither the name of the Intel Corporation nor the
+ * * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
@@ -23,6 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
using System;
using System.Collections.Generic;
using Nini.Config;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index de33b35b4b..1f10c3eaa1 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -595,7 +595,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
if (part == null)
{
- m_log.Error("[Script] SceneObjectPart unavailable. Script NOT started.");
+ m_log.Error("[Script] SceneObjectPart unavailable. Script NOT started."+" localID = "+localID);
m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n";
m_ScriptFailCount++;
return false;
diff --git a/addon-modules/BulletSPlugin/BSCharacter.cs b/addon-modules/BulletSPlugin/BSCharacter.cs
deleted file mode 100644
index d66b1a6522..0000000000
--- a/addon-modules/BulletSPlugin/BSCharacter.cs
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright (c) 2011 Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Intel Corporation nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * 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
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using log4net;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Physics.Manager;
-using OpenSim.Region.CoreModules.RegionSync.RegionSyncModule;
-
-namespace OpenSim.Region.Physics.BulletSPlugin
-{
-public class BSCharacter : PhysicsActor
-{
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private static readonly string LogHeader = "[BULLETS CHAR]";
-
- private BSScene _scene;
- private String _avName;
- private bool _stopped;
- private Vector3 _size;
- private Vector3 _scale;
- private PrimitiveBaseShape _pbs;
- private uint _localID = 0;
- private bool _grabbed;
- private bool _selected;
- private Vector3 _position;
- private float _mass = 80f;
- public float _density = 60f;
- public float CAPSULE_RADIUS = 0.37f;
- public float CAPSULE_LENGTH = 2.140599f;
- private Vector3 _force;
- private Vector3 _velocity;
- private Vector3 _torque;
- private float _collisionScore;
- private Vector3 _acceleration;
- private Quaternion _orientation;
- private int _physicsActorType;
- private bool _isPhysical;
- private bool _flying;
- private bool _setAlwaysRun;
- private bool _throttleUpdates;
- private bool _isColliding;
- private long _collidingStep;
- private bool _collidingGround;
- private long _collidingGroundStep;
- private bool _collidingObj;
- private bool _floatOnWater;
- private Vector3 _rotationalVelocity;
- private bool _kinematic;
- private float _buoyancy;
-
- private int _subscribedEventsMs = 0;
-
- private Vector3 _PIDTarget;
- private bool _usePID;
- private float _PIDTau;
- private bool _useHoverPID;
- private float _PIDHoverHeight;
- private PIDHoverType _PIDHoverType;
- private float _PIDHoverTao;
-
- public BSCharacter(uint localID, String avName, BSScene parent_scene, Vector3 pos, Vector3 size, bool isFlying)
- {
- _localID = localID;
- _avName = avName;
- _scene = parent_scene;
- _position = pos;
- _size = size;
- _orientation = Quaternion.Identity;
- _velocity = Vector3.Zero;
- _buoyancy = 0f; // characters return a buoyancy of zero
- _scale = new Vector3(1f, 1f, 1f);
- float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH);
- _mass = _density*AVvolume;
-
- ShapeData shapeData = new ShapeData();
- shapeData.ID = _localID;
- shapeData.Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR;
- shapeData.Position = _position;
- shapeData.Rotation = _orientation;
- shapeData.Velocity = _velocity;
- shapeData.Scale = _scale;
- shapeData.Mass = _mass;
- shapeData.Buoyancy = isFlying ? 0f : 1f;
- shapeData.Static = ShapeData.numericFalse;
-
- BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
-
- return;
- }
-
- // called when this character is being destroyed and the resources should be released
- public void Destroy()
- {
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
- });
- }
-
- public override void RequestPhysicsterseUpdate()
- {
- if (PhysEngineToSceneConnectorModule.IsPhysEngineActorS)
- {
- // if the values have changed and it was I who changed them, send an update
- // if (this.lastValues.Changed(this) && ChangingActorID == RegionSyncServerModule.ActorID)
- if (ChangingActorID == RegionSyncServerModule.ActorID)
- {
- // m_log.DebugFormat("{0}: Sending terse update for {1}", LogHeader, LocalID);
- ChangingActorID = "XX"; // undo our mark on the changes so this won't get sent over and over
- PhysEngineToSceneConnectorModule.RouteUpdate(this);
- }
- }
- else
- {
- base.RequestPhysicsterseUpdate();
- }
- }
-
- public override bool Stopped {
- get { return _stopped; }
- }
- public override Vector3 Size {
- get { return _size; }
- set { _size = value;
- base.ChangingActorID = RegionSyncServerModule.ActorID;
- }
- }
- public override PrimitiveBaseShape Shape {
- set { _pbs = value;
- }
- }
- public override uint LocalID {
- set { _localID = value;
- }
- get { return _localID; }
- }
- public override bool Grabbed {
- set { _grabbed = value;
- }
- }
- public override bool Selected {
- set { _selected = value;
- }
- }
- public override void CrossingFailure() { return; }
- public override void link(PhysicsActor obj) { return; }
- public override void delink() { return; }
- public override void LockAngularMotion(Vector3 axis) { return; }
-
- public override Vector3 Position {
- get {
- // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
- return _position;
- }
- set {
- _position = value;
- base.ChangingActorID = RegionSyncServerModule.ActorID;
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
- });
- }
- }
- public override float Mass {
- get {
- return _mass;
- }
- }
- public override Vector3 Force {
- get { return _force; }
- set {
- _force = value;
- base.ChangingActorID = RegionSyncServerModule.ActorID;
- // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force);
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
- });
- }
- }
-
- public override int VehicleType {
- get { return 0; }
- set { return; }
- }
- public override void VehicleFloatParam(int param, float value) { }
- public override void VehicleVectorParam(int param, Vector3 value) {}
- public override void VehicleRotationParam(int param, Quaternion rotation) { }
- public override void VehicleFlags(int param, bool remove) { }
-
- // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
- public override void SetVolumeDetect(int param) { return; }
-
- public override Vector3 GeometricCenter { get { return Vector3.Zero; } }
- public override Vector3 CenterOfMass { get { return Vector3.Zero; } }
- public override Vector3 Velocity {
- get { return _velocity; }
- set {
- _velocity = value;
- base.ChangingActorID = RegionSyncServerModule.ActorID;
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity);
- });
- }
- }
- public override Vector3 Torque {
- get { return _torque; }
- set { _torque = value;
- }
- }
- public override float CollisionScore {
- get { return _collisionScore; }
- set { _collisionScore = value;
- }
- }
- public override Vector3 Acceleration {
- get { return _acceleration; }
- }
- public override Quaternion Orientation {
- get { return _orientation; }
- set {
- _orientation = value;
- _scene.TaintedObject(delegate()
- {
- // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
- BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
- });
- }
- }
- public override int PhysicsActorType {
- get { return _physicsActorType; }
- set { _physicsActorType = value;
- }
- }
- public override bool IsPhysical {
- get { return _isPhysical; }
- set { _isPhysical = value;
- }
- }
- public override bool Flying {
- get { return _flying; }
- set {
- _flying = value;
- _scene.TaintedObject(delegate()
- {
- // simulate flying by changing the effect of gravity
- BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 0f : 1f);
- });
- }
- }
- public override bool
- SetAlwaysRun {
- get { return _setAlwaysRun; }
- set { _setAlwaysRun = value; }
- }
- public override bool ThrottleUpdates {
- get { return _throttleUpdates; }
- set { _throttleUpdates = value; }
- }
- public override bool IsColliding {
- get { return (_collidingStep == _scene.SimulationStep); }
- set { _isColliding = value; }
- }
- public override bool CollidingGround {
- get { return (_collidingGroundStep == _scene.SimulationStep); }
- set { _collidingGround = value; }
- }
- public override bool CollidingObj {
- get { return _collidingObj; }
- set { _collidingObj = value; }
- }
- public override bool FloatOnWater {
- set { _floatOnWater = value; }
- }
- public override Vector3 RotationalVelocity {
- get { return _rotationalVelocity; }
- set { _rotationalVelocity = value; }
- }
- public override bool Kinematic {
- get { return _kinematic; }
- set { _kinematic = value; }
- }
- public override float Buoyancy {
- get { return _buoyancy; }
- set { _buoyancy = value; }
- }
-
- // Used for MoveTo
- public override Vector3 PIDTarget {
- set { _PIDTarget = value; }
- }
- public override bool PIDActive {
- set { _usePID = value; }
- }
- public override float PIDTau {
- set { _PIDTau = value; }
- }
-
- // Used for llSetHoverHeight and maybe vehicle height
- // Hover Height will override MoveTo target's Z
- public override bool PIDHoverActive {
- set { _useHoverPID = value; }
- }
- public override float PIDHoverHeight {
- set { _PIDHoverHeight = value; }
- }
- public override PIDHoverType PIDHoverType {
- set { _PIDHoverType = value; }
- }
- public override float PIDHoverTau {
- set { _PIDHoverTao = value; }
- }
-
- // For RotLookAt
- public override Quaternion APIDTarget { set { return; } }
- public override bool APIDActive { set { return; } }
- public override float APIDStrength { set { return; } }
- public override float APIDDamping { set { return; } }
-
- public override void AddForce(Vector3 force, bool pushforce) {
- if (force.IsFinite())
- {
- _force.X += force.X;
- _force.Y += force.Y;
- _force.Z += force.Z;
- base.ChangingActorID = RegionSyncServerModule.ActorID;
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
- });
- }
- else
- {
- m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader);
- }
- //m_lastUpdateSent = false;
- }
- public override void AddAngularForce(Vector3 force, bool pushforce) {
- }
- public override void SetMomentum(Vector3 momentum) {
- }
- public override void SubscribeEvents(int ms) {
- _subscribedEventsMs = ms;
- }
- public override void UnSubscribeEvents() {
- _subscribedEventsMs = 0;
- }
- public override bool SubscribedEvents() {
- return (_subscribedEventsMs > 0);
- }
-
- // The physics engine says that properties have updated. Update same and inform
- // the world that things have changed.
- public void UpdateProperties(EntityProperties entprop)
- {
- bool changed = false;
- // we assign to the local variables so the normal set action does not happen
- if (_position != entprop.Position)
- {
- _position = entprop.Position;
- changed = true;
- }
- if (_orientation != entprop.Rotation)
- {
- _orientation = entprop.Rotation;
- changed = true;
- }
- if (_velocity != entprop.Velocity)
- {
- _velocity = entprop.Velocity;
- changed = true;
- }
- if (_acceleration != entprop.Acceleration)
- {
- _acceleration = entprop.Acceleration;
- changed = true;
- }
- if (_rotationalVelocity != entprop.AngularVelocity)
- {
- _rotationalVelocity = entprop.AngularVelocity;
- changed = true;
- }
- if (changed)
- {
- base.ChangingActorID = RegionSyncServerModule.ActorID;
- this.RequestPhysicsterseUpdate();
- }
- }
-
- public void Collide(uint collidingWith, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth)
- {
- // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
-
- // The following makes IsColliding() and IsCollidingGround() work
- _collidingStep = _scene.SimulationStep;
- if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID)
- {
- _collidingGroundStep = _scene.SimulationStep;
- }
-
- if (_subscribedEventsMs == 0) return; // don't want collisions
-
- Dictionary contactPoints = new Dictionary();
- contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
- CollisionEventUpdate args = new CollisionEventUpdate(LocalID, (int)type, 1, contactPoints);
- base.SendCollisionUpdate(args);
- }
-
-}
-}
diff --git a/addon-modules/BulletSPlugin/BSPlugin.cs b/addon-modules/BulletSPlugin/BSPlugin.cs
deleted file mode 100644
index 0d53e8ed67..0000000000
--- a/addon-modules/BulletSPlugin/BSPlugin.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Intel Corporation nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * 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
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-using System;
-using System.Collections.Generic;
-using OpenSim.Framework;
-using OpenSim.Region.Physics.Manager;
-using OpenMetaverse;
-
-namespace OpenSim.Region.Physics.BulletSPlugin
-{
-public class BSPlugin : IPhysicsPlugin
-{
- //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
-
- private BSScene _mScene;
-
- public BSPlugin()
- {
- }
-
- public bool Init()
- {
- return true;
- }
-
- public PhysicsScene GetScene(String sceneIdentifier)
- {
- if (_mScene == null)
- {
- _mScene = new BSScene(sceneIdentifier);
- }
- return (_mScene);
- }
-
- public string GetName()
- {
- return ("BulletSim");
- }
-
- public void Dispose()
- {
- }
-}
-}
diff --git a/addon-modules/BulletSPlugin/BSPrim.cs b/addon-modules/BulletSPlugin/BSPrim.cs
deleted file mode 100644
index 515c4dad61..0000000000
--- a/addon-modules/BulletSPlugin/BSPrim.cs
+++ /dev/null
@@ -1,1106 +0,0 @@
-/*
- * Copyright (c) Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Intel Corporation nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * 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
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-using System;
-using System.Reflection;
-using System.Collections.Generic;
-using System.Xml;
-using log4net;
-using OMV = OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Physics.Manager;
-using OpenSim.Region.Physics.ConvexDecompositionDotNet;
-
-namespace OpenSim.Region.Physics.BulletSPlugin
-{
- [Serializable]
-public sealed class BSPrim : PhysicsActor
-{
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private static readonly string LogHeader = "[BULLETS PRIM]";
-
- private IMesh _mesh;
- private PrimitiveBaseShape _pbs;
- private ShapeData.PhysicsShapeType _shapeType;
- private ulong _hullKey;
- private List _hulls;
-
- private BSScene _scene;
- private String _avName;
- private uint _localID = 0;
-
- private OMV.Vector3 _size;
- private OMV.Vector3 _scale;
- private bool _stopped;
- private bool _grabbed;
- private bool _isSelected;
- private bool _isVolumeDetect;
- private OMV.Vector3 _position;
- private float _mass;
- private float _density;
- private OMV.Vector3 _force;
- private OMV.Vector3 _velocity;
- private OMV.Vector3 _torque;
- private float _collisionScore;
- private OMV.Vector3 _acceleration;
- private OMV.Quaternion _orientation;
- private int _physicsActorType;
- private bool _isPhysical;
- private bool _flying;
- private float _friction;
- private bool _setAlwaysRun;
- private bool _throttleUpdates;
- private bool _isColliding;
- private bool _collidingGround;
- private bool _collidingObj;
- private bool _floatOnWater;
- private OMV.Vector3 _rotationalVelocity;
- private bool _kinematic;
- private float _buoyancy;
-
- private List _childrenPrims;
- private BSPrim _parentPrim;
-
- private int _subscribedEventsMs = 0;
- long _collidingStep;
- long _collidingGroundStep;
-
- private OMV.Vector3 _PIDTarget;
- private bool _usePID;
- private float _PIDTau;
- private bool _useHoverPID;
- private float _PIDHoverHeight;
- private PIDHoverType _PIDHoverType;
- private float _PIDHoverTao;
-
- public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
- OMV.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical)
- {
- m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
- _localID = localID;
- _avName = primName;
- _scene = parent_scene;
- _position = pos;
- _size = size;
- _scale = new OMV.Vector3(1f, 1f, 1f); // the scale will be set by CreateGeom depending on object type
- _orientation = rotation;
- _buoyancy = 1f;
- _mesh = mesh;
- _hullKey = 0;
- _pbs = pbs;
- _isPhysical = pisPhysical;
- _isVolumeDetect = false;
- _subscribedEventsMs = 0;
- _friction = _scene.DefaultFriction; // TODO: compute based on object material
- _density = _scene.DefaultDensity; // TODO: compute based on object material
- _parentPrim = null; // not a child or a parent
- _childrenPrims = new List();
- if (_isPhysical)
- _mass = CalculateMass();
- else
- _mass = 0f;
- // do the actual object creation at taint time
- _scene.TaintedObject(delegate()
- {
- CreateGeom();
- CreateObject();
- });
- }
-
- // called when this prim is being destroyed and we should free all the resources
- public void Destroy()
- {
- // m_log.DebugFormat("{0}: Destroy", LogHeader);
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
- });
- }
-
- public override bool Stopped {
- get { return _stopped; }
- }
- public override OMV.Vector3 Size {
- get { return _size; }
- set {
- _size = value;
- m_log.DebugFormat("{0}: Size={1}", LogHeader, _size);
- _scene.TaintedObject(delegate()
- {
- if (_isPhysical) _mass = CalculateMass(); // changing size changes the mass
- BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, _mass, _isPhysical);
- RecreateGeomAndObject();
- // SyncUpdated = true;
- });
- }
- }
- public override PrimitiveBaseShape Shape {
- set {
- _pbs = value;
- m_log.DebugFormat("{0}: set Shape", LogHeader);
- _scene.TaintedObject(delegate()
- {
- if (_isPhysical) _mass = CalculateMass(); // changing the shape changes the mass
- RecreateGeomAndObject();
- // SyncUpdated = true;
- });
- }
- }
- public override uint LocalID {
- set { _localID = value; }
- get { return _localID; }
- }
- public override bool Grabbed {
- set { _grabbed = value;
- m_log.DebugFormat("{0}: Grabbed={1}", LogHeader, _grabbed);
- }
- }
- public override bool Selected {
- set {
- _isSelected = value;
- _scene.TaintedObject(delegate()
- {
- SetObjectDynamic();
- // SyncUpdated = true;
- });
- }
- }
- public override void CrossingFailure() { return; }
-
- // link me to the specified parent
- public override void link(PhysicsActor obj) {
- BSPrim parent = (BSPrim)obj;
- m_log.DebugFormat("{0}: link {1} to {2}", LogHeader, _localID, obj.LocalID);
- // TODO: decide if this parent checking needs to happen at taint time
- if (_parentPrim == null)
- {
- if (parent != null)
- {
- // I don't have a parent so I am joining a linkset
- parent.AddChildToLinkset(this);
- }
- }
- else
- {
- // I already have a parent, is parenting changing?
- if (parent != _parentPrim)
- {
- if (parent == null)
- {
- // we are being removed from a linkset
- _parentPrim.RemoveChildFromLinkset(this);
- }
- else
- {
- // asking to reparent a prim should not happen
- m_log.ErrorFormat("{0}: Reparenting a prim. ", LogHeader);
- }
- }
- }
- return;
- }
-
- // delink me from my linkset
- public override void delink() {
- // TODO: decide if this parent checking needs to happen at taint time
- m_log.DebugFormat("{0}: delink {1}", LogHeader, _localID);
- if (_parentPrim != null)
- {
- _parentPrim.RemoveChildFromLinkset(this);
- }
- return;
- }
-
- public void AddChildToLinkset(BSPrim pchild)
- {
- BSPrim child = pchild;
- _scene.TaintedObject(delegate()
- {
- if (!_childrenPrims.Contains(child))
- {
- _childrenPrims.Add(child);
- child.ParentPrim = this; // the child has gained a parent
- RecreateGeomAndObject(); // rebuild my shape with the new child added
- }
- });
- return;
- }
-
- public void RemoveChildFromLinkset(BSPrim pchild)
- {
- BSPrim child = pchild;
- _scene.TaintedObject(delegate()
- {
- if (_childrenPrims.Contains(child))
- {
- _childrenPrims.Remove(child);
- child.ParentPrim = null; // the child has lost its parent
- RecreateGeomAndObject(); // rebuild my shape with the child removed
- }
- else
- {
- m_log.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset");
- }
- });
- return;
- }
-
- public BSPrim ParentPrim
- {
- set { _parentPrim = value; }
- }
-
- public ulong HullKey
- {
- get { return _hullKey; }
- }
-
- // return true if we are the root of a linkset (there are children to manage)
- public bool IsRootOfLinkset
- {
- get { return (_parentPrim == null && _childrenPrims.Count != 0); }
- }
-
- public override void LockAngularMotion(OMV.Vector3 axis) { return; }
-
- public override OMV.Vector3 Position {
- get {
- // don't do the following GetObjectPosition because this function is called a zillion times
- // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
- return _position;
- }
- set {
- _position = value;
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
- // SyncUpdated = true;
- });
- }
- }
- public override float Mass {
- get { return _mass; }
- }
- public override OMV.Vector3 Force {
- get { return _force; }
- set {
- _force = value;
- m_log.DebugFormat("{0}: set Force. f={1}", LogHeader, _force);
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
- // SyncUpdated = true;
- });
- }
- }
-
- public override int VehicleType {
- get { return 0; }
- set { return; }
- }
- public override void VehicleFloatParam(int param, float value) { }
- public override void VehicleVectorParam(int param, OMV.Vector3 value) {}
- public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { }
- public override void VehicleFlags(int param, bool remove) { }
-
- // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
- public override void SetVolumeDetect(int param) {
- bool newValue = (param != 0);
- if (_isVolumeDetect != newValue)
- {
- _isVolumeDetect = newValue;
- _scene.TaintedObject(delegate()
- {
- SetObjectDynamic();
- });
- }
- return;
- }
-
- public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } }
- public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } }
- public override OMV.Vector3 Velocity {
- get { return _velocity; }
- set { _velocity = value;
- // SyncUpdated = true;
- }
- }
- public override OMV.Vector3 Torque {
- get { return _torque; }
- set { _torque = value;
- // SyncUpdated = true;
- }
- }
- public override float CollisionScore {
- get { return _collisionScore; }
- set { _collisionScore = value;
- // SyncUpdated = true;
- }
- }
- public override OMV.Vector3 Acceleration {
- get { return _acceleration; }
- }
- public override OMV.Quaternion Orientation {
- get { return _orientation; }
- set {
- _orientation = value;
- _scene.TaintedObject(delegate()
- {
- _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
- BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
- // m_log.DebugFormat("{0}: set orientation: {1}", LogHeader, _orientation);
- // SyncUpdated = true;
- });
- }
- }
- public override int PhysicsActorType {
- get { return _physicsActorType; }
- set { _physicsActorType = value;
- // SyncUpdated = true;
- }
- }
- public override bool IsPhysical {
- get { return _isPhysical; }
- set {
- _isPhysical = value;
- _scene.TaintedObject(delegate()
- {
- SetObjectDynamic();
- // SyncUpdated = true;
- });
- }
- }
-
- // An object is static (does not move) if selected or not physical
- private bool IsStatic
- {
- get { return _isSelected || !IsPhysical; }
- }
-
- // An object is solid if it's not phantom and if it's not doing VolumeDetect
- private bool IsSolid
- {
- get { return !IsPhantom && !_isVolumeDetect; }
- }
-
- // make gravity work if the object is physical and not selected
- // no locking here because only called when it is safe
- private void SetObjectDynamic()
- {
- // non-physical things work best with a mass of zero
- _mass = IsStatic ? 0f : CalculateMass();
- BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), _mass);
- // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}, mass={4}", LogHeader, _localID, IsStatic, IsSolid, _mass);
- }
-
- // prims don't fly
- public override bool Flying {
- get { return _flying; }
- set { _flying = value; }
- }
- public override bool SetAlwaysRun {
- get { return _setAlwaysRun; }
- set { _setAlwaysRun = value; }
- }
- public override bool ThrottleUpdates {
- get { return _throttleUpdates; }
- set { _throttleUpdates = value; }
- }
- public override bool IsColliding {
- get { return (_collidingStep == _scene.SimulationStep); }
- set { _isColliding = value; }
- }
- public override bool CollidingGround {
- get { return (_collidingGroundStep == _scene.SimulationStep); }
- set { _collidingGround = value; }
- }
- public override bool CollidingObj {
- get { return _collidingObj; }
- set { _collidingObj = value; }
- }
- public bool IsPhantom {
- get {
- // SceneObjectPart removes phantom objects from the physics scene
- // so, although we could implement touching and such, we never
- // are invoked as a phantom object
- return false;
- }
- }
- public override bool FloatOnWater {
- set { _floatOnWater = value; }
- }
- public override OMV.Vector3 RotationalVelocity {
- get { return _rotationalVelocity; }
- set { _rotationalVelocity = value;
- m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
- }
- }
- public override bool Kinematic {
- get { return _kinematic; }
- set { _kinematic = value;
- m_log.DebugFormat("{0}: Kinematic={1}", LogHeader, _kinematic);
- }
- }
- public override float Buoyancy {
- get { return _buoyancy; }
- set { _buoyancy = value;
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy);
- });
- }
- }
-
- // Used for MoveTo
- public override OMV.Vector3 PIDTarget {
- set { _PIDTarget = value; }
- }
- public override bool PIDActive {
- set { _usePID = value; }
- }
- public override float PIDTau {
- set { _PIDTau = value; }
- }
-
- // Used for llSetHoverHeight and maybe vehicle height
- // Hover Height will override MoveTo target's Z
- public override bool PIDHoverActive {
- set { _useHoverPID = value; }
- }
- public override float PIDHoverHeight {
- set { _PIDHoverHeight = value; }
- }
- public override PIDHoverType PIDHoverType {
- set { _PIDHoverType = value; }
- }
- public override float PIDHoverTau {
- set { _PIDHoverTao = value; }
- }
-
- // For RotLookAt
- public override OMV.Quaternion APIDTarget { set { return; } }
- public override bool APIDActive { set { return; } }
- public override float APIDStrength { set { return; } }
- public override float APIDDamping { set { return; } }
-
- public override void AddForce(OMV.Vector3 force, bool pushforce) {
- if (force.IsFinite())
- {
- _force.X += force.X;
- _force.Y += force.Y;
- _force.Z += force.Z;
- }
- else
- {
- m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader);
- }
- _scene.TaintedObject(delegate()
- {
- BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
- });
- }
-
- public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
- m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce);
- }
- public override void SetMomentum(OMV.Vector3 momentum) {
- }
- public override void SubscribeEvents(int ms) {
- _subscribedEventsMs = ms;
- }
- public override void UnSubscribeEvents() {
- _subscribedEventsMs = 0;
- }
- public override bool SubscribedEvents() {
- return (_subscribedEventsMs > 0);
- }
-
- #region Mass Calculation
-
- private float CalculateMass()
- {
- float volume = _size.X * _size.Y * _size.Z; // default
- float tmp;
-
- float returnMass = 0;
- float hollowAmount = (float)_pbs.ProfileHollow * 2.0e-5f;
- float hollowVolume = hollowAmount * hollowAmount;
-
- switch (_pbs.ProfileShape)
- {
- case ProfileShape.Square:
- // default box
-
- if (_pbs.PathCurve == (byte)Extrusion.Straight)
- {
- if (hollowAmount > 0.0)
- {
- switch (_pbs.HollowShape)
- {
- case HollowShape.Square:
- case HollowShape.Same:
- break;
-
- case HollowShape.Circle:
-
- hollowVolume *= 0.78539816339f;
- break;
-
- case HollowShape.Triangle:
-
- hollowVolume *= (0.5f * .5f);
- break;
-
- default:
- hollowVolume = 0;
- break;
- }
- volume *= (1.0f - hollowVolume);
- }
- }
-
- else if (_pbs.PathCurve == (byte)Extrusion.Curve1)
- {
- //a tube
-
- volume *= 0.78539816339e-2f * (float)(200 - _pbs.PathScaleX);
- tmp= 1.0f -2.0e-2f * (float)(200 - _pbs.PathScaleY);
- volume -= volume*tmp*tmp;
-
- if (hollowAmount > 0.0)
- {
- hollowVolume *= hollowAmount;
-
- switch (_pbs.HollowShape)
- {
- case HollowShape.Square:
- case HollowShape.Same:
- break;
-
- case HollowShape.Circle:
- hollowVolume *= 0.78539816339f;;
- break;
-
- case HollowShape.Triangle:
- hollowVolume *= 0.5f * 0.5f;
- break;
- default:
- hollowVolume = 0;
- break;
- }
- volume *= (1.0f - hollowVolume);
- }
- }
-
- break;
-
- case ProfileShape.Circle:
-
- if (_pbs.PathCurve == (byte)Extrusion.Straight)
- {
- volume *= 0.78539816339f; // elipse base
-
- if (hollowAmount > 0.0)
- {
- switch (_pbs.HollowShape)
- {
- case HollowShape.Same:
- case HollowShape.Circle:
- break;
-
- case HollowShape.Square:
- hollowVolume *= 0.5f * 2.5984480504799f;
- break;
-
- case HollowShape.Triangle:
- hollowVolume *= .5f * 1.27323954473516f;
- break;
-
- default:
- hollowVolume = 0;
- break;
- }
- volume *= (1.0f - hollowVolume);
- }
- }
-
- else if (_pbs.PathCurve == (byte)Extrusion.Curve1)
- {
- volume *= 0.61685027506808491367715568749226e-2f * (float)(200 - _pbs.PathScaleX);
- tmp = 1.0f - .02f * (float)(200 - _pbs.PathScaleY);
- volume *= (1.0f - tmp * tmp);
-
- if (hollowAmount > 0.0)
- {
-
- // calculate the hollow volume by it's shape compared to the prim shape
- hollowVolume *= hollowAmount;
-
- switch (_pbs.HollowShape)
- {
- case HollowShape.Same:
- case HollowShape.Circle:
- break;
-
- case HollowShape.Square:
- hollowVolume *= 0.5f * 2.5984480504799f;
- break;
-
- case HollowShape.Triangle:
- hollowVolume *= .5f * 1.27323954473516f;
- break;
-
- default:
- hollowVolume = 0;
- break;
- }
- volume *= (1.0f - hollowVolume);
- }
- }
- break;
-
- case ProfileShape.HalfCircle:
- if (_pbs.PathCurve == (byte)Extrusion.Curve1)
- {
- volume *= 0.52359877559829887307710723054658f;
- }
- break;
-
- case ProfileShape.EquilateralTriangle:
-
- if (_pbs.PathCurve == (byte)Extrusion.Straight)
- {
- volume *= 0.32475953f;
-
- if (hollowAmount > 0.0)
- {
-
- // calculate the hollow volume by it's shape compared to the prim shape
- switch (_pbs.HollowShape)
- {
- case HollowShape.Same:
- case HollowShape.Triangle:
- hollowVolume *= .25f;
- break;
-
- case HollowShape.Square:
- hollowVolume *= 0.499849f * 3.07920140172638f;
- break;
-
- case HollowShape.Circle:
- // Hollow shape is a perfect cyllinder in respect to the cube's scale
- // Cyllinder hollow volume calculation
-
- hollowVolume *= 0.1963495f * 3.07920140172638f;
- break;
-
- default:
- hollowVolume = 0;
- break;
- }
- volume *= (1.0f - hollowVolume);
- }
- }
- else if (_pbs.PathCurve == (byte)Extrusion.Curve1)
- {
- volume *= 0.32475953f;
- volume *= 0.01f * (float)(200 - _pbs.PathScaleX);
- tmp = 1.0f - .02f * (float)(200 - _pbs.PathScaleY);
- volume *= (1.0f - tmp * tmp);
-
- if (hollowAmount > 0.0)
- {
-
- hollowVolume *= hollowAmount;
-
- switch (_pbs.HollowShape)
- {
- case HollowShape.Same:
- case HollowShape.Triangle:
- hollowVolume *= .25f;
- break;
-
- case HollowShape.Square:
- hollowVolume *= 0.499849f * 3.07920140172638f;
- break;
-
- case HollowShape.Circle:
-
- hollowVolume *= 0.1963495f * 3.07920140172638f;
- break;
-
- default:
- hollowVolume = 0;
- break;
- }
- volume *= (1.0f - hollowVolume);
- }
- }
- break;
-
- default:
- break;
- }
-
-
-
- float taperX1;
- float taperY1;
- float taperX;
- float taperY;
- float pathBegin;
- float pathEnd;
- float profileBegin;
- float profileEnd;
-
- if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible)
- {
- taperX1 = _pbs.PathScaleX * 0.01f;
- if (taperX1 > 1.0f)
- taperX1 = 2.0f - taperX1;
- taperX = 1.0f - taperX1;
-
- taperY1 = _pbs.PathScaleY * 0.01f;
- if (taperY1 > 1.0f)
- taperY1 = 2.0f - taperY1;
- taperY = 1.0f - taperY1;
- }
- else
- {
- taperX = _pbs.PathTaperX * 0.01f;
- if (taperX < 0.0f)
- taperX = -taperX;
- taperX1 = 1.0f - taperX;
-
- taperY = _pbs.PathTaperY * 0.01f;
- if (taperY < 0.0f)
- taperY = -taperY;
- taperY1 = 1.0f - taperY;
-
- }
-
-
- volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY);
-
- pathBegin = (float)_pbs.PathBegin * 2.0e-5f;
- pathEnd = 1.0f - (float)_pbs.PathEnd * 2.0e-5f;
- volume *= (pathEnd - pathBegin);
-
- // this is crude aproximation
- profileBegin = (float)_pbs.ProfileBegin * 2.0e-5f;
- profileEnd = 1.0f - (float)_pbs.ProfileEnd * 2.0e-5f;
- volume *= (profileEnd - profileBegin);
-
- returnMass = _density * volume;
-
- if (returnMass <= 0)
- returnMass = 0.0001f;//ckrinke: Mass must be greater then zero.
-
- if (IsRootOfLinkset)
- {
- foreach (BSPrim prim in _childrenPrims)
- {
- returnMass += prim.CalculateMass();
- }
- }
-
- if (returnMass > _scene.maximumMassObject)
- returnMass = _scene.maximumMassObject;
- return returnMass;
- }// end CalculateMass
- #endregion Mass Calculation
-
- // Create the geometry information in Bullet for later use
- // No locking here because this is done when we know physics is not simulating
- private void CreateGeom()
- {
- if (_mesh == null)
- {
- // the mesher thought this was too simple to mesh. Use a native Bullet collision shape.
- if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1)
- {
- if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z)
- {
- m_log.DebugFormat("{0}: CreateGeom: mesh null. Defaulting to sphere of size {1}", LogHeader, _size);
- _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE;
- // Bullet native objects are scaled by the Bullet engine so pass the size in
- _scale = _size;
- }
- }
- else
- {
- m_log.DebugFormat("{0}: CreateGeom: mesh null. Defaulting to box of size {1}", LogHeader, _size);
- _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX;
- _scale = _size;
- }
- }
- else
- {
- if (_hullKey != 0)
- {
- m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey);
- BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey);
- _hullKey = 0;
- _hulls.Clear();
- }
-
- int[] indices = _mesh.getIndexListAsInt();
- List vertices = _mesh.getVertexList();
-
- //format conversion from IMesh format to DecompDesc format
- List convIndices = new List();
- List convVertices = new List();
- for (int ii = 0; ii < indices.GetLength(0); ii++)
- {
- convIndices.Add(indices[ii]);
- }
- foreach (OMV.Vector3 vv in vertices)
- {
- convVertices.Add(new float3(vv.X, vv.Y, vv.Z));
- }
-
- // setup and do convex hull conversion
- _hulls = new List();
- DecompDesc dcomp = new DecompDesc();
- dcomp.mIndices = convIndices;
- dcomp.mVertices = convVertices;
- ConvexBuilder convexBuilder = new ConvexBuilder(HullReturn);
- // create the hull into the _hulls variable
- convexBuilder.process(dcomp);
-
- // Convert the vertices and indices for passing to unmanaged
- // The hull information is passed as a large floating point array.
- // The format is:
- // convHulls[0] = number of hulls
- // convHulls[1] = number of vertices in first hull
- // convHulls[2] = hull centroid X coordinate
- // convHulls[3] = hull centroid Y coordinate
- // convHulls[4] = hull centroid Z coordinate
- // convHulls[5] = first hull vertex X
- // convHulls[6] = first hull vertex Y
- // convHulls[7] = first hull vertex Z
- // convHulls[8] = second hull vertex X
- // ...
- // convHulls[n] = number of vertices in second hull
- // convHulls[n+1] = second hull centroid X coordinate
- // ...
- //
- // TODO: is is very inefficient. Someday change the convex hull generator to return
- // data structures that do not need to be converted in order to pass to Bullet.
- // And maybe put the values directly into pinned memory rather than marshaling.
- int hullCount = _hulls.Count;
- int totalVertices = 1; // include one for the count of the hulls
- foreach (ConvexResult cr in _hulls)
- {
- totalVertices += 4; // add four for the vertex count and centroid
- totalVertices += cr.HullIndices.Count * 3; // we pass just triangles
- }
- float[] convHulls = new float[totalVertices];
-
- convHulls[0] = (float)hullCount;
- int jj = 1;
- foreach (ConvexResult cr in _hulls)
- {
- // copy vertices for index access
- float3[] verts = new float3[cr.HullVertices.Count];
- int kk = 0;
- foreach (float3 ff in cr.HullVertices)
- {
- verts[kk++] = ff;
- }
-
- // add to the array one hull's worth of data
- convHulls[jj++] = cr.HullIndices.Count;
- convHulls[jj++] = 0f; // centroid x,y,z
- convHulls[jj++] = 0f;
- convHulls[jj++] = 0f;
- foreach (int ind in cr.HullIndices)
- {
- convHulls[jj++] = verts[ind].x;
- convHulls[jj++] = verts[ind].y;
- convHulls[jj++] = verts[ind].z;
- }
- }
-
- // create the hull definition in Bullet
- _hullKey = (ulong)_pbs.GetHashCode();
- // m_log.DebugFormat("{0}: CreateGeom: calling CreateHull. key={1}, hulls={2}", LogHeader, _hullKey, hullCount);
- BulletSimAPI.CreateHull(_scene.WorldID, _hullKey, hullCount, convHulls);
- _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL;
- // meshes are already scaled by the meshmerizer
- _scale = new OMV.Vector3(1f, 1f, 1f);
- }
- return;
- }
-
- private void HullReturn(ConvexResult result)
- {
- _hulls.Add(result);
- return;
- }
-
- // Create an object in Bullet
- // No locking here because this is done when the physics engine is not simulating
- private void CreateObject()
- {
- if (IsRootOfLinkset)
- {
- // Create a linkset around this object
- // If I am the root prim of a linkset, replace my physical shape with all the
- // pieces of the children.
- // All of the children should have called CreateGeom so they have a hull
- // in the physics engine already. Here we pull together all of those hulls
- // into one shape.
- m_log.DebugFormat("{0}: CreateLinkset", LogHeader);
- int totalPrimsInLinkset = _childrenPrims.Count + 1;
- ShapeData[] shapes = new ShapeData[totalPrimsInLinkset];
- FillShapeInfo(out shapes[0]);
- int ii = 1;
- foreach (BSPrim prim in _childrenPrims)
- {
- m_log.DebugFormat("{0}: CreateLinkset: adding prim {1}", LogHeader, prim.LocalID);
- prim.FillShapeInfo(out shapes[ii]);
- ii++;
- }
- BulletSimAPI.CreateLinkset(_scene.WorldID, totalPrimsInLinkset, shapes);
- }
- else
- {
- // simple object
- ShapeData shape;
- FillShapeInfo(out shape);
- BulletSimAPI.CreateObject(_scene.WorldID, shape);
- }
- }
-
- // Copy prim's info into the BulletSim shape description structure
- public void FillShapeInfo(out ShapeData shape)
- {
- shape.ID = _localID;
- shape.Type = _shapeType;
- shape.Position = _position;
- shape.Rotation = _orientation;
- shape.Velocity = _velocity;
- shape.Scale = _scale;
- shape.Mass = _isPhysical ? _mass : 0f;
- shape.Buoyancy = _buoyancy;
- shape.MeshKey = _hullKey;
- shape.Collidable = (!IsPhantom) ? ShapeData.numericTrue : ShapeData.numericFalse;
- shape.Friction = _friction;
- shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue;
- }
-
- // Rebuild the geometry and object.
- // This is called when the shape changes so we need to recreate the mesh/hull.
- // No locking here because this is done when the physics engine is not simulating
- private void RecreateGeomAndObject()
- {
- if (_hullKey != 0)
- {
- // if a hull already exists, delete the old one
- BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey);
- _hullKey = 0;
- }
- // If this object is complex or we are the root of a linkset, build a mesh.
- // The root of a linkset must be a mesh so we can create the linked compound object.
- if (_scene.NeedsMeshing(_pbs) || IsRootOfLinkset )
- {
- m_log.DebugFormat("{0}: RecreateGeomAndObject: creating mesh", LogHeader);
- _mesh = _scene.mesher.CreateMesh(_avName, _pbs, _size, _scene.meshLOD, _isPhysical);
- }
- else
- {
- // it's a BulletSim native shape.
- _mesh = null;
- }
- CreateGeom(); // create the geometry for this prim
- CreateObject();
- return;
- }
-
- // The physics engine says that properties have updated. Update same and inform
- // the world that things have changed.
- // TODO: do we really need to check for changed? Maybe just copy values and call RequestPhysicsterseUpdate()
- public void UpdateProperties(EntityProperties entprop)
- {
- bool changed = false;
- // assign to the local variables so the normal set action does not happen
- if (_position != entprop.Position)
- {
- _position = entprop.Position;
- // m_log.DebugFormat("{0}: UpdateProperties: position = {1}", LogHeader, _position);
- changed = true;
- }
- if (_orientation != entprop.Rotation)
- {
- _orientation = entprop.Rotation;
- // m_log.DebugFormat("{0}: UpdateProperties: rotation = {1}", LogHeader, _orientation);
- changed = true;
- }
- if (_velocity != entprop.Velocity)
- {
- _velocity = entprop.Velocity;
- // m_log.DebugFormat("{0}: UpdateProperties: velocity = {1}", LogHeader, _velocity);
- changed = true;
- }
- if (_acceleration != entprop.Acceleration)
- {
- _acceleration = entprop.Acceleration;
- // m_log.DebugFormat("{0}: UpdateProperties: acceleration = {1}", LogHeader, _acceleration);
- changed = true;
- }
- if (_rotationalVelocity != entprop.AngularVelocity)
- {
- _rotationalVelocity = entprop.AngularVelocity;
- // m_log.DebugFormat("{0}: UpdateProperties: rotationalVelocity = {1}", LogHeader, _rotationalVelocity);
- changed = true;
- }
- if (changed)
- {
- base.RequestPhysicsterseUpdate();
- }
- }
-
- // I've collided with something
- public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
- {
- // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
- // The following makes IsColliding() and IsCollidingGround() work
- _collidingStep = _scene.SimulationStep;
- if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID)
- {
- _collidingGroundStep = _scene.SimulationStep;
- }
-
- if (_subscribedEventsMs == 0) return; // nothing in the object is waiting for collision events
-
- // create the event for the collision
- Dictionary contactPoints = new Dictionary();
- contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
- CollisionEventUpdate args = new CollisionEventUpdate(LocalID, (int)type, 1, contactPoints);
- base.SendCollisionUpdate(args);
- }
-}
-}
diff --git a/addon-modules/BulletSPlugin/BSScene.cs b/addon-modules/BulletSPlugin/BSScene.cs
deleted file mode 100644
index d656b8aa24..0000000000
--- a/addon-modules/BulletSPlugin/BSScene.cs
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- * Copyright (c) 2011 Intel Corporation
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Intel Corporation nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * 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
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading;
-using Nini.Config;
-using log4net;
-using OpenSim.Framework;
-using OpenSim.Region.Physics.Manager;
-using OpenMetaverse;
-using OpenSim.Region.Framework;
-
-// TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim)
-// Does NeedsMeshing() really need to exclude all the different shapes?
-// Based on material, set density and friction
-// More efficient memory usage in passing hull information from BSPrim to BulletSim
-// Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly?
-// In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground)
-// At the moment, physical and phantom causes object to drop through the terrain
-// LinkSets
-// Freeing of memory of linksets in BulletSim::DestroyObject
-// Set child prims phantom since the physicality is handled by the parent prim
-// Linked children need rotation relative to parent (passed as world rotation)
-// Should prim.link() and prim.delink() membership checking happen at taint time?
-// Test sculpties
-// Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once
-// Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect
-// Parameterize BulletSim. Pass a structure of parameters to the C++ code. Capsule size, friction, ...
-// Use event subscription times to reduce the number of events passed up (_subscribedEventMS)
-// Implement the genCollisions feature in BulletSim::SetObjectProperties (don't pass up unneeded collisions)
-//
-namespace OpenSim.Region.Physics.BulletSPlugin
-{
-public class BSScene : PhysicsScene
-{
- private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
- private static readonly string LogHeader = "[BULLETS SCENE]";
-
- private Dictionary m_avatars = new Dictionary();
- private Dictionary m_prims = new Dictionary();
- private float[] m_heightMap;
- private uint m_worldID;
- public uint WorldID { get { return m_worldID; } }
-
- public IMesher mesher;
- public int meshLOD = 32;
-
- private int m_maxSubSteps = 10;
- private float m_fixedTimeStep = 1f / 60f;
- private long m_simulationStep = 0;
- public long SimulationStep { get { return m_simulationStep; } }
-
- private bool _meshSculptedPrim = true; // cause scuplted prims to get meshed
- private bool _forceSimplePrimMeshing = false; // if a cube or sphere, let Bullet do internal shapes
- public float maximumMassObject = 10000.01f;
-
- public const uint TERRAIN_ID = 0;
- public const uint GROUNDPLANE_ID = 1;
-
- public float DefaultFriction = 0.70f;
- public float DefaultDensity = 10.000006836f; // Aluminum g/cm3; TODO: compute based on object material
-
- public delegate void TaintCallback();
- private List _taintedObjects;
- private Object _taintLock = new Object();
-
- private BulletSimAPI.DebugLogCallback debugLogCallbackHandle;
-
- public BSScene(string identifier)
- {
- }
-
- public override void Initialise(IMesher meshmerizer, IConfigSource config)
- {
- if (config != null)
- {
- IConfig pConfig = config.Configs["BulletSim"];
- if (pConfig != null)
- {
- DefaultFriction = pConfig.GetFloat("Friction", DefaultFriction);
- DefaultDensity = pConfig.GetFloat("Density", DefaultDensity);
- }
- }
- // if Debug, enable logging from the unmanaged code
- if (m_log.IsDebugEnabled)
- {
- m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader);
- debugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger);
- BulletSimAPI.SetDebugLogCallback(debugLogCallbackHandle);
- }
-
- _meshSculptedPrim = true; // mesh sculpted prims
- _forceSimplePrimMeshing = false; // use complex meshing if called for
-
- _taintedObjects = new List();
-
- mesher = meshmerizer;
- // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader);
- m_worldID = BulletSimAPI.Initialize(new Vector3(Constants.RegionSize, Constants.RegionSize, 1000f));
- }
-
- private void BulletLogger(string msg)
- {
- m_log.Debug("[BULLETS UNMANAGED]:" + msg);
- }
-
- public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
- {
- m_log.ErrorFormat("{0}: CALL TO AddAvatar in BSScene. NOT IMPLEMENTED", LogHeader);
- return null;
- }
-
- public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying)
- {
- // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName);
- BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
- lock (m_avatars) m_avatars.Add(localID, actor);
- return actor;
- }
-
- public override void RemoveAvatar(PhysicsActor actor)
- {
- // m_log.DebugFormat("{0}: RemoveAvatar", LogHeader);
- if (actor is BSCharacter)
- {
- ((BSCharacter)actor).Destroy();
- }
- try
- {
- lock (m_avatars) m_avatars.Remove(actor.LocalID);
- }
- catch (Exception e)
- {
- m_log.WarnFormat("{0}: Attempt to remove avatar that is not in physics scene: {1}", LogHeader, e);
- }
- }
-
- public override void RemovePrim(PhysicsActor prim)
- {
- // m_log.DebugFormat("{0}: RemovePrim", LogHeader);
- if (prim is BSPrim)
- {
- ((BSPrim)prim).Destroy();
- }
- try
- {
- lock (m_prims) m_prims.Remove(prim.LocalID);
- }
- catch (Exception e)
- {
- m_log.WarnFormat("{0}: Attempt to remove prim that is not in physics scene: {1}", LogHeader, e);
- }
- }
-
- public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
- Vector3 size, Quaternion rotation) // deprecated
- {
- return null;
- }
- public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
- Vector3 size, Quaternion rotation, bool isPhysical)
- {
- m_log.ErrorFormat("{0}: CALL TO AddPrimShape in BSScene. NOT IMPLEMENTED", LogHeader);
- return null;
- }
-
- public override PhysicsActor AddPrimShape(uint localID, string primName, PrimitiveBaseShape pbs, Vector3 position,
- Vector3 size, Quaternion rotation, bool isPhysical)
- {
- // m_log.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName);
- IMesh mesh = null;
- if (NeedsMeshing(pbs))
- {
- // if the prim is complex, create the mesh for it.
- // If simple (box or sphere) leave 'mesh' null and physics will do a native shape.
- // m_log.DebugFormat("{0}: AddPrimShape2: creating mesh", LogHeader);
- mesh = mesher.CreateMesh(primName, pbs, size, this.meshLOD, isPhysical);
- }
- BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, mesh, pbs, isPhysical);
- lock (m_prims) m_prims.Add(localID, prim);
- return prim;
- }
-
- public override void AddPhysicsActorTaint(PhysicsActor prim) { }
-
- public override float Simulate(float timeStep)
- {
- int updatedEntityCount;
- IntPtr updatedEntitiesPtr;
- IntPtr[] updatedEntities;
- int collidersCount;
- IntPtr collidersPtr;
- int[] colliders; // should be uint but Marshal.Copy does not have that overload
-
- // update the prim states while we know the physics engine is not busy
- ProcessTaints();
-
- // step the physical world one interval
- m_simulationStep++;
- int numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep,
- out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr);
-
- // if there were collisions, they show up here
- if (collidersCount > 0)
- {
- colliders = new int[collidersCount];
- Marshal.Copy(collidersPtr, colliders, 0, collidersCount);
- for (int ii = 0; ii < collidersCount; ii+=2)
- {
- uint cA = (uint)colliders[ii];
- uint cB = (uint)colliders[ii+1];
- SendCollision(cA, cB);
- SendCollision(cB, cA);
- }
- }
-
- // if any of the objects had updated properties, they are returned in the updatedEntity structure
- if (updatedEntityCount > 0)
- {
- updatedEntities = new IntPtr[updatedEntityCount];
- Marshal.Copy(updatedEntitiesPtr, updatedEntities, 0, updatedEntityCount);
- for (int ii = 0; ii < updatedEntityCount; ii++)
- {
- IntPtr updatePointer = updatedEntities[ii];
- EntityProperties entprop = (EntityProperties)Marshal.PtrToStructure(updatePointer, typeof(EntityProperties));
- // m_log.DebugFormat("{0}: entprop: id={1}, pos={2}", LogHeader, entprop.ID, entprop.Position);
- BSCharacter actor;
- if (m_avatars.TryGetValue(entprop.ID, out actor))
- {
- actor.UpdateProperties(entprop);
- continue;
- }
- BSPrim prim;
- if (m_prims.TryGetValue(entprop.ID, out prim))
- {
- prim.UpdateProperties(entprop);
- }
- }
- }
-
- // if (collidersCount > 0 || updatedEntityCount > 0) m_log.WarnFormat("{0}: collisions={1}, updates={2}", LogHeader, collidersCount/2, updatedEntityCount);
-
- return 11f; // returns frames per second
- }
-
- // Something has collided
- private void SendCollision(uint localID, uint collidingWith)
- {
- if (localID == TERRAIN_ID || localID == GROUNDPLANE_ID)
- {
- // we never send collisions to the terrain
- return;
- }
-
- ActorTypes type = ActorTypes.Prim;
- if (collidingWith == TERRAIN_ID || collidingWith == GROUNDPLANE_ID)
- type = ActorTypes.Ground;
- else if (m_avatars.ContainsKey(collidingWith))
- type = ActorTypes.Agent;
-
- BSPrim prim;
- if (m_prims.TryGetValue(localID, out prim)) {
- prim.Collide(collidingWith, type, Vector3.Zero, Vector3.UnitZ, 0.01f);
- return;
- }
- BSCharacter actor;
- if (m_avatars.TryGetValue(localID, out actor)) {
- actor.Collide(collidingWith, type, Vector3.Zero, Vector3.UnitZ, 0.01f);
- return;
- }
- return;
- }
-
- public override void GetResults() { }
-
- public override void SetTerrain(float[] heightMap) {
- m_log.DebugFormat("{0}: SetTerrain", LogHeader);
- m_heightMap = heightMap;
- this.TaintedObject(delegate()
- {
- BulletSimAPI.SetHeightmap(m_worldID, m_heightMap);
- });
- }
-
- public override void SetWaterLevel(float baseheight) { }
-
- public override void DeleteTerrain()
- {
- m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader);
- }
-
- public override void Dispose()
- {
- m_log.DebugFormat("{0}: Dispose()", LogHeader);
- }
-
- public override Dictionary GetTopColliders()
- {
- return new Dictionary();
- }
-
- public override bool IsThreaded { get { return false; } }
-
- ///
- /// Routine to figure out if we need to mesh this prim with our mesher
- ///
- ///
- /// true if the prim needs meshing
- public bool NeedsMeshing(PrimitiveBaseShape pbs)
- {
- // most of this is redundant now as the mesher will return null if it cant mesh a prim
- // but we still need to check for sculptie meshing being enabled so this is the most
- // convenient place to do it for now...
-
- // int iPropertiesNotSupportedDefault = 0;
-
- if (pbs.SculptEntry && !_meshSculptedPrim)
- {
- // m_log.DebugFormat("{0}: NeedsMeshing: scultpy mesh", LogHeader);
- return false;
- }
-
- // if it's a standard box or sphere with no cuts, hollows, twist or top shear, return false since Bullet
- // can use an internal representation for the prim
- if (!_forceSimplePrimMeshing)
- {
- // m_log.DebugFormat("{0}: NeedsMeshing: simple mesh: profshape={1}, curve={2}", LogHeader, pbs.ProfileShape, pbs.PathCurve);
- if ((pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight)
- || (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1
- && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z))
- {
-
- if (pbs.ProfileBegin == 0 && pbs.ProfileEnd == 0
- && pbs.ProfileHollow == 0
- && pbs.PathTwist == 0 && pbs.PathTwistBegin == 0
- && pbs.PathBegin == 0 && pbs.PathEnd == 0
- && pbs.PathTaperX == 0 && pbs.PathTaperY == 0
- && pbs.PathScaleX == 100 && pbs.PathScaleY == 100
- && pbs.PathShearX == 0 && pbs.PathShearY == 0)
- {
- return false;
- }
- }
- }
-
- /* TODO: verify that the mesher will now do all these shapes
- if (pbs.ProfileHollow != 0)
- iPropertiesNotSupportedDefault++;
-
- if ((pbs.PathBegin != 0) || pbs.PathEnd != 0)
- iPropertiesNotSupportedDefault++;
-
- if ((pbs.PathTwistBegin != 0) || (pbs.PathTwist != 0))
- iPropertiesNotSupportedDefault++;
-
- if ((pbs.ProfileBegin != 0) || pbs.ProfileEnd != 0)
- iPropertiesNotSupportedDefault++;
-
- if ((pbs.PathScaleX != 100) || (pbs.PathScaleY != 100))
- iPropertiesNotSupportedDefault++;
-
- if ((pbs.PathShearX != 0) || (pbs.PathShearY != 0))
- iPropertiesNotSupportedDefault++;
-
- if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight)
- iPropertiesNotSupportedDefault++;
-
- if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 && (pbs.Scale.X != pbs.Scale.Y || pbs.Scale.Y != pbs.Scale.Z || pbs.Scale.Z != pbs.Scale.X))
- iPropertiesNotSupportedDefault++;
-
- if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte) Extrusion.Curve1)
- iPropertiesNotSupportedDefault++;
-
- // test for torus
- if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
- {
- if (pbs.PathCurve == (byte)Extrusion.Curve1)
- {
- iPropertiesNotSupportedDefault++;
- }
- }
- else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
- {
- if (pbs.PathCurve == (byte)Extrusion.Straight)
- {
- iPropertiesNotSupportedDefault++;
- }
- // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
- else if (pbs.PathCurve == (byte)Extrusion.Curve1)
- {
- iPropertiesNotSupportedDefault++;
- }
- }
- else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
- {
- if (pbs.PathCurve == (byte)Extrusion.Curve1 || pbs.PathCurve == (byte)Extrusion.Curve2)
- {
- iPropertiesNotSupportedDefault++;
- }
- }
- else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
- {
- if (pbs.PathCurve == (byte)Extrusion.Straight)
- {
- iPropertiesNotSupportedDefault++;
- }
- else if (pbs.PathCurve == (byte)Extrusion.Curve1)
- {
- iPropertiesNotSupportedDefault++;
- }
- }
- if (iPropertiesNotSupportedDefault == 0)
- {
- return false;
- }
- */
- return true;
- }
-
- // The calls to the PhysicsActors can't directly call into the physics engine
- // because it might be busy. We we delay changes to a known time.
- // We rely on C#'s closure to save and restore the context for the delegate.
- public void TaintedObject(TaintCallback callback)
- {
- lock (_taintLock)
- _taintedObjects.Add(callback);
- return;
- }
-
- // When someone tries to change a property on a BSPrim or BSCharacter, the object queues
- // a callback into itself to do the actual property change. That callback is called
- // here just before the physics engine is called to step the simulation.
- public void ProcessTaints()
- {
- // swizzle a new list into the list location so we can process what's there
- List oldList;
- lock (_taintLock)
- {
- oldList = _taintedObjects;
- _taintedObjects = new List();
- }
-
- foreach (TaintCallback callback in oldList)
- {
- try
- {
- callback();
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("{0}: ProcessTaints: Exception: {1}", LogHeader, e);
- }
- }
- oldList.Clear();
- }
-}
-}
diff --git a/addon-modules/BulletSPlugin/BulletSimAPI.cs b/addon-modules/BulletSPlugin/BulletSimAPI.cs
deleted file mode 100644
index 8d97f30bb1..0000000000
--- a/addon-modules/BulletSPlugin/BulletSimAPI.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-Copyright (c) 2011, Intel Corporation
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are
-permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list
- of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this
- list of conditions and the following disclaimer in the documentation and/or other
- materials provided with the distribution.
- * Neither the name of Intel Corporation nor the names of its contributors may be
- used to endorse or promote products derived from this software without specific
- prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
-SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND 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
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-using System;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Text;
-using OpenMetaverse;
-
-namespace OpenSim.Region.Physics.BulletSPlugin {
-
-public struct ConvexHull
-{
- Vector3 Offset;
- int VertexCount;
- Vector3[] Vertices;
-}
-public struct ShapeData
-{
- public enum PhysicsShapeType
- {
- SHAPE_AVATAR = 0,
- SHAPE_BOX = 1,
- SHAPE_CONE = 2,
- SHAPE_CYLINDER = 3,
- SHAPE_SPHERE = 4,
- SHAPE_HULL = 5
- };
- public const int numericTrue = 1;
- public const int numericFalse = 0;
- public uint ID;
- public PhysicsShapeType Type;
- public Vector3 Position;
- public Quaternion Rotation;
- public Vector3 Velocity;
- public Vector3 Scale;
- public float Mass;
- public float Buoyancy;
- public System.UInt64 MeshKey;
- public int Collidable;
- public float Friction;
- public int Static; // true if a static object. Otherwise gravity, etc.
- // note that bools are passed as ints since bool size changes by language
-}
-public struct SweepHit
-{
- public uint ID;
- public float Fraction;
- public Vector3 Normal;
- public Vector3 Point;
-}
-public struct RaycastHit
-{
- public uint ID;
- public float Fraction;
- public Vector3 Normal;
-}
-
-public struct EntityProperties
-{
- public uint ID;
- public Vector3 Position;
- public Quaternion Rotation;
- public Vector3 Velocity;
- public Vector3 Acceleration;
- public Vector3 AngularVelocity;
-}
-
-static class BulletSimAPI {
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern uint Initialize(Vector3 maxPosition);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void Shutdown(uint worldID);
-
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep,
- out int updatedEntityCount,
- out IntPtr updatedEntitiesPtr,
- out int collidersCount,
- out IntPtr collidersPtr);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool CreateHull(uint worldID, System.UInt64 meshKey, int hullCount,
- [MarshalAs(UnmanagedType.LPArray)] float[] hulls
- );
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool DestroyHull(uint worldID, System.UInt64 meshKey);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool CreateObject(uint worldID, ShapeData shapeData);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void CreateLinkset(uint worldID, int objectCount, ShapeData[] shapeDatas);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 GetObjectPosition(uint WorldID, uint id);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectTranslation(uint worldID, uint id, Vector3 position, Quaternion rotation);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectVelocity(uint worldID, uint id, Vector3 velocity);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectForce(uint worldID, uint id, Vector3 force);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectScaleMass(uint worldID, uint id, Vector3 scale, float mass, bool isDynamic);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectCollidable(uint worldID, uint id, bool phantom);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectDynamic(uint worldID, uint id, bool isDynamic, float mass);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectGhost(uint worldID, uint id, bool ghostly);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectProperties(uint worldID, uint id, bool isStatic, bool isSolid, bool genCollisions, float mass);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool SetObjectBuoyancy(uint worldID, uint id, float buoyancy);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool HasObject(uint worldID, uint id);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern bool DestroyObject(uint worldID, uint id);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern SweepHit ConvexSweepTest(uint worldID, uint id, Vector3 to, float extraMargin);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vector3 to);
-
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern Vector3 RecoverFromPenetration(uint worldID, uint id);
-
-// Log a debug message
-[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg);
-[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
-public static extern void SetDebugLogCallback(DebugLogCallback callback);
-}
-}
diff --git a/addon-modules/BulletSPlugin/prebuild.xml b/addon-modules/BulletSPlugin/prebuild.xml
deleted file mode 100644
index 47ed1a1069..0000000000
--- a/addon-modules/BulletSPlugin/prebuild.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
- ../../bin/Physics/
-
-
-
-
- ../../bin/Physics/
-
-
-
- ../../bin/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/addon-modules/ConvexDecompositionDotNet/CTri.cs b/addon-modules/ConvexDecompositionDotNet/CTri.cs
deleted file mode 100644
index 4d84c44704..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/CTri.cs
+++ /dev/null
@@ -1,341 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class Wpoint
- {
- public float3 mPoint;
- public float mWeight;
-
- public Wpoint(float3 p, float w)
- {
- mPoint = p;
- mWeight = w;
- }
- }
-
- public class CTri
- {
- private const int WSCALE = 4;
-
- public float3 mP1;
- public float3 mP2;
- public float3 mP3;
- public float3 mNear1;
- public float3 mNear2;
- public float3 mNear3;
- public float3 mNormal;
- public float mPlaneD;
- public float mConcavity;
- public float mC1;
- public float mC2;
- public float mC3;
- public int mI1;
- public int mI2;
- public int mI3;
- public int mProcessed; // already been added...
-
- public CTri(float3 p1, float3 p2, float3 p3, int i1, int i2, int i3)
- {
- mProcessed = 0;
- mI1 = i1;
- mI2 = i2;
- mI3 = i3;
-
- mP1 = new float3(p1);
- mP2 = new float3(p2);
- mP3 = new float3(p3);
-
- mNear1 = new float3();
- mNear2 = new float3();
- mNear3 = new float3();
-
- mNormal = new float3();
- mPlaneD = mNormal.ComputePlane(mP1, mP2, mP3);
- }
-
- public float Facing(CTri t)
- {
- return float3.dot(mNormal, t.mNormal);
- }
-
- public bool clip(float3 start, ref float3 end)
- {
- float3 sect = new float3();
- bool hit = lineIntersectsTriangle(start, end, mP1, mP2, mP3, ref sect);
-
- if (hit)
- end = sect;
- return hit;
- }
-
- public bool Concave(float3 p, ref float distance, ref float3 n)
- {
- n.NearestPointInTriangle(p, mP1, mP2, mP3);
- distance = p.Distance(n);
- return true;
- }
-
- public void addTri(int[] indices, int i1, int i2, int i3, ref int tcount)
- {
- indices[tcount * 3 + 0] = i1;
- indices[tcount * 3 + 1] = i2;
- indices[tcount * 3 + 2] = i3;
- tcount++;
- }
-
- public float getVolume()
- {
- int[] indices = new int[8 * 3];
-
- int tcount = 0;
-
- addTri(indices, 0, 1, 2, ref tcount);
- addTri(indices, 3, 4, 5, ref tcount);
-
- addTri(indices, 0, 3, 4, ref tcount);
- addTri(indices, 0, 4, 1, ref tcount);
-
- addTri(indices, 1, 4, 5, ref tcount);
- addTri(indices, 1, 5, 2, ref tcount);
-
- addTri(indices, 0, 3, 5, ref tcount);
- addTri(indices, 0, 5, 2, ref tcount);
-
- List vertices = new List { mP1, mP2, mP3, mNear1, mNear2, mNear3 };
- List indexList = new List(indices);
-
- float v = Concavity.computeMeshVolume(vertices, indexList);
- return v;
- }
-
- public float raySect(float3 p, float3 dir, ref float3 sect)
- {
- float4 plane = new float4();
-
- plane.x = mNormal.x;
- plane.y = mNormal.y;
- plane.z = mNormal.z;
- plane.w = mPlaneD;
-
- float3 dest = p + dir * 100000f;
-
- intersect(p, dest, ref sect, plane);
-
- return sect.Distance(p); // return the intersection distance
- }
-
- public float planeDistance(float3 p)
- {
- float4 plane = new float4();
-
- plane.x = mNormal.x;
- plane.y = mNormal.y;
- plane.z = mNormal.z;
- plane.w = mPlaneD;
-
- return DistToPt(p, plane);
- }
-
- public bool samePlane(CTri t)
- {
- const float THRESH = 0.001f;
- float dd = Math.Abs(t.mPlaneD - mPlaneD);
- if (dd > THRESH)
- return false;
- dd = Math.Abs(t.mNormal.x - mNormal.x);
- if (dd > THRESH)
- return false;
- dd = Math.Abs(t.mNormal.y - mNormal.y);
- if (dd > THRESH)
- return false;
- dd = Math.Abs(t.mNormal.z - mNormal.z);
- if (dd > THRESH)
- return false;
- return true;
- }
-
- public bool hasIndex(int i)
- {
- if (i == mI1 || i == mI2 || i == mI3)
- return true;
- return false;
- }
-
- public bool sharesEdge(CTri t)
- {
- bool ret = false;
- uint count = 0;
-
- if (t.hasIndex(mI1))
- count++;
- if (t.hasIndex(mI2))
- count++;
- if (t.hasIndex(mI3))
- count++;
-
- if (count >= 2)
- ret = true;
-
- return ret;
- }
-
- public float area()
- {
- float a = mConcavity * mP1.Area(mP2, mP3);
- return a;
- }
-
- public void addWeighted(List list)
- {
- Wpoint p1 = new Wpoint(mP1, mC1);
- Wpoint p2 = new Wpoint(mP2, mC2);
- Wpoint p3 = new Wpoint(mP3, mC3);
-
- float3 d1 = mNear1 - mP1;
- float3 d2 = mNear2 - mP2;
- float3 d3 = mNear3 - mP3;
-
- d1 *= WSCALE;
- d2 *= WSCALE;
- d3 *= WSCALE;
-
- d1 = d1 + mP1;
- d2 = d2 + mP2;
- d3 = d3 + mP3;
-
- Wpoint p4 = new Wpoint(d1, mC1);
- Wpoint p5 = new Wpoint(d2, mC2);
- Wpoint p6 = new Wpoint(d3, mC3);
-
- list.Add(p1);
- list.Add(p2);
- list.Add(p3);
-
- list.Add(p4);
- list.Add(p5);
- list.Add(p6);
- }
-
- private static float DistToPt(float3 p, float4 plane)
- {
- float x = p.x;
- float y = p.y;
- float z = p.z;
- float d = x*plane.x + y*plane.y + z*plane.z + plane.w;
- return d;
- }
-
- private static void intersect(float3 p1, float3 p2, ref float3 split, float4 plane)
- {
- float dp1 = DistToPt(p1, plane);
-
- float3 dir = new float3();
- dir.x = p2[0] - p1[0];
- dir.y = p2[1] - p1[1];
- dir.z = p2[2] - p1[2];
-
- float dot1 = dir[0] * plane[0] + dir[1] * plane[1] + dir[2] * plane[2];
- float dot2 = dp1 - plane[3];
-
- float t = -(plane[3] + dot2) / dot1;
-
- split.x = (dir[0] * t) + p1[0];
- split.y = (dir[1] * t) + p1[1];
- split.z = (dir[2] * t) + p1[2];
- }
-
- private static bool rayIntersectsTriangle(float3 p, float3 d, float3 v0, float3 v1, float3 v2, out float t)
- {
- t = 0f;
-
- float3 e1, e2, h, s, q;
- float a, f, u, v;
-
- e1 = v1 - v0;
- e2 = v2 - v0;
- h = float3.cross(d, e2);
- a = float3.dot(e1, h);
-
- if (a > -0.00001f && a < 0.00001f)
- return false;
-
- f = 1f / a;
- s = p - v0;
- u = f * float3.dot(s, h);
-
- if (u < 0.0f || u > 1.0f)
- return false;
-
- q = float3.cross(s, e1);
- v = f * float3.dot(d, q);
- if (v < 0.0f || u + v > 1.0f)
- return false;
-
- // at this stage we can compute t to find out where
- // the intersection point is on the line
- t = f * float3.dot(e2, q);
- if (t > 0f) // ray intersection
- return true;
- else // this means that there is a line intersection but not a ray intersection
- return false;
- }
-
- private static bool lineIntersectsTriangle(float3 rayStart, float3 rayEnd, float3 p1, float3 p2, float3 p3, ref float3 sect)
- {
- float3 dir = rayEnd - rayStart;
-
- float d = (float)Math.Sqrt(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]);
- float r = 1.0f / d;
-
- dir *= r;
-
- float t;
- bool ret = rayIntersectsTriangle(rayStart, dir, p1, p2, p3, out t);
-
- if (ret)
- {
- if (t > d)
- {
- sect.x = rayStart.x + dir.x * t;
- sect.y = rayStart.y + dir.y * t;
- sect.z = rayStart.z + dir.z * t;
- }
- else
- {
- ret = false;
- }
- }
-
- return ret;
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/Concavity.cs b/addon-modules/ConvexDecompositionDotNet/Concavity.cs
deleted file mode 100644
index cc6383a9c6..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/Concavity.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public static class Concavity
- {
- // compute's how 'concave' this object is and returns the total volume of the
- // convex hull as well as the volume of the 'concavity' which was found.
- public static float computeConcavity(List vertices, List indices, ref float4 plane, ref float volume)
- {
- float cret = 0f;
- volume = 1f;
-
- HullResult result = new HullResult();
- HullDesc desc = new HullDesc();
-
- desc.MaxFaces = 256;
- desc.MaxVertices = 256;
- desc.SetHullFlag(HullFlag.QF_TRIANGLES);
- desc.Vertices = vertices;
-
- HullError ret = HullUtils.CreateConvexHull(desc, ref result);
-
- if (ret == HullError.QE_OK)
- {
- volume = computeMeshVolume2(result.OutputVertices, result.Indices);
-
- // ok..now..for each triangle on the original mesh..
- // we extrude the points to the nearest point on the hull.
- List tris = new List();
-
- for (int i = 0; i < result.Indices.Count / 3; i++)
- {
- int i1 = result.Indices[i * 3 + 0];
- int i2 = result.Indices[i * 3 + 1];
- int i3 = result.Indices[i * 3 + 2];
-
- float3 p1 = result.OutputVertices[i1];
- float3 p2 = result.OutputVertices[i2];
- float3 p3 = result.OutputVertices[i3];
-
- CTri t = new CTri(p1, p2, p3, i1, i2, i3);
- tris.Add(t);
- }
-
- // we have not pre-computed the plane equation for each triangle in the convex hull..
- float totalVolume = 0;
-
- List ftris = new List(); // 'feature' triangles.
- List input_mesh = new List();
-
- for (int i = 0; i < indices.Count / 3; i++)
- {
- int i1 = indices[i * 3 + 0];
- int i2 = indices[i * 3 + 1];
- int i3 = indices[i * 3 + 2];
-
- float3 p1 = vertices[i1];
- float3 p2 = vertices[i2];
- float3 p3 = vertices[i3];
-
- CTri t = new CTri(p1, p2, p3, i1, i2, i3);
- input_mesh.Add(t);
- }
-
- for (int i = 0; i < indices.Count / 3; i++)
- {
- int i1 = indices[i * 3 + 0];
- int i2 = indices[i * 3 + 1];
- int i3 = indices[i * 3 + 2];
-
- float3 p1 = vertices[i1];
- float3 p2 = vertices[i2];
- float3 p3 = vertices[i3];
-
- CTri t = new CTri(p1, p2, p3, i1, i2, i3);
-
- featureMatch(t, tris, input_mesh);
-
- if (t.mConcavity > 0.05f)
- {
- float v = t.getVolume();
- totalVolume += v;
- ftris.Add(t);
- }
- }
-
- SplitPlane.computeSplitPlane(vertices, indices, ref plane);
- cret = totalVolume;
- }
-
- return cret;
- }
-
- public static bool featureMatch(CTri m, List tris, List input_mesh)
- {
- bool ret = false;
- float neardot = 0.707f;
- m.mConcavity = 0;
-
- for (int i = 0; i < tris.Count; i++)
- {
- CTri t = tris[i];
-
- if (t.samePlane(m))
- {
- ret = false;
- break;
- }
-
- float dot = float3.dot(t.mNormal, m.mNormal);
-
- if (dot > neardot)
- {
- float d1 = t.planeDistance(m.mP1);
- float d2 = t.planeDistance(m.mP2);
- float d3 = t.planeDistance(m.mP3);
-
- if (d1 > 0.001f || d2 > 0.001f || d3 > 0.001f) // can't be near coplaner!
- {
- neardot = dot;
-
- t.raySect(m.mP1, m.mNormal, ref m.mNear1);
- t.raySect(m.mP2, m.mNormal, ref m.mNear2);
- t.raySect(m.mP3, m.mNormal, ref m.mNear3);
-
- ret = true;
- }
- }
- }
-
- if (ret)
- {
- m.mC1 = m.mP1.Distance(m.mNear1);
- m.mC2 = m.mP2.Distance(m.mNear2);
- m.mC3 = m.mP3.Distance(m.mNear3);
-
- m.mConcavity = m.mC1;
-
- if (m.mC2 > m.mConcavity)
- m.mConcavity = m.mC2;
- if (m.mC3 > m.mConcavity)
- m.mConcavity = m.mC3;
- }
-
- return ret;
- }
-
- private static float det(float3 p1, float3 p2, float3 p3)
- {
- return p1.x * p2.y * p3.z + p2.x * p3.y * p1.z + p3.x * p1.y * p2.z - p1.x * p3.y * p2.z - p2.x * p1.y * p3.z - p3.x * p2.y * p1.z;
- }
-
- public static float computeMeshVolume(List vertices, List indices)
- {
- float volume = 0f;
-
- for (int i = 0; i < indices.Count / 3; i++)
- {
- float3 p1 = vertices[indices[i * 3 + 0]];
- float3 p2 = vertices[indices[i * 3 + 1]];
- float3 p3 = vertices[indices[i * 3 + 2]];
-
- volume += det(p1, p2, p3); // compute the volume of the tetrahedran relative to the origin.
- }
-
- volume *= (1.0f / 6.0f);
- if (volume < 0f)
- return -volume;
- return volume;
- }
-
- public static float computeMeshVolume2(List vertices, List indices)
- {
- float volume = 0f;
-
- float3 p0 = vertices[0];
- for (int i = 0; i < indices.Count / 3; i++)
- {
- float3 p1 = vertices[indices[i * 3 + 0]];
- float3 p2 = vertices[indices[i * 3 + 1]];
- float3 p3 = vertices[indices[i * 3 + 2]];
-
- volume += tetVolume(p0, p1, p2, p3); // compute the volume of the tetrahedron relative to the root vertice
- }
-
- return volume * (1.0f / 6.0f);
- }
-
- private static float tetVolume(float3 p0, float3 p1, float3 p2, float3 p3)
- {
- float3 a = p1 - p0;
- float3 b = p2 - p0;
- float3 c = p3 - p0;
-
- float3 cross = float3.cross(b, c);
- float volume = float3.dot(a, cross);
-
- if (volume < 0f)
- return -volume;
- return volume;
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/ConvexBuilder.cs b/addon-modules/ConvexDecompositionDotNet/ConvexBuilder.cs
deleted file mode 100644
index dfaede1176..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/ConvexBuilder.cs
+++ /dev/null
@@ -1,411 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class DecompDesc
- {
- public List mVertices;
- public List mIndices;
-
- // options
- public uint mDepth; // depth to split, a maximum of 10, generally not over 7.
- public float mCpercent; // the concavity threshold percentage. 0=20 is reasonable.
- public float mPpercent; // the percentage volume conservation threshold to collapse hulls. 0-30 is reasonable.
-
- // hull output limits.
- public uint mMaxVertices; // maximum number of vertices in the output hull. Recommended 32 or less.
- public float mSkinWidth; // a skin width to apply to the output hulls.
-
- public ConvexDecompositionCallback mCallback; // the interface to receive back the results.
-
- public DecompDesc()
- {
- mDepth = 5;
- mCpercent = 5;
- mPpercent = 5;
- mMaxVertices = 32;
- }
- }
-
- public class CHull
- {
- public float[] mMin = new float[3];
- public float[] mMax = new float[3];
- public float mVolume;
- public float mDiagonal;
- public ConvexResult mResult;
-
- public CHull(ConvexResult result)
- {
- mResult = new ConvexResult(result);
- mVolume = Concavity.computeMeshVolume(result.HullVertices, result.HullIndices);
-
- mDiagonal = getBoundingRegion(result.HullVertices, mMin, mMax);
-
- float dx = mMax[0] - mMin[0];
- float dy = mMax[1] - mMin[1];
- float dz = mMax[2] - mMin[2];
-
- dx *= 0.1f; // inflate 1/10th on each edge
- dy *= 0.1f; // inflate 1/10th on each edge
- dz *= 0.1f; // inflate 1/10th on each edge
-
- mMin[0] -= dx;
- mMin[1] -= dy;
- mMin[2] -= dz;
-
- mMax[0] += dx;
- mMax[1] += dy;
- mMax[2] += dz;
- }
-
- public void Dispose()
- {
- mResult = null;
- }
-
- public bool overlap(CHull h)
- {
- return overlapAABB(mMin, mMax, h.mMin, h.mMax);
- }
-
- // returns the d1Giagonal distance
- private static float getBoundingRegion(List points, float[] bmin, float[] bmax)
- {
- float3 first = points[0];
-
- bmin[0] = first.x;
- bmin[1] = first.y;
- bmin[2] = first.z;
-
- bmax[0] = first.x;
- bmax[1] = first.y;
- bmax[2] = first.z;
-
- for (int i = 1; i < points.Count; i++)
- {
- float3 p = points[i];
-
- if (p[0] < bmin[0]) bmin[0] = p[0];
- if (p[1] < bmin[1]) bmin[1] = p[1];
- if (p[2] < bmin[2]) bmin[2] = p[2];
-
- if (p[0] > bmax[0]) bmax[0] = p[0];
- if (p[1] > bmax[1]) bmax[1] = p[1];
- if (p[2] > bmax[2]) bmax[2] = p[2];
- }
-
- float dx = bmax[0] - bmin[0];
- float dy = bmax[1] - bmin[1];
- float dz = bmax[2] - bmin[2];
-
- return (float)Math.Sqrt(dx * dx + dy * dy + dz * dz);
- }
-
- // return true if the two AABB's overlap.
- private static bool overlapAABB(float[] bmin1, float[] bmax1, float[] bmin2, float[] bmax2)
- {
- if (bmax2[0] < bmin1[0]) return false; // if the maximum is less than our minimum on any axis
- if (bmax2[1] < bmin1[1]) return false;
- if (bmax2[2] < bmin1[2]) return false;
-
- if (bmin2[0] > bmax1[0]) return false; // if the minimum is greater than our maximum on any axis
- if (bmin2[1] > bmax1[1]) return false; // if the minimum is greater than our maximum on any axis
- if (bmin2[2] > bmax1[2]) return false; // if the minimum is greater than our maximum on any axis
-
- return true; // the extents overlap
- }
- }
-
- public class ConvexBuilder
- {
- public List mChulls = new List();
- private ConvexDecompositionCallback mCallback;
-
- private int MAXDEPTH = 8;
- private float CONCAVE_PERCENT = 1f;
- private float MERGE_PERCENT = 2f;
-
- public ConvexBuilder(ConvexDecompositionCallback callback)
- {
- mCallback = callback;
- }
-
- public void Dispose()
- {
- int i;
- for (i = 0; i < mChulls.Count; i++)
- {
- CHull cr = mChulls[i];
- cr.Dispose();
- }
- }
-
- public bool isDuplicate(uint i1, uint i2, uint i3, uint ci1, uint ci2, uint ci3)
- {
- uint dcount = 0;
-
- Debug.Assert(i1 != i2 && i1 != i3 && i2 != i3);
- Debug.Assert(ci1 != ci2 && ci1 != ci3 && ci2 != ci3);
-
- if (i1 == ci1 || i1 == ci2 || i1 == ci3)
- dcount++;
- if (i2 == ci1 || i2 == ci2 || i2 == ci3)
- dcount++;
- if (i3 == ci1 || i3 == ci2 || i3 == ci3)
- dcount++;
-
- return dcount == 3;
- }
-
- public void getMesh(ConvexResult cr, VertexPool vc, List indices)
- {
- List src = cr.HullIndices;
-
- for (int i = 0; i < src.Count / 3; i++)
- {
- int i1 = src[i * 3 + 0];
- int i2 = src[i * 3 + 1];
- int i3 = src[i * 3 + 2];
-
- float3 p1 = cr.HullVertices[i1];
- float3 p2 = cr.HullVertices[i2];
- float3 p3 = cr.HullVertices[i3];
-
- i1 = vc.getIndex(p1);
- i2 = vc.getIndex(p2);
- i3 = vc.getIndex(p3);
- }
- }
-
- public CHull canMerge(CHull a, CHull b)
- {
- if (!a.overlap(b)) // if their AABB's (with a little slop) don't overlap, then return.
- return null;
-
- CHull ret = null;
-
- // ok..we are going to combine both meshes into a single mesh
- // and then we are going to compute the concavity...
-
- VertexPool vc = new VertexPool();
-
- List indices = new List();
-
- getMesh(a.mResult, vc, indices);
- getMesh(b.mResult, vc, indices);
-
- int vcount = vc.GetSize();
- List vertices = vc.GetVertices();
- int tcount = indices.Count / 3;
-
- //don't do anything if hull is empty
- if (tcount == 0)
- {
- vc.Clear();
- return null;
- }
-
- HullResult hresult = new HullResult();
- HullDesc desc = new HullDesc();
-
- desc.SetHullFlag(HullFlag.QF_TRIANGLES);
- desc.Vertices = vertices;
-
- HullError hret = HullUtils.CreateConvexHull(desc, ref hresult);
-
- if (hret == HullError.QE_OK)
- {
- float combineVolume = Concavity.computeMeshVolume(hresult.OutputVertices, hresult.Indices);
- float sumVolume = a.mVolume + b.mVolume;
-
- float percent = (sumVolume * 100) / combineVolume;
- if (percent >= (100.0f - MERGE_PERCENT))
- {
- ConvexResult cr = new ConvexResult(hresult.OutputVertices, hresult.Indices);
- ret = new CHull(cr);
- }
- }
-
- vc.Clear();
- return ret;
- }
-
- public bool combineHulls()
- {
- bool combine = false;
-
- sortChulls(mChulls); // sort the convex hulls, largest volume to least...
-
- List output = new List(); // the output hulls...
-
- int i;
- for (i = 0; i < mChulls.Count && !combine; ++i)
- {
- CHull cr = mChulls[i];
-
- int j;
- for (j = 0; j < mChulls.Count; j++)
- {
- CHull match = mChulls[j];
-
- if (cr != match) // don't try to merge a hull with itself, that be stoopid
- {
-
- CHull merge = canMerge(cr, match); // if we can merge these two....
-
- if (merge != null)
- {
- output.Add(merge);
-
- ++i;
- while (i != mChulls.Count)
- {
- CHull cr2 = mChulls[i];
- if (cr2 != match)
- {
- output.Add(cr2);
- }
- i++;
- }
-
- cr.Dispose();
- match.Dispose();
- combine = true;
- break;
- }
- }
- }
-
- if (combine)
- {
- break;
- }
- else
- {
- output.Add(cr);
- }
- }
-
- if (combine)
- {
- mChulls.Clear();
- mChulls = output;
- output.Clear();
- }
-
- return combine;
- }
-
- public int process(DecompDesc desc)
- {
- int ret = 0;
-
- MAXDEPTH = (int)desc.mDepth;
- CONCAVE_PERCENT = desc.mCpercent;
- MERGE_PERCENT = desc.mPpercent;
-
- ConvexDecomposition.calcConvexDecomposition(desc.mVertices, desc.mIndices, ConvexDecompResult, 0f, 0, MAXDEPTH, CONCAVE_PERCENT, MERGE_PERCENT);
-
- while (combineHulls()) // keep combinging hulls until I can't combine any more...
- ;
-
- int i;
- for (i = 0; i < mChulls.Count; i++)
- {
- CHull cr = mChulls[i];
-
- // before we hand it back to the application, we need to regenerate the hull based on the
- // limits given by the user.
-
- ConvexResult c = cr.mResult; // the high resolution hull...
-
- HullResult result = new HullResult();
- HullDesc hdesc = new HullDesc();
-
- hdesc.SetHullFlag(HullFlag.QF_TRIANGLES);
-
- hdesc.Vertices = c.HullVertices;
- hdesc.MaxVertices = desc.mMaxVertices; // maximum number of vertices allowed in the output
-
- if (desc.mSkinWidth != 0f)
- {
- hdesc.SkinWidth = desc.mSkinWidth;
- hdesc.SetHullFlag(HullFlag.QF_SKIN_WIDTH); // do skin width computation.
- }
-
- HullError ret2 = HullUtils.CreateConvexHull(hdesc, ref result);
-
- if (ret2 == HullError.QE_OK)
- {
- ConvexResult r = new ConvexResult(result.OutputVertices, result.Indices);
-
- r.mHullVolume = Concavity.computeMeshVolume(result.OutputVertices, result.Indices); // the volume of the hull.
-
- // compute the best fit OBB
- //computeBestFitOBB(result.mNumOutputVertices, result.mOutputVertices, sizeof(float) * 3, r.mOBBSides, r.mOBBTransform);
-
- //r.mOBBVolume = r.mOBBSides[0] * r.mOBBSides[1] * r.mOBBSides[2]; // compute the OBB volume.
-
- //fm_getTranslation(r.mOBBTransform, r.mOBBCenter); // get the translation component of the 4x4 matrix.
-
- //fm_matrixToQuat(r.mOBBTransform, r.mOBBOrientation); // extract the orientation as a quaternion.
-
- //r.mSphereRadius = computeBoundingSphere(result.mNumOutputVertices, result.mOutputVertices, r.mSphereCenter);
- //r.mSphereVolume = fm_sphereVolume(r.mSphereRadius);
-
- mCallback(r);
- }
-
- result = null;
- cr.Dispose();
- }
-
- ret = mChulls.Count;
-
- mChulls.Clear();
-
- return ret;
- }
-
- public void ConvexDecompResult(ConvexResult result)
- {
- CHull ch = new CHull(result);
- mChulls.Add(ch);
- }
-
- public void sortChulls(List hulls)
- {
- hulls.Sort(delegate(CHull a, CHull b) { return a.mVolume.CompareTo(b.mVolume); });
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/ConvexDecomposition.cs b/addon-modules/ConvexDecompositionDotNet/ConvexDecomposition.cs
deleted file mode 100644
index 2e2bb70c7a..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/ConvexDecomposition.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public delegate void ConvexDecompositionCallback(ConvexResult result);
-
- public class FaceTri
- {
- public float3 P1;
- public float3 P2;
- public float3 P3;
-
- public FaceTri() { }
-
- public FaceTri(List vertices, int i1, int i2, int i3)
- {
- P1 = new float3(vertices[i1]);
- P2 = new float3(vertices[i2]);
- P3 = new float3(vertices[i3]);
- }
- }
-
- public static class ConvexDecomposition
- {
- private static void addTri(VertexPool vl, List list, float3 p1, float3 p2, float3 p3)
- {
- int i1 = vl.getIndex(p1);
- int i2 = vl.getIndex(p2);
- int i3 = vl.getIndex(p3);
-
- // do *not* process degenerate triangles!
- if ( i1 != i2 && i1 != i3 && i2 != i3 )
- {
- list.Add(i1);
- list.Add(i2);
- list.Add(i3);
- }
- }
-
- public static void calcConvexDecomposition(List vertices, List indices, ConvexDecompositionCallback callback, float masterVolume, int depth,
- int maxDepth, float concavePercent, float mergePercent)
- {
- float4 plane = new float4();
- bool split = false;
-
- if (depth < maxDepth)
- {
- float volume = 0f;
- float c = Concavity.computeConcavity(vertices, indices, ref plane, ref volume);
-
- if (depth == 0)
- {
- masterVolume = volume;
- }
-
- float percent = (c * 100.0f) / masterVolume;
-
- if (percent > concavePercent) // if great than 5% of the total volume is concave, go ahead and keep splitting.
- {
- split = true;
- }
- }
-
- if (depth >= maxDepth || !split)
- {
- HullResult result = new HullResult();
- HullDesc desc = new HullDesc();
-
- desc.SetHullFlag(HullFlag.QF_TRIANGLES);
-
- desc.Vertices = vertices;
-
- HullError ret = HullUtils.CreateConvexHull(desc, ref result);
-
- if (ret == HullError.QE_OK)
- {
- ConvexResult r = new ConvexResult(result.OutputVertices, result.Indices);
- callback(r);
- }
-
- return;
- }
-
- List ifront = new List();
- List iback = new List();
-
- VertexPool vfront = new VertexPool();
- VertexPool vback = new VertexPool();
-
- // ok..now we are going to 'split' all of the input triangles against this plane!
- for (int i = 0; i < indices.Count / 3; i++)
- {
- int i1 = indices[i * 3 + 0];
- int i2 = indices[i * 3 + 1];
- int i3 = indices[i * 3 + 2];
-
- FaceTri t = new FaceTri(vertices, i1, i2, i3);
-
- float3[] front = new float3[4];
- float3[] back = new float3[4];
-
- int fcount = 0;
- int bcount = 0;
-
- PlaneTriResult result = PlaneTri.planeTriIntersection(plane, t, 0.00001f, ref front, out fcount, ref back, out bcount);
-
- if (fcount > 4 || bcount > 4)
- {
- result = PlaneTri.planeTriIntersection(plane, t, 0.00001f, ref front, out fcount, ref back, out bcount);
- }
-
- switch (result)
- {
- case PlaneTriResult.PTR_FRONT:
- Debug.Assert(fcount == 3);
- addTri(vfront, ifront, front[0], front[1], front[2]);
- break;
- case PlaneTriResult.PTR_BACK:
- Debug.Assert(bcount == 3);
- addTri(vback, iback, back[0], back[1], back[2]);
- break;
- case PlaneTriResult.PTR_SPLIT:
- Debug.Assert(fcount >= 3 && fcount <= 4);
- Debug.Assert(bcount >= 3 && bcount <= 4);
-
- addTri(vfront, ifront, front[0], front[1], front[2]);
- addTri(vback, iback, back[0], back[1], back[2]);
-
- if (fcount == 4)
- {
- addTri(vfront, ifront, front[0], front[2], front[3]);
- }
-
- if (bcount == 4)
- {
- addTri(vback, iback, back[0], back[2], back[3]);
- }
-
- break;
- }
- }
-
- // ok... here we recursively call
- if (ifront.Count > 0)
- {
- int vcount = vfront.GetSize();
- List vertices2 = vfront.GetVertices();
- for (int i = 0; i < vertices2.Count; i++)
- vertices2[i] = new float3(vertices2[i]);
- int tcount = ifront.Count / 3;
-
- calcConvexDecomposition(vertices2, ifront, callback, masterVolume, depth + 1, maxDepth, concavePercent, mergePercent);
- }
-
- ifront.Clear();
- vfront.Clear();
-
- if (iback.Count > 0)
- {
- int vcount = vback.GetSize();
- List vertices2 = vback.GetVertices();
- int tcount = iback.Count / 3;
-
- calcConvexDecomposition(vertices2, iback, callback, masterVolume, depth + 1, maxDepth, concavePercent, mergePercent);
- }
-
- iback.Clear();
- vback.Clear();
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/ConvexResult.cs b/addon-modules/ConvexDecompositionDotNet/ConvexResult.cs
deleted file mode 100644
index 87758b5971..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/ConvexResult.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class ConvexResult
- {
- public List HullVertices;
- public List HullIndices;
-
- public float mHullVolume; // the volume of the convex hull.
-
- //public float[] OBBSides = new float[3]; // the width, height and breadth of the best fit OBB
- //public float[] OBBCenter = new float[3]; // the center of the OBB
- //public float[] OBBOrientation = new float[4]; // the quaternion rotation of the OBB.
- //public float[] OBBTransform = new float[16]; // the 4x4 transform of the OBB.
- //public float OBBVolume; // the volume of the OBB
-
- //public float SphereRadius; // radius and center of best fit sphere
- //public float[] SphereCenter = new float[3];
- //public float SphereVolume; // volume of the best fit sphere
-
- public ConvexResult()
- {
- HullVertices = new List();
- HullIndices = new List();
- }
-
- public ConvexResult(List hvertices, List hindices)
- {
- HullVertices = hvertices;
- HullIndices = hindices;
- }
-
- public ConvexResult(ConvexResult r)
- {
- HullVertices = new List(r.HullVertices);
- HullIndices = new List(r.HullIndices);
- }
-
- public void Dispose()
- {
- HullVertices = null;
- HullIndices = null;
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/HullClasses.cs b/addon-modules/ConvexDecompositionDotNet/HullClasses.cs
deleted file mode 100644
index d81df262ae..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/HullClasses.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class HullResult
- {
- public bool Polygons = true; // true if indices represents polygons, false indices are triangles
- public List OutputVertices = new List();
- public List Indices;
-
- // If triangles, then indices are array indexes into the vertex list.
- // If polygons, indices are in the form (number of points in face) (p1, p2, p3, ..) etc..
- }
-
- public class PHullResult
- {
- public List Vertices = new List();
- public List Indices = new List();
- }
-
- [Flags]
- public enum HullFlag : int
- {
- QF_DEFAULT = 0,
- QF_TRIANGLES = (1 << 0), // report results as triangles, not polygons.
- QF_SKIN_WIDTH = (1 << 2) // extrude hull based on this skin width
- }
-
- public enum HullError : int
- {
- QE_OK, // success!
- QE_FAIL // failed.
- }
-
- public class HullDesc
- {
- public HullFlag Flags; // flags to use when generating the convex hull.
- public List Vertices;
- public float NormalEpsilon; // the epsilon for removing duplicates. This is a normalized value, if normalized bit is on.
- public float SkinWidth;
- public uint MaxVertices; // maximum number of vertices to be considered for the hull!
- public uint MaxFaces;
-
- public HullDesc()
- {
- Flags = HullFlag.QF_DEFAULT;
- Vertices = new List();
- NormalEpsilon = 0.001f;
- MaxVertices = 4096;
- MaxFaces = 4096;
- SkinWidth = 0.01f;
- }
-
- public HullDesc(HullFlag flags, List vertices)
- {
- Flags = flags;
- Vertices = new List(vertices);
- NormalEpsilon = 0.001f;
- MaxVertices = 4096;
- MaxFaces = 4096;
- SkinWidth = 0.01f;
- }
-
- public bool HasHullFlag(HullFlag flag)
- {
- return (Flags & flag) != 0;
- }
-
- public void SetHullFlag(HullFlag flag)
- {
- Flags |= flag;
- }
-
- public void ClearHullFlag(HullFlag flag)
- {
- Flags &= ~flag;
- }
- }
-
- public class ConvexH
- {
- public struct HalfEdge
- {
- public short ea; // the other half of the edge (index into edges list)
- public byte v; // the vertex at the start of this edge (index into vertices list)
- public byte p; // the facet on which this edge lies (index into facets list)
-
- public HalfEdge(short _ea, byte _v, byte _p)
- {
- ea = _ea;
- v = _v;
- p = _p;
- }
-
- public HalfEdge(HalfEdge e)
- {
- ea = e.ea;
- v = e.v;
- p = e.p;
- }
- }
-
- public List vertices = new List();
- public List edges = new List();
- public List facets = new List();
-
- public ConvexH(int vertices_size, int edges_size, int facets_size)
- {
- vertices = new List(vertices_size);
- edges = new List(edges_size);
- facets = new List(facets_size);
- }
- }
-
- public class VertFlag
- {
- public byte planetest;
- public byte junk;
- public byte undermap;
- public byte overmap;
- }
-
- public class EdgeFlag
- {
- public byte planetest;
- public byte fixes;
- public short undermap;
- public short overmap;
- }
-
- public class PlaneFlag
- {
- public byte undermap;
- public byte overmap;
- }
-
- public class Coplanar
- {
- public ushort ea;
- public byte v0;
- public byte v1;
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/HullTriangle.cs b/addon-modules/ConvexDecompositionDotNet/HullTriangle.cs
deleted file mode 100644
index 1119a75e91..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/HullTriangle.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class HullTriangle : int3
- {
- public int3 n = new int3();
- public int id;
- public int vmax;
- public float rise;
- private List tris;
-
- public HullTriangle(int a, int b, int c, List tris)
- : base(a, b, c)
- {
- this.tris = tris;
-
- n = new int3(-1, -1, -1);
- id = tris.Count;
- tris.Add(this);
- vmax = -1;
- rise = 0.0f;
- }
-
- public void Dispose()
- {
- Debug.Assert(tris[id] == this);
- tris[id] = null;
- }
-
- public int neib(int a, int b)
- {
- int i;
-
- for (i = 0; i < 3; i++)
- {
- int i1 = (i + 1) % 3;
- int i2 = (i + 2) % 3;
- if ((this)[i] == a && (this)[i1] == b)
- return n[i2];
- if ((this)[i] == b && (this)[i1] == a)
- return n[i2];
- }
-
- Debug.Assert(false);
- return -1;
- }
-
- public void setneib(int a, int b, int value)
- {
- int i;
-
- for (i = 0; i < 3; i++)
- {
- int i1 = (i + 1) % 3;
- int i2 = (i + 2) % 3;
- if ((this)[i] == a && (this)[i1] == b)
- {
- n[i2] = value;
- return;
- }
- if ((this)[i] == b && (this)[i1] == a)
- {
- n[i2] = value;
- return;
- }
- }
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/HullUtils.cs b/addon-modules/ConvexDecompositionDotNet/HullUtils.cs
deleted file mode 100644
index c9ccfe2c61..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/HullUtils.cs
+++ /dev/null
@@ -1,1868 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public static class HullUtils
- {
- public static int argmin(float[] a, int n)
- {
- int r = 0;
- for (int i = 1; i < n; i++)
- {
- if (a[i] < a[r])
- {
- r = i;
- }
- }
- return r;
- }
-
- public static float clampf(float a)
- {
- return Math.Min(1.0f, Math.Max(0.0f, a));
- }
-
- public static float Round(float a, float precision)
- {
- return (float)Math.Floor(0.5f + a / precision) * precision;
- }
-
- public static float Interpolate(float f0, float f1, float alpha)
- {
- return f0 * (1 - alpha) + f1 * alpha;
- }
-
- public static void Swap(ref T a, ref T b)
- {
- T tmp = a;
- a = b;
- b = tmp;
- }
-
- public static bool above(List vertices, int3 t, float3 p, float epsilon)
- {
- float3 vtx = vertices[t.x];
- float3 n = TriNormal(vtx, vertices[t.y], vertices[t.z]);
- return (float3.dot(n, p - vtx) > epsilon); // EPSILON???
- }
-
- public static int hasedge(int3 t, int a, int b)
- {
- for (int i = 0; i < 3; i++)
- {
- int i1 = (i + 1) % 3;
- if (t[i] == a && t[i1] == b)
- return 1;
- }
- return 0;
- }
-
- public static bool hasvert(int3 t, int v)
- {
- return (t[0] == v || t[1] == v || t[2] == v);
- }
-
- public static int shareedge(int3 a, int3 b)
- {
- int i;
- for (i = 0; i < 3; i++)
- {
- int i1 = (i + 1) % 3;
- if (hasedge(a, b[i1], b[i]) != 0)
- return 1;
- }
- return 0;
- }
-
- public static void b2bfix(HullTriangle s, HullTriangle t, List tris)
- {
- int i;
- for (i = 0; i < 3; i++)
- {
- int i1 = (i + 1) % 3;
- int i2 = (i + 2) % 3;
- int a = (s)[i1];
- int b = (s)[i2];
- Debug.Assert(tris[s.neib(a, b)].neib(b, a) == s.id);
- Debug.Assert(tris[t.neib(a, b)].neib(b, a) == t.id);
- tris[s.neib(a, b)].setneib(b, a, t.neib(b, a));
- tris[t.neib(b, a)].setneib(a, b, s.neib(a, b));
- }
- }
-
- public static void removeb2b(HullTriangle s, HullTriangle t, List tris)
- {
- b2bfix(s, t, tris);
- s.Dispose();
- t.Dispose();
- }
-
- public static void checkit(HullTriangle t, List tris)
- {
- int i;
- Debug.Assert(tris[t.id] == t);
- for (i = 0; i < 3; i++)
- {
- int i1 = (i + 1) % 3;
- int i2 = (i + 2) % 3;
- int a = (t)[i1];
- int b = (t)[i2];
- Debug.Assert(a != b);
- Debug.Assert(tris[t.n[i]].neib(b, a) == t.id);
- }
- }
-
- public static void extrude(HullTriangle t0, int v, List tris)
- {
- int3 t = t0;
- int n = tris.Count;
- HullTriangle ta = new HullTriangle(v, t[1], t[2], tris);
- ta.n = new int3(t0.n[0], n + 1, n + 2);
- tris[t0.n[0]].setneib(t[1], t[2], n + 0);
- HullTriangle tb = new HullTriangle(v, t[2], t[0], tris);
- tb.n = new int3(t0.n[1], n + 2, n + 0);
- tris[t0.n[1]].setneib(t[2], t[0], n + 1);
- HullTriangle tc = new HullTriangle(v, t[0], t[1], tris);
- tc.n = new int3(t0.n[2], n + 0, n + 1);
- tris[t0.n[2]].setneib(t[0], t[1], n + 2);
- checkit(ta, tris);
- checkit(tb, tris);
- checkit(tc, tris);
- if (hasvert(tris[ta.n[0]], v))
- removeb2b(ta, tris[ta.n[0]], tris);
- if (hasvert(tris[tb.n[0]], v))
- removeb2b(tb, tris[tb.n[0]], tris);
- if (hasvert(tris[tc.n[0]], v))
- removeb2b(tc, tris[tc.n[0]], tris);
- t0.Dispose();
- }
-
- public static HullTriangle extrudable(float epsilon, List tris)
- {
- int i;
- HullTriangle t = null;
- for (i = 0; i < tris.Count; i++)
- {
- if (t == null || (tris.Count > i && (object)tris[i] != null && t.rise < tris[i].rise))
- {
- t = tris[i];
- }
- }
- return (t.rise > epsilon) ? t : null;
- }
-
- public static Quaternion RotationArc(float3 v0, float3 v1)
- {
- Quaternion q = new Quaternion();
- v0 = float3.normalize(v0); // Comment these two lines out if you know its not needed.
- v1 = float3.normalize(v1); // If vector is already unit length then why do it again?
- float3 c = float3.cross(v0, v1);
- float d = float3.dot(v0, v1);
- if (d <= -1.0f) // 180 about x axis
- {
- return new Quaternion(1f, 0f, 0f, 0f);
- }
- float s = (float)Math.Sqrt((1 + d) * 2f);
- q.x = c.x / s;
- q.y = c.y / s;
- q.z = c.z / s;
- q.w = s / 2.0f;
- return q;
- }
-
- public static float3 PlaneLineIntersection(Plane plane, float3 p0, float3 p1)
- {
- // returns the point where the line p0-p1 intersects the plane n&d
- float3 dif = p1 - p0;
- float dn = float3.dot(plane.normal, dif);
- float t = -(plane.dist + float3.dot(plane.normal, p0)) / dn;
- return p0 + (dif * t);
- }
-
- public static float3 LineProject(float3 p0, float3 p1, float3 a)
- {
- float3 w = new float3();
- w = p1 - p0;
- float t = float3.dot(w, (a - p0)) / (w.x * w.x + w.y * w.y + w.z * w.z);
- return p0 + w * t;
- }
-
- public static float3 PlaneProject(Plane plane, float3 point)
- {
- return point - plane.normal * (float3.dot(point, plane.normal) + plane.dist);
- }
-
- public static float LineProjectTime(float3 p0, float3 p1, float3 a)
- {
- float3 w = new float3();
- w = p1 - p0;
- float t = float3.dot(w, (a - p0)) / (w.x * w.x + w.y * w.y + w.z * w.z);
- return t;
- }
-
- public static float3 ThreePlaneIntersection(Plane p0, Plane p1, Plane p2)
- {
- float3x3 mp = float3x3.Transpose(new float3x3(p0.normal, p1.normal, p2.normal));
- float3x3 mi = float3x3.Inverse(mp);
- float3 b = new float3(p0.dist, p1.dist, p2.dist);
- return -b * mi;
- }
-
- public static bool PolyHit(List vert, float3 v0, float3 v1)
- {
- float3 impact = new float3();
- float3 normal = new float3();
- return PolyHit(vert, v0, v1, out impact, out normal);
- }
-
- public static bool PolyHit(List vert, float3 v0, float3 v1, out float3 impact)
- {
- float3 normal = new float3();
- return PolyHit(vert, v0, v1, out impact, out normal);
- }
-
- public static bool PolyHit(List vert, float3 v0, float3 v1, out float3 impact, out float3 normal)
- {
- float3 the_point = new float3();
-
- impact = null;
- normal = null;
-
- int i;
- float3 nrml = new float3(0, 0, 0);
- for (i = 0; i < vert.Count; i++)
- {
- int i1 = (i + 1) % vert.Count;
- int i2 = (i + 2) % vert.Count;
- nrml = nrml + float3.cross(vert[i1] - vert[i], vert[i2] - vert[i1]);
- }
-
- float m = float3.magnitude(nrml);
- if (m == 0.0)
- {
- return false;
- }
- nrml = nrml * (1.0f / m);
- float dist = -float3.dot(nrml, vert[0]);
- float d0;
- float d1;
- if ((d0 = float3.dot(v0, nrml) + dist) < 0 || (d1 = float3.dot(v1, nrml) + dist) > 0)
- {
- return false;
- }
-
- // By using the cached plane distances d0 and d1
- // we can optimize the following:
- // the_point = planelineintersection(nrml,dist,v0,v1);
- float a = d0 / (d0 - d1);
- the_point = v0 * (1 - a) + v1 * a;
-
-
- bool inside = true;
- for (int j = 0; inside && j < vert.Count; j++)
- {
- // let inside = 0 if outside
- float3 pp1 = new float3();
- float3 pp2 = new float3();
- float3 side = new float3();
- pp1 = vert[j];
- pp2 = vert[(j + 1) % vert.Count];
- side = float3.cross((pp2 - pp1), (the_point - pp1));
- inside = (float3.dot(nrml, side) >= 0.0);
- }
- if (inside)
- {
- if (normal != null)
- {
- normal = nrml;
- }
- if (impact != null)
- {
- impact = the_point;
- }
- }
- return inside;
- }
-
- public static bool BoxInside(float3 p, float3 bmin, float3 bmax)
- {
- return (p.x >= bmin.x && p.x <= bmax.x && p.y >= bmin.y && p.y <= bmax.y && p.z >= bmin.z && p.z <= bmax.z);
- }
-
- public static bool BoxIntersect(float3 v0, float3 v1, float3 bmin, float3 bmax, float3 impact)
- {
- if (BoxInside(v0, bmin, bmax))
- {
- impact = v0;
- return true;
- }
- if (v0.x <= bmin.x && v1.x >= bmin.x)
- {
- float a = (bmin.x - v0.x) / (v1.x - v0.x);
- //v.x = bmin.x;
- float vy = (1 - a) * v0.y + a * v1.y;
- float vz = (1 - a) * v0.z + a * v1.z;
- if (vy >= bmin.y && vy <= bmax.y && vz >= bmin.z && vz <= bmax.z)
- {
- impact.x = bmin.x;
- impact.y = vy;
- impact.z = vz;
- return true;
- }
- }
- else if (v0.x >= bmax.x && v1.x <= bmax.x)
- {
- float a = (bmax.x - v0.x) / (v1.x - v0.x);
- //v.x = bmax.x;
- float vy = (1 - a) * v0.y + a * v1.y;
- float vz = (1 - a) * v0.z + a * v1.z;
- if (vy >= bmin.y && vy <= bmax.y && vz >= bmin.z && vz <= bmax.z)
- {
- impact.x = bmax.x;
- impact.y = vy;
- impact.z = vz;
- return true;
- }
- }
- if (v0.y <= bmin.y && v1.y >= bmin.y)
- {
- float a = (bmin.y - v0.y) / (v1.y - v0.y);
- float vx = (1 - a) * v0.x + a * v1.x;
- //v.y = bmin.y;
- float vz = (1 - a) * v0.z + a * v1.z;
- if (vx >= bmin.x && vx <= bmax.x && vz >= bmin.z && vz <= bmax.z)
- {
- impact.x = vx;
- impact.y = bmin.y;
- impact.z = vz;
- return true;
- }
- }
- else if (v0.y >= bmax.y && v1.y <= bmax.y)
- {
- float a = (bmax.y - v0.y) / (v1.y - v0.y);
- float vx = (1 - a) * v0.x + a * v1.x;
- // vy = bmax.y;
- float vz = (1 - a) * v0.z + a * v1.z;
- if (vx >= bmin.x && vx <= bmax.x && vz >= bmin.z && vz <= bmax.z)
- {
- impact.x = vx;
- impact.y = bmax.y;
- impact.z = vz;
- return true;
- }
- }
- if (v0.z <= bmin.z && v1.z >= bmin.z)
- {
- float a = (bmin.z - v0.z) / (v1.z - v0.z);
- float vx = (1 - a) * v0.x + a * v1.x;
- float vy = (1 - a) * v0.y + a * v1.y;
- // v.z = bmin.z;
- if (vy >= bmin.y && vy <= bmax.y && vx >= bmin.x && vx <= bmax.x)
- {
- impact.x = vx;
- impact.y = vy;
- impact.z = bmin.z;
- return true;
- }
- }
- else if (v0.z >= bmax.z && v1.z <= bmax.z)
- {
- float a = (bmax.z - v0.z) / (v1.z - v0.z);
- float vx = (1 - a) * v0.x + a * v1.x;
- float vy = (1 - a) * v0.y + a * v1.y;
- // v.z = bmax.z;
- if (vy >= bmin.y && vy <= bmax.y && vx >= bmin.x && vx <= bmax.x)
- {
- impact.x = vx;
- impact.y = vy;
- impact.z = bmax.z;
- return true;
- }
- }
- return false;
- }
-
- public static float DistanceBetweenLines(float3 ustart, float3 udir, float3 vstart, float3 vdir, float3 upoint)
- {
- return DistanceBetweenLines(ustart, udir, vstart, vdir, upoint, null);
- }
-
- public static float DistanceBetweenLines(float3 ustart, float3 udir, float3 vstart, float3 vdir)
- {
- return DistanceBetweenLines(ustart, udir, vstart, vdir, null, null);
- }
-
- public static float DistanceBetweenLines(float3 ustart, float3 udir, float3 vstart, float3 vdir, float3 upoint, float3 vpoint)
- {
- float3 cp = float3.normalize(float3.cross(udir, vdir));
-
- float distu = -float3.dot(cp, ustart);
- float distv = -float3.dot(cp, vstart);
- float dist = (float)Math.Abs(distu - distv);
- if (upoint != null)
- {
- Plane plane = new Plane();
- plane.normal = float3.normalize(float3.cross(vdir, cp));
- plane.dist = -float3.dot(plane.normal, vstart);
- upoint = PlaneLineIntersection(plane, ustart, ustart + udir);
- }
- if (vpoint != null)
- {
- Plane plane = new Plane();
- plane.normal = float3.normalize(float3.cross(udir, cp));
- plane.dist = -float3.dot(plane.normal, ustart);
- vpoint = PlaneLineIntersection(plane, vstart, vstart + vdir);
- }
- return dist;
- }
-
- public static float3 TriNormal(float3 v0, float3 v1, float3 v2)
- {
- // return the normal of the triangle
- // inscribed by v0, v1, and v2
- float3 cp = float3.cross(v1 - v0, v2 - v1);
- float m = float3.magnitude(cp);
- if (m == 0)
- return new float3(1, 0, 0);
- return cp * (1.0f / m);
- }
-
- public static int PlaneTest(Plane p, float3 v, float planetestepsilon)
- {
- float a = float3.dot(v, p.normal) + p.dist;
- int flag = (a > planetestepsilon) ? (2) : ((a < -planetestepsilon) ? (1) : (0));
- return flag;
- }
-
- public static int SplitTest(ref ConvexH convex, Plane plane, float planetestepsilon)
- {
- int flag = 0;
- for (int i = 0; i < convex.vertices.Count; i++)
- {
- flag |= PlaneTest(plane, convex.vertices[i], planetestepsilon);
- }
- return flag;
- }
-
- public static Quaternion VirtualTrackBall(float3 cop, float3 cor, float3 dir1, float3 dir2)
- {
- // routine taken from game programming gems.
- // Implement track ball functionality to spin stuf on the screen
- // cop center of projection
- // cor center of rotation
- // dir1 old mouse direction
- // dir2 new mouse direction
- // pretend there is a sphere around cor. Then find the points
- // where dir1 and dir2 intersect that sphere. Find the
- // rotation that takes the first point to the second.
- float m;
- // compute plane
- float3 nrml = cor - cop;
- float fudgefactor = 1.0f / (float3.magnitude(nrml) * 0.25f); // since trackball proportional to distance from cop
- nrml = float3.normalize(nrml);
- float dist = -float3.dot(nrml, cor);
- float3 u = PlaneLineIntersection(new Plane(nrml, dist), cop, cop + dir1);
- u = u - cor;
- u = u * fudgefactor;
- m = float3.magnitude(u);
- if (m > 1)
- {
- u /= m;
- }
- else
- {
- u = u - (nrml * (float)Math.Sqrt(1 - m * m));
- }
- float3 v = PlaneLineIntersection(new Plane(nrml, dist), cop, cop + dir2);
- v = v - cor;
- v = v * fudgefactor;
- m = float3.magnitude(v);
- if (m > 1)
- {
- v /= m;
- }
- else
- {
- v = v - (nrml * (float)Math.Sqrt(1 - m * m));
- }
- return RotationArc(u, v);
- }
-
- public static bool AssertIntact(ConvexH convex, float planetestepsilon)
- {
- int i;
- int estart = 0;
- for (i = 0; i < convex.edges.Count; i++)
- {
- if (convex.edges[estart].p != convex.edges[i].p)
- {
- estart = i;
- }
- int inext = i + 1;
- if (inext >= convex.edges.Count || convex.edges[inext].p != convex.edges[i].p)
- {
- inext = estart;
- }
- Debug.Assert(convex.edges[inext].p == convex.edges[i].p);
- int nb = convex.edges[i].ea;
- Debug.Assert(nb != 255);
- if (nb == 255 || nb == -1)
- return false;
- Debug.Assert(nb != -1);
- Debug.Assert(i == convex.edges[nb].ea);
- }
- for (i = 0; i < convex.edges.Count; i++)
- {
- Debug.Assert((0) == PlaneTest(convex.facets[convex.edges[i].p], convex.vertices[convex.edges[i].v], planetestepsilon));
- if ((0) != PlaneTest(convex.facets[convex.edges[i].p], convex.vertices[convex.edges[i].v], planetestepsilon))
- return false;
- if (convex.edges[estart].p != convex.edges[i].p)
- {
- estart = i;
- }
- int i1 = i + 1;
- if (i1 >= convex.edges.Count || convex.edges[i1].p != convex.edges[i].p)
- {
- i1 = estart;
- }
- int i2 = i1 + 1;
- if (i2 >= convex.edges.Count || convex.edges[i2].p != convex.edges[i].p)
- {
- i2 = estart;
- }
- if (i == i2) // i sliced tangent to an edge and created 2 meaningless edges
- continue;
- float3 localnormal = TriNormal(convex.vertices[convex.edges[i].v], convex.vertices[convex.edges[i1].v], convex.vertices[convex.edges[i2].v]);
- Debug.Assert(float3.dot(localnormal, convex.facets[convex.edges[i].p].normal) > 0);
- if (float3.dot(localnormal, convex.facets[convex.edges[i].p].normal) <= 0)
- return false;
- }
- return true;
- }
-
- public static ConvexH test_btbq(float planetestepsilon)
- {
- // back to back quads
- ConvexH convex = new ConvexH(4, 8, 2);
- convex.vertices[0] = new float3(0, 0, 0);
- convex.vertices[1] = new float3(1, 0, 0);
- convex.vertices[2] = new float3(1, 1, 0);
- convex.vertices[3] = new float3(0, 1, 0);
- convex.facets[0] = new Plane(new float3(0, 0, 1), 0);
- convex.facets[1] = new Plane(new float3(0, 0, -1), 0);
- convex.edges[0] = new ConvexH.HalfEdge(7, 0, 0);
- convex.edges[1] = new ConvexH.HalfEdge(6, 1, 0);
- convex.edges[2] = new ConvexH.HalfEdge(5, 2, 0);
- convex.edges[3] = new ConvexH.HalfEdge(4, 3, 0);
-
- convex.edges[4] = new ConvexH.HalfEdge(3, 0, 1);
- convex.edges[5] = new ConvexH.HalfEdge(2, 3, 1);
- convex.edges[6] = new ConvexH.HalfEdge(1, 2, 1);
- convex.edges[7] = new ConvexH.HalfEdge(0, 1, 1);
- AssertIntact(convex, planetestepsilon);
- return convex;
- }
-
- public static ConvexH test_cube()
- {
- ConvexH convex = new ConvexH(8, 24, 6);
- convex.vertices[0] = new float3(0, 0, 0);
- convex.vertices[1] = new float3(0, 0, 1);
- convex.vertices[2] = new float3(0, 1, 0);
- convex.vertices[3] = new float3(0, 1, 1);
- convex.vertices[4] = new float3(1, 0, 0);
- convex.vertices[5] = new float3(1, 0, 1);
- convex.vertices[6] = new float3(1, 1, 0);
- convex.vertices[7] = new float3(1, 1, 1);
-
- convex.facets[0] = new Plane(new float3(-1, 0, 0), 0);
- convex.facets[1] = new Plane(new float3(1, 0, 0), -1);
- convex.facets[2] = new Plane(new float3(0, -1, 0), 0);
- convex.facets[3] = new Plane(new float3(0, 1, 0), -1);
- convex.facets[4] = new Plane(new float3(0, 0, -1), 0);
- convex.facets[5] = new Plane(new float3(0, 0, 1), -1);
-
- convex.edges[0] = new ConvexH.HalfEdge(11, 0, 0);
- convex.edges[1] = new ConvexH.HalfEdge(23, 1, 0);
- convex.edges[2] = new ConvexH.HalfEdge(15, 3, 0);
- convex.edges[3] = new ConvexH.HalfEdge(16, 2, 0);
-
- convex.edges[4] = new ConvexH.HalfEdge(13, 6, 1);
- convex.edges[5] = new ConvexH.HalfEdge(21, 7, 1);
- convex.edges[6] = new ConvexH.HalfEdge(9, 5, 1);
- convex.edges[7] = new ConvexH.HalfEdge(18, 4, 1);
-
- convex.edges[8] = new ConvexH.HalfEdge(19, 0, 2);
- convex.edges[9] = new ConvexH.HalfEdge(6, 4, 2);
- convex.edges[10] = new ConvexH.HalfEdge(20, 5, 2);
- convex.edges[11] = new ConvexH.HalfEdge(0, 1, 2);
-
- convex.edges[12] = new ConvexH.HalfEdge(22, 3, 3);
- convex.edges[13] = new ConvexH.HalfEdge(4, 7, 3);
- convex.edges[14] = new ConvexH.HalfEdge(17, 6, 3);
- convex.edges[15] = new ConvexH.HalfEdge(2, 2, 3);
-
- convex.edges[16] = new ConvexH.HalfEdge(3, 0, 4);
- convex.edges[17] = new ConvexH.HalfEdge(14, 2, 4);
- convex.edges[18] = new ConvexH.HalfEdge(7, 6, 4);
- convex.edges[19] = new ConvexH.HalfEdge(8, 4, 4);
-
- convex.edges[20] = new ConvexH.HalfEdge(10, 1, 5);
- convex.edges[21] = new ConvexH.HalfEdge(5, 5, 5);
- convex.edges[22] = new ConvexH.HalfEdge(12, 7, 5);
- convex.edges[23] = new ConvexH.HalfEdge(1, 3, 5);
-
- return convex;
- }
-
- public static ConvexH ConvexHMakeCube(float3 bmin, float3 bmax)
- {
- ConvexH convex = test_cube();
- convex.vertices[0] = new float3(bmin.x, bmin.y, bmin.z);
- convex.vertices[1] = new float3(bmin.x, bmin.y, bmax.z);
- convex.vertices[2] = new float3(bmin.x, bmax.y, bmin.z);
- convex.vertices[3] = new float3(bmin.x, bmax.y, bmax.z);
- convex.vertices[4] = new float3(bmax.x, bmin.y, bmin.z);
- convex.vertices[5] = new float3(bmax.x, bmin.y, bmax.z);
- convex.vertices[6] = new float3(bmax.x, bmax.y, bmin.z);
- convex.vertices[7] = new float3(bmax.x, bmax.y, bmax.z);
-
- convex.facets[0] = new Plane(new float3(-1, 0, 0), bmin.x);
- convex.facets[1] = new Plane(new float3(1, 0, 0), -bmax.x);
- convex.facets[2] = new Plane(new float3(0, -1, 0), bmin.y);
- convex.facets[3] = new Plane(new float3(0, 1, 0), -bmax.y);
- convex.facets[4] = new Plane(new float3(0, 0, -1), bmin.z);
- convex.facets[5] = new Plane(new float3(0, 0, 1), -bmax.z);
- return convex;
- }
-
- public static ConvexH ConvexHCrop(ref ConvexH convex, Plane slice, float planetestepsilon)
- {
- int i;
- int vertcountunder = 0;
- int vertcountover = 0;
- List vertscoplanar = new List(); // existing vertex members of convex that are coplanar
- List edgesplit = new List(); // existing edges that members of convex that cross the splitplane
-
- Debug.Assert(convex.edges.Count < 480);
-
- EdgeFlag[] edgeflag = new EdgeFlag[512];
- VertFlag[] vertflag = new VertFlag[256];
- PlaneFlag[] planeflag = new PlaneFlag[128];
- ConvexH.HalfEdge[] tmpunderedges = new ConvexH.HalfEdge[512];
- Plane[] tmpunderplanes = new Plane[128];
- Coplanar[] coplanaredges = new Coplanar[512];
- int coplanaredges_num = 0;
-
- List createdverts = new List();
-
- // do the side-of-plane tests
- for (i = 0; i < convex.vertices.Count; i++)
- {
- vertflag[i].planetest = (byte)PlaneTest(slice, convex.vertices[i], planetestepsilon);
- if (vertflag[i].planetest == (0))
- {
- // ? vertscoplanar.Add(i);
- vertflag[i].undermap = (byte)vertcountunder++;
- vertflag[i].overmap = (byte)vertcountover++;
- }
- else if (vertflag[i].planetest == (1))
- {
- vertflag[i].undermap = (byte)vertcountunder++;
- }
- else
- {
- Debug.Assert(vertflag[i].planetest == (2));
- vertflag[i].overmap = (byte)vertcountover++;
- vertflag[i].undermap = 255; // for debugging purposes
- }
- }
- int vertcountunderold = vertcountunder; // for debugging only
-
- int under_edge_count = 0;
- int underplanescount = 0;
- int e0 = 0;
-
- for (int currentplane = 0; currentplane < convex.facets.Count; currentplane++)
- {
- int estart = e0;
- int enextface = 0;
- int planeside = 0;
- int e1 = e0 + 1;
- int vout = -1;
- int vin = -1;
- int coplanaredge = -1;
- do
- {
-
- if (e1 >= convex.edges.Count || convex.edges[e1].p != currentplane)
- {
- enextface = e1;
- e1 = estart;
- }
- ConvexH.HalfEdge edge0 = convex.edges[e0];
- ConvexH.HalfEdge edge1 = convex.edges[e1];
- ConvexH.HalfEdge edgea = convex.edges[edge0.ea];
-
- planeside |= vertflag[edge0.v].planetest;
- //if((vertflag[edge0.v].planetest & vertflag[edge1.v].planetest) == COPLANAR) {
- // assert(ecop==-1);
- // ecop=e;
- //}
-
- if (vertflag[edge0.v].planetest == (2) && vertflag[edge1.v].planetest == (2))
- {
- // both endpoints over plane
- edgeflag[e0].undermap = -1;
- }
- else if ((vertflag[edge0.v].planetest | vertflag[edge1.v].planetest) == (1))
- {
- // at least one endpoint under, the other coplanar or under
-
- edgeflag[e0].undermap = (short)under_edge_count;
- tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap;
- tmpunderedges[under_edge_count].p = (byte)underplanescount;
- if (edge0.ea < e0)
- {
- // connect the neighbors
- Debug.Assert(edgeflag[edge0.ea].undermap != -1);
- tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap;
- tmpunderedges[edgeflag[edge0.ea].undermap].ea = (short)under_edge_count;
- }
- under_edge_count++;
- }
- else if ((vertflag[edge0.v].planetest | vertflag[edge1.v].planetest) == (0))
- {
- // both endpoints coplanar
- // must check a 3rd point to see if UNDER
- int e2 = e1 + 1;
- if (e2 >= convex.edges.Count || convex.edges[e2].p != currentplane)
- {
- e2 = estart;
- }
- Debug.Assert(convex.edges[e2].p == currentplane);
- ConvexH.HalfEdge edge2 = convex.edges[e2];
- if (vertflag[edge2.v].planetest == (1))
- {
-
- edgeflag[e0].undermap = (short)under_edge_count;
- tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap;
- tmpunderedges[under_edge_count].p = (byte)underplanescount;
- tmpunderedges[under_edge_count].ea = -1;
- // make sure this edge is added to the "coplanar" list
- coplanaredge = under_edge_count;
- vout = vertflag[edge0.v].undermap;
- vin = vertflag[edge1.v].undermap;
- under_edge_count++;
- }
- else
- {
- edgeflag[e0].undermap = -1;
- }
- }
- else if (vertflag[edge0.v].planetest == (1) && vertflag[edge1.v].planetest == (2))
- {
- // first is under 2nd is over
-
- edgeflag[e0].undermap = (short)under_edge_count;
- tmpunderedges[under_edge_count].v = vertflag[edge0.v].undermap;
- tmpunderedges[under_edge_count].p = (byte)underplanescount;
- if (edge0.ea < e0)
- {
- Debug.Assert(edgeflag[edge0.ea].undermap != -1);
- // connect the neighbors
- tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap;
- tmpunderedges[edgeflag[edge0.ea].undermap].ea = (short)under_edge_count;
- vout = tmpunderedges[edgeflag[edge0.ea].undermap].v;
- }
- else
- {
- Plane p0 = convex.facets[edge0.p];
- Plane pa = convex.facets[edgea.p];
- createdverts.Add(ThreePlaneIntersection(p0, pa, slice));
- //createdverts.Add(PlaneProject(slice,PlaneLineIntersection(slice,convex.vertices[edge0.v],convex.vertices[edgea.v])));
- //createdverts.Add(PlaneLineIntersection(slice,convex.vertices[edge0.v],convex.vertices[edgea.v]));
- vout = vertcountunder++;
- }
- under_edge_count++;
- /// hmmm something to think about: i might be able to output this edge regarless of
- // wheter or not we know v-in yet. ok i;ll try this now:
- tmpunderedges[under_edge_count].v = (byte)vout;
- tmpunderedges[under_edge_count].p = (byte)underplanescount;
- tmpunderedges[under_edge_count].ea = -1;
- coplanaredge = under_edge_count;
- under_edge_count++;
-
- if (vin != -1)
- {
- // we previously processed an edge where we came under
- // now we know about vout as well
-
- // ADD THIS EDGE TO THE LIST OF EDGES THAT NEED NEIGHBOR ON PARTITION PLANE!!
- }
-
- }
- else if (vertflag[edge0.v].planetest == (0) && vertflag[edge1.v].planetest == (2))
- {
- // first is coplanar 2nd is over
-
- edgeflag[e0].undermap = -1;
- vout = vertflag[edge0.v].undermap;
- // I hate this but i have to make sure part of this face is UNDER before ouputting this vert
- int k = estart;
- Debug.Assert(edge0.p == currentplane);
- while (!((planeside & 1) != 0) && k < convex.edges.Count && convex.edges[k].p == edge0.p)
- {
- planeside |= vertflag[convex.edges[k].v].planetest;
- k++;
- }
- if ((planeside & 1) != 0)
- {
- tmpunderedges[under_edge_count].v = (byte)vout;
- tmpunderedges[under_edge_count].p = (byte)underplanescount;
- tmpunderedges[under_edge_count].ea = -1;
- coplanaredge = under_edge_count; // hmmm should make a note of the edge # for later on
- under_edge_count++;
-
- }
- }
- else if (vertflag[edge0.v].planetest == (2) && vertflag[edge1.v].planetest == (1))
- {
- // first is over next is under
- // new vertex!!!
- Debug.Assert(vin == -1);
- if (e0 < edge0.ea)
- {
- Plane p0 = convex.facets[edge0.p];
- Plane pa = convex.facets[edgea.p];
- createdverts.Add(ThreePlaneIntersection(p0, pa, slice));
- //createdverts.Add(PlaneLineIntersection(slice,convex.vertices[edge0.v],convex.vertices[edgea.v]));
- //createdverts.Add(PlaneProject(slice,PlaneLineIntersection(slice,convex.vertices[edge0.v],convex.vertices[edgea.v])));
- vin = vertcountunder++;
- }
- else
- {
- // find the new vertex that was created by edge[edge0.ea]
- int nea = edgeflag[edge0.ea].undermap;
- Debug.Assert(tmpunderedges[nea].p == tmpunderedges[nea + 1].p);
- vin = tmpunderedges[nea + 1].v;
- Debug.Assert(vin < vertcountunder);
- Debug.Assert(vin >= vertcountunderold); // for debugging only
- }
- if (vout != -1)
- {
- // we previously processed an edge where we went over
- // now we know vin too
- // ADD THIS EDGE TO THE LIST OF EDGES THAT NEED NEIGHBOR ON PARTITION PLANE!!
- }
- // output edge
- tmpunderedges[under_edge_count].v = (byte)vin;
- tmpunderedges[under_edge_count].p = (byte)underplanescount;
- edgeflag[e0].undermap = (short)under_edge_count;
- if (e0 > edge0.ea)
- {
- Debug.Assert(edgeflag[edge0.ea].undermap != -1);
- // connect the neighbors
- tmpunderedges[under_edge_count].ea = edgeflag[edge0.ea].undermap;
- tmpunderedges[edgeflag[edge0.ea].undermap].ea = (short)under_edge_count;
- }
- Debug.Assert(edgeflag[e0].undermap == under_edge_count);
- under_edge_count++;
- }
- else if (vertflag[edge0.v].planetest == (2) && vertflag[edge1.v].planetest == (0))
- {
- // first is over next is coplanar
-
- edgeflag[e0].undermap = -1;
- vin = vertflag[edge1.v].undermap;
- Debug.Assert(vin != -1);
- if (vout != -1)
- {
- // we previously processed an edge where we came under
- // now we know both endpoints
- // ADD THIS EDGE TO THE LIST OF EDGES THAT NEED NEIGHBOR ON PARTITION PLANE!!
- }
-
- }
- else
- {
- Debug.Assert(false);
- }
-
-
- e0 = e1;
- e1++; // do the modulo at the beginning of the loop
-
- } while (e0 != estart);
- e0 = enextface;
- if ((planeside & 1) != 0)
- {
- planeflag[currentplane].undermap = (byte)underplanescount;
- tmpunderplanes[underplanescount] = convex.facets[currentplane];
- underplanescount++;
- }
- else
- {
- planeflag[currentplane].undermap = 0;
- }
- if (vout >= 0 && (planeside & 1) != 0)
- {
- Debug.Assert(vin >= 0);
- Debug.Assert(coplanaredge >= 0);
- Debug.Assert(coplanaredge != 511);
- coplanaredges[coplanaredges_num].ea = (ushort)coplanaredge;
- coplanaredges[coplanaredges_num].v0 = (byte)vin;
- coplanaredges[coplanaredges_num].v1 = (byte)vout;
- coplanaredges_num++;
- }
- }
-
- // add the new plane to the mix:
- if (coplanaredges_num > 0)
- {
- tmpunderplanes[underplanescount++] = slice;
- }
- for (i = 0; i < coplanaredges_num - 1; i++)
- {
- if (coplanaredges[i].v1 != coplanaredges[i + 1].v0)
- {
- int j = 0;
- for (j = i + 2; j < coplanaredges_num; j++)
- {
- if (coplanaredges[i].v1 == coplanaredges[j].v0)
- {
- Coplanar tmp = coplanaredges[i + 1];
- coplanaredges[i + 1] = coplanaredges[j];
- coplanaredges[j] = tmp;
- break;
- }
- }
- if (j >= coplanaredges_num)
- {
- Debug.Assert(j < coplanaredges_num);
- return null;
- }
- }
- }
-
- ConvexH punder = new ConvexH(vertcountunder, under_edge_count + coplanaredges_num, underplanescount);
- ConvexH under = punder;
-
- {
- int k = 0;
- for (i = 0; i < convex.vertices.Count; i++)
- {
- if (vertflag[i].planetest != (2))
- {
- under.vertices[k++] = convex.vertices[i];
- }
- }
- i = 0;
- while (k < vertcountunder)
- {
- under.vertices[k++] = createdverts[i++];
- }
- Debug.Assert(i == createdverts.Count);
- }
-
- for (i = 0; i < coplanaredges_num; i++)
- {
- ConvexH.HalfEdge edge = under.edges[under_edge_count + i];
- edge.p = (byte)(underplanescount - 1);
- edge.ea = (short)coplanaredges[i].ea;
- edge.v = (byte)coplanaredges[i].v0;
- under.edges[under_edge_count + i] = edge;
-
- tmpunderedges[coplanaredges[i].ea].ea = (short)(under_edge_count + i);
- }
-
- under.edges = new List(tmpunderedges);
- under.facets = new List(tmpunderplanes);
- return punder;
- }
-
- public static ConvexH ConvexHDup(ConvexH src)
- {
- ConvexH dst = new ConvexH(src.vertices.Count, src.edges.Count, src.facets.Count);
- dst.vertices = new List(src.vertices.Count);
- foreach (float3 f in src.vertices)
- dst.vertices.Add(new float3(f));
- dst.edges = new List(src.edges.Count);
- foreach (ConvexH.HalfEdge e in src.edges)
- dst.edges.Add(new ConvexH.HalfEdge(e));
- dst.facets = new List(src.facets.Count);
- foreach (Plane p in src.facets)
- dst.facets.Add(new Plane(p));
- return dst;
- }
-
- public static int candidateplane(List planes, int planes_count, ConvexH convex, float epsilon)
- {
- int p = 0;
- float md = 0;
- int i;
- for (i = 0; i < planes_count; i++)
- {
- float d = 0;
- for (int j = 0; j < convex.vertices.Count; j++)
- {
- d = Math.Max(d, float3.dot(convex.vertices[j], planes[i].normal) + planes[i].dist);
- }
- if (i == 0 || d > md)
- {
- p = i;
- md = d;
- }
- }
- return (md > epsilon) ? p : -1;
- }
-
- public static float3 orth(float3 v)
- {
- float3 a = float3.cross(v, new float3(0f, 0f, 1f));
- float3 b = float3.cross(v, new float3(0f, 1f, 0f));
- return float3.normalize((float3.magnitude(a) > float3.magnitude(b)) ? a : b);
- }
-
- public static int maxdir(List p, int count, float3 dir)
- {
- Debug.Assert(count != 0);
- int m = 0;
- float currDotm = float3.dot(p[0], dir);
- for (int i = 1; i < count; i++)
- {
- float currDoti = float3.dot(p[i], dir);
- if (currDoti > currDotm)
- {
- currDotm = currDoti;
- m = i;
- }
- }
- return m;
- }
-
- public static int maxdirfiltered(List p, int count, float3 dir, byte[] allow)
- {
- //Debug.Assert(count != 0);
- int m = 0;
- float currDotm = float3.dot(p[0], dir);
- float currDoti;
-
- while (allow[m] == 0)
- m++;
-
- for (int i = 1; i < count; i++)
- {
- if (allow[i] != 0)
- {
- currDoti = float3.dot(p[i], dir);
- if (currDoti > currDotm)
- {
- currDotm = currDoti;
- m = i;
- }
- }
- }
- //Debug.Assert(m != -1);
- return m;
- }
-
- public static int maxdirsterid(List p, int count, float3 dir, byte[] allow)
- {
- int m = -1;
- while (m == -1)
- {
- m = maxdirfiltered(p, count, dir, allow);
- if (allow[m] == 3)
- return m;
- float3 u = orth(dir);
- float3 v = float3.cross(u, dir);
- int ma = -1;
- for (float x = 0.0f; x <= 360.0f; x += 45.0f)
- {
- int mb;
- {
- float s = (float)Math.Sin((3.14159264f / 180.0f) * (x));
- float c = (float)Math.Cos((3.14159264f / 180.0f) * (x));
- mb = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow);
- }
- if (ma == m && mb == m)
- {
- allow[m] = 3;
- return m;
- }
- if (ma != -1 && ma != mb) // Yuck - this is really ugly
- {
- int mc = ma;
- for (float xx = x - 40.0f; xx <= x; xx += 5.0f)
- {
- float s = (float)Math.Sin((3.14159264f / 180.0f) * (xx));
- float c = (float)Math.Cos((3.14159264f / 180.0f) * (xx));
- int md = maxdirfiltered(p, count, dir + (u * s + v * c) * 0.025f, allow);
- if (mc == m && md == m)
- {
- allow[m] = 3;
- return m;
- }
- mc = md;
- }
- }
- ma = mb;
- }
- allow[m] = 0;
- m = -1;
- }
-
- Debug.Assert(false);
- return m;
- }
-
- public static int4 FindSimplex(List verts, byte[] allow)
- {
- float3[] basis = new float3[3];
- basis[0] = new float3(0.01f, 0.02f, 1.0f);
- int p0 = maxdirsterid(verts, verts.Count, basis[0], allow);
- int p1 = maxdirsterid(verts, verts.Count, -basis[0], allow);
- basis[0] = verts[p0] - verts[p1];
- if (p0 == p1 || basis[0] == new float3(0, 0, 0))
- return new int4(-1, -1, -1, -1);
- basis[1] = float3.cross(new float3(1, 0.02f, 0), basis[0]);
- basis[2] = float3.cross(new float3(-0.02f, 1, 0), basis[0]);
- basis[1] = float3.normalize((float3.magnitude(basis[1]) > float3.magnitude(basis[2])) ? basis[1] : basis[2]);
- int p2 = maxdirsterid(verts, verts.Count, basis[1], allow);
- if (p2 == p0 || p2 == p1)
- {
- p2 = maxdirsterid(verts, verts.Count, -basis[1], allow);
- }
- if (p2 == p0 || p2 == p1)
- return new int4(-1, -1, -1, -1);
- basis[1] = verts[p2] - verts[p0];
- basis[2] = float3.normalize(float3.cross(basis[1], basis[0]));
- int p3 = maxdirsterid(verts, verts.Count, basis[2], allow);
- if (p3 == p0 || p3 == p1 || p3 == p2)
- p3 = maxdirsterid(verts, verts.Count, -basis[2], allow);
- if (p3 == p0 || p3 == p1 || p3 == p2)
- return new int4(-1, -1, -1, -1);
- Debug.Assert(!(p0 == p1 || p0 == p2 || p0 == p3 || p1 == p2 || p1 == p3 || p2 == p3));
- if (float3.dot(verts[p3] - verts[p0], float3.cross(verts[p1] - verts[p0], verts[p2] - verts[p0])) < 0)
- {
- Swap(ref p2, ref p3);
- }
- return new int4(p0, p1, p2, p3);
- }
-
- public static float GetDist(float px, float py, float pz, float3 p2)
- {
- float dx = px - p2.x;
- float dy = py - p2.y;
- float dz = pz - p2.z;
-
- return dx * dx + dy * dy + dz * dz;
- }
-
- public static void ReleaseHull(PHullResult result)
- {
- if (result.Indices != null)
- result.Indices = null;
- if (result.Vertices != null)
- result.Vertices = null;
- }
-
- public static int calchullgen(List verts, int vlimit, List tris)
- {
- if (verts.Count < 4)
- return 0;
- if (vlimit == 0)
- vlimit = 1000000000;
- int j;
- float3 bmin = new float3(verts[0]);
- float3 bmax = new float3(verts[0]);
- List isextreme = new List(verts.Count);
- byte[] allow = new byte[verts.Count];
- for (j = 0; j < verts.Count; j++)
- {
- allow[j] = 1;
- isextreme.Add(0);
- bmin = float3.VectorMin(bmin, verts[j]);
- bmax = float3.VectorMax(bmax, verts[j]);
- }
- float epsilon = float3.magnitude(bmax - bmin) * 0.001f;
-
- int4 p = FindSimplex(verts, allow);
- if (p.x == -1) // simplex failed
- return 0;
-
- float3 center = (verts[p[0]] + verts[p[1]] + verts[p[2]] + verts[p[3]]) / 4.0f; // a valid interior point
- HullTriangle t0 = new HullTriangle(p[2], p[3], p[1], tris);
- t0.n = new int3(2, 3, 1);
- HullTriangle t1 = new HullTriangle(p[3], p[2], p[0], tris);
- t1.n = new int3(3, 2, 0);
- HullTriangle t2 = new HullTriangle(p[0], p[1], p[3], tris);
- t2.n = new int3(0, 1, 3);
- HullTriangle t3 = new HullTriangle(p[1], p[0], p[2], tris);
- t3.n = new int3(1, 0, 2);
- isextreme[p[0]] = isextreme[p[1]] = isextreme[p[2]] = isextreme[p[3]] = 1;
- checkit(t0, tris);
- checkit(t1, tris);
- checkit(t2, tris);
- checkit(t3, tris);
-
- for (j = 0; j < tris.Count; j++)
- {
- HullTriangle t = tris[j];
- Debug.Assert((object)t != null);
- Debug.Assert(t.vmax < 0);
- float3 n = TriNormal(verts[(t)[0]], verts[(t)[1]], verts[(t)[2]]);
- t.vmax = maxdirsterid(verts, verts.Count, n, allow);
- t.rise = float3.dot(n, verts[t.vmax] - verts[(t)[0]]);
- }
- HullTriangle te;
- vlimit -= 4;
- while (vlimit > 0 && (te = extrudable(epsilon, tris)) != null)
- {
- int3 ti = te;
- int v = te.vmax;
- Debug.Assert(isextreme[v] == 0); // wtf we've already done this vertex
- isextreme[v] = 1;
- //if(v==p0 || v==p1 || v==p2 || v==p3) continue; // done these already
- j = tris.Count;
- while (j-- != 0)
- {
- if (tris.Count <= j || (object)tris[j] == null)
- continue;
- int3 t = tris[j];
- if (above(verts, t, verts[v], 0.01f * epsilon))
- {
- extrude(tris[j], v, tris);
- }
- }
- // now check for those degenerate cases where we have a flipped triangle or a really skinny triangle
- j = tris.Count;
- while (j-- != 0)
- {
- if (tris.Count <= j || (object)tris[j] == null)
- continue;
- if (!hasvert(tris[j], v))
- break;
- int3 nt = tris[j];
- if (above(verts, nt, center, 0.01f * epsilon) || float3.magnitude(float3.cross(verts[nt[1]] - verts[nt[0]], verts[nt[2]] - verts[nt[1]])) < epsilon * epsilon * 0.1f)
- {
- HullTriangle nb = tris[tris[j].n[0]];
- Debug.Assert(nb != null);
- Debug.Assert(!hasvert(nb, v));
- Debug.Assert(nb.id < j);
- extrude(nb, v, tris);
- j = tris.Count;
- }
- }
- j = tris.Count;
- while (j-- != 0)
- {
- HullTriangle t = tris[j];
- if (t == null)
- continue;
- if (t.vmax >= 0)
- break;
- float3 n = TriNormal(verts[(t)[0]], verts[(t)[1]], verts[(t)[2]]);
- t.vmax = maxdirsterid(verts, verts.Count, n, allow);
- if (isextreme[t.vmax] != 0)
- {
- t.vmax = -1; // already done that vertex - algorithm needs to be able to terminate.
- }
- else
- {
- t.rise = float3.dot(n, verts[t.vmax] - verts[(t)[0]]);
- }
- }
- vlimit--;
- }
- return 1;
- }
-
- public static bool calchull(List verts, out List tris_out, int vlimit, List tris)
- {
- tris_out = null;
-
- int rc = calchullgen(verts, vlimit, tris);
- if (rc == 0)
- return false;
- List ts = new List();
- for (int i = 0; i < tris.Count; i++)
- {
- if ((object)tris[i] != null)
- {
- for (int j = 0; j < 3; j++)
- ts.Add((tris[i])[j]);
- tris[i] = null;
- }
- }
-
- tris_out = ts;
- tris.Clear();
- return true;
- }
-
- public static int calchullpbev(List verts, int vlimit, out List planes, float bevangle, List tris)
- {
- int i;
- int j;
- planes = new List();
- int rc = calchullgen(verts, vlimit, tris);
- if (rc == 0)
- return 0;
- for (i = 0; i < tris.Count; i++)
- {
- if (tris[i] != null)
- {
- Plane p = new Plane();
- HullTriangle t = tris[i];
- p.normal = TriNormal(verts[(t)[0]], verts[(t)[1]], verts[(t)[2]]);
- p.dist = -float3.dot(p.normal, verts[(t)[0]]);
- planes.Add(p);
- for (j = 0; j < 3; j++)
- {
- if (t.n[j] < t.id)
- continue;
- HullTriangle s = tris[t.n[j]];
- float3 snormal = TriNormal(verts[(s)[0]], verts[(s)[1]], verts[(s)[2]]);
- if (float3.dot(snormal, p.normal) >= Math.Cos(bevangle * (3.14159264f / 180.0f)))
- continue;
- float3 n = float3.normalize(snormal + p.normal);
- planes.Add(new Plane(n, -float3.dot(n, verts[maxdir(verts, verts.Count, n)])));
- }
- }
- }
-
- tris.Clear();
- return 1;
- }
-
- public static int overhull(List planes, List verts, int maxplanes, out List verts_out, out List faces_out, float inflate)
- {
- verts_out = null;
- faces_out = null;
-
- int i;
- int j;
- if (verts.Count < 4)
- return 0;
- maxplanes = Math.Min(maxplanes, planes.Count);
- float3 bmin = new float3(verts[0]);
- float3 bmax = new float3(verts[0]);
- for (i = 0; i < verts.Count; i++)
- {
- bmin = float3.VectorMin(bmin, verts[i]);
- bmax = float3.VectorMax(bmax, verts[i]);
- }
- // float diameter = magnitude(bmax-bmin);
- // inflate *=diameter; // RELATIVE INFLATION
- bmin -= new float3(inflate, inflate, inflate);
- bmax += new float3(inflate, inflate, inflate);
- for (i = 0; i < planes.Count; i++)
- {
- planes[i].dist -= inflate;
- }
- float3 emin = new float3(bmin);
- float3 emax = new float3(bmax);
- float epsilon = float3.magnitude(emax - emin) * 0.025f;
- float planetestepsilon = float3.magnitude(emax - emin) * (0.001f);
- // todo: add bounding cube planes to force bevel. or try instead not adding the diameter expansion ??? must think.
- // ConvexH *convex = ConvexHMakeCube(bmin - float3(diameter,diameter,diameter),bmax+float3(diameter,diameter,diameter));
- ConvexH c = ConvexHMakeCube(new float3(bmin), new float3(bmax));
- int k;
- while (maxplanes-- != 0 && (k = candidateplane(planes, planes.Count, c, epsilon)) >= 0)
- {
- ConvexH tmp = c;
- c = ConvexHCrop(ref tmp, planes[k], planetestepsilon);
- if (c == null) // might want to debug this case better!!!
- {
- c = tmp;
- break;
- }
- if (AssertIntact(c, planetestepsilon) == false) // might want to debug this case better too!!!
- {
- c = tmp;
- break;
- }
- tmp.edges = null;
- tmp.facets = null;
- tmp.vertices = null;
- }
-
- Debug.Assert(AssertIntact(c, planetestepsilon));
- //return c;
- //C++ TO C# CONVERTER TODO TASK: The memory management function 'malloc' has no equivalent in C#:
- faces_out = new List(); //(int)malloc(sizeof(int) * (1 + c.facets.Count + c.edges.Count)); // new int[1+c->facets.count+c->edges.count];
- int faces_count_out = 0;
- i = 0;
- faces_out[faces_count_out++] = -1;
- k = 0;
- while (i < c.edges.Count)
- {
- j = 1;
- while (j + i < c.edges.Count && c.edges[i].p == c.edges[i + j].p)
- {
- j++;
- }
- faces_out[faces_count_out++] = j;
- while (j-- != 0)
- {
- faces_out[faces_count_out++] = c.edges[i].v;
- i++;
- }
- k++;
- }
- faces_out[0] = k; // number of faces.
- Debug.Assert(k == c.facets.Count);
- Debug.Assert(faces_count_out == 1 + c.facets.Count + c.edges.Count);
- verts_out = c.vertices; // new float3[c->vertices.count];
- int verts_count_out = c.vertices.Count;
- for (i = 0; i < c.vertices.Count; i++)
- {
- verts_out[i] = new float3(c.vertices[i]);
- }
-
- c.edges = null;
- c.facets = null;
- c.vertices = null;
- return 1;
- }
-
- public static int overhullv(List verts, int maxplanes, out List verts_out, out List faces_out, float inflate, float bevangle, int vlimit, List tris)
- {
- verts_out = null;
- faces_out = null;
-
- if (verts.Count == 0)
- return 0;
- List planes = new List();
- int rc = calchullpbev(verts, vlimit, out planes, bevangle, tris);
- if (rc == 0)
- return 0;
- return overhull(planes, verts, maxplanes, out verts_out, out faces_out, inflate);
- }
-
- public static void addPoint(ref uint vcount, List p, float x, float y, float z)
- {
- p.Add(new float3(x, y, z));
- vcount++;
- }
-
- public static bool ComputeHull(List vertices, ref PHullResult result, int vlimit, float inflate)
- {
- List tris = new List();
- List faces;
- List verts_out;
-
- if (inflate == 0.0f)
- {
- List tris_out;
- bool ret = calchull(vertices, out tris_out, vlimit, tris);
- if (ret == false)
- return false;
-
- result.Indices = tris_out;
- result.Vertices = vertices;
- return true;
- }
- else
- {
- int ret = overhullv(vertices, 35, out verts_out, out faces, inflate, 120.0f, vlimit, tris);
- if (ret == 0)
- return false;
-
- List tris2 = new List();
- int n = faces[0];
- int k = 1;
- for (int i = 0; i < n; i++)
- {
- int pn = faces[k++];
- for (int j = 2; j < pn; j++)
- tris2.Add(new int3(faces[k], faces[k + j - 1], faces[k + j]));
- k += pn;
- }
- Debug.Assert(tris2.Count == faces.Count - 1 - (n * 3));
-
- result.Indices = new List(tris2.Count * 3);
- for (int i = 0; i < tris2.Count; i++)
- {
- result.Indices.Add(tris2[i].x);
- result.Indices.Add(tris2[i].y);
- result.Indices.Add(tris2[i].z);
- }
- result.Vertices = verts_out;
-
- return true;
- }
- }
-
- private static bool CleanupVertices(List svertices, out List vertices, float normalepsilon, out float3 scale)
- {
- const float EPSILON = 0.000001f;
-
- vertices = new List();
- scale = new float3(1f, 1f, 1f);
-
- if (svertices.Count == 0)
- return false;
-
- uint vcount = 0;
-
- float[] recip = new float[3];
-
- float[] bmin = { Single.MaxValue, Single.MaxValue, Single.MaxValue };
- float[] bmax = { Single.MinValue, Single.MinValue, Single.MinValue };
-
- for (int i = 0; i < svertices.Count; i++)
- {
- float3 p = svertices[i];
-
- for (int j = 0; j < 3; j++)
- {
- if (p[j] < bmin[j])
- bmin[j] = p[j];
- if (p[j] > bmax[j])
- bmax[j] = p[j];
- }
- }
-
- float dx = bmax[0] - bmin[0];
- float dy = bmax[1] - bmin[1];
- float dz = bmax[2] - bmin[2];
-
- float3 center = new float3();
-
- center.x = dx * 0.5f + bmin[0];
- center.y = dy * 0.5f + bmin[1];
- center.z = dz * 0.5f + bmin[2];
-
- if (dx < EPSILON || dy < EPSILON || dz < EPSILON || svertices.Count < 3)
- {
- float len = Single.MaxValue;
-
- if (dx > EPSILON && dx < len)
- len = dx;
- if (dy > EPSILON && dy < len)
- len = dy;
- if (dz > EPSILON && dz < len)
- len = dz;
-
- if (len == Single.MaxValue)
- {
- dx = dy = dz = 0.01f; // one centimeter
- }
- else
- {
- if (dx < EPSILON) // 1/5th the shortest non-zero edge.
- dx = len * 0.05f;
- if (dy < EPSILON)
- dy = len * 0.05f;
- if (dz < EPSILON)
- dz = len * 0.05f;
- }
-
- float x1 = center[0] - dx;
- float x2 = center[0] + dx;
-
- float y1 = center[1] - dy;
- float y2 = center[1] + dy;
-
- float z1 = center[2] - dz;
- float z2 = center[2] + dz;
-
- addPoint(ref vcount, vertices, x1, y1, z1);
- addPoint(ref vcount, vertices, x2, y1, z1);
- addPoint(ref vcount, vertices, x2, y2, z1);
- addPoint(ref vcount, vertices, x1, y2, z1);
- addPoint(ref vcount, vertices, x1, y1, z2);
- addPoint(ref vcount, vertices, x2, y1, z2);
- addPoint(ref vcount, vertices, x2, y2, z2);
- addPoint(ref vcount, vertices, x1, y2, z2);
-
- return true; // return cube
- }
- else
- {
- scale.x = dx;
- scale.y = dy;
- scale.z = dz;
-
- recip[0] = 1f / dx;
- recip[1] = 1f / dy;
- recip[2] = 1f / dz;
-
- center.x *= recip[0];
- center.y *= recip[1];
- center.z *= recip[2];
- }
-
- for (int i = 0; i < svertices.Count; i++)
- {
- float3 p = svertices[i];
-
- float px = p[0];
- float py = p[1];
- float pz = p[2];
-
- px = px * recip[0]; // normalize
- py = py * recip[1]; // normalize
- pz = pz * recip[2]; // normalize
-
- if (true)
- {
- int j;
-
- for (j = 0; j < vcount; j++)
- {
- float3 v = vertices[j];
-
- float x = v[0];
- float y = v[1];
- float z = v[2];
-
- float dx1 = Math.Abs(x - px);
- float dy1 = Math.Abs(y - py);
- float dz1 = Math.Abs(z - pz);
-
- if (dx1 < normalepsilon && dy1 < normalepsilon && dz1 < normalepsilon)
- {
- // ok, it is close enough to the old one
- // now let us see if it is further from the center of the point cloud than the one we already recorded.
- // in which case we keep this one instead.
- float dist1 = GetDist(px, py, pz, center);
- float dist2 = GetDist(v[0], v[1], v[2], center);
-
- if (dist1 > dist2)
- {
- v.x = px;
- v.y = py;
- v.z = pz;
- }
-
- break;
- }
- }
-
- if (j == vcount)
- {
- float3 dest = new float3(px, py, pz);
- vertices.Add(dest);
- vcount++;
- }
- }
- }
-
- // ok..now make sure we didn't prune so many vertices it is now invalid.
- if (true)
- {
- float[] bmin2 = { Single.MaxValue, Single.MaxValue, Single.MaxValue };
- float[] bmax2 = { Single.MinValue, Single.MinValue, Single.MinValue };
-
- for (int i = 0; i < vcount; i++)
- {
- float3 p = vertices[i];
- for (int j = 0; j < 3; j++)
- {
- if (p[j] < bmin2[j])
- bmin2[j] = p[j];
- if (p[j] > bmax2[j])
- bmax2[j] = p[j];
- }
- }
-
- float dx2 = bmax2[0] - bmin2[0];
- float dy2 = bmax2[1] - bmin2[1];
- float dz2 = bmax2[2] - bmin2[2];
-
- if (dx2 < EPSILON || dy2 < EPSILON || dz2 < EPSILON || vcount < 3)
- {
- float cx = dx2 * 0.5f + bmin2[0];
- float cy = dy2 * 0.5f + bmin2[1];
- float cz = dz2 * 0.5f + bmin2[2];
-
- float len = Single.MaxValue;
-
- if (dx2 >= EPSILON && dx2 < len)
- len = dx2;
- if (dy2 >= EPSILON && dy2 < len)
- len = dy2;
- if (dz2 >= EPSILON && dz2 < len)
- len = dz2;
-
- if (len == Single.MaxValue)
- {
- dx2 = dy2 = dz2 = 0.01f; // one centimeter
- }
- else
- {
- if (dx2 < EPSILON) // 1/5th the shortest non-zero edge.
- dx2 = len * 0.05f;
- if (dy2 < EPSILON)
- dy2 = len * 0.05f;
- if (dz2 < EPSILON)
- dz2 = len * 0.05f;
- }
-
- float x1 = cx - dx2;
- float x2 = cx + dx2;
-
- float y1 = cy - dy2;
- float y2 = cy + dy2;
-
- float z1 = cz - dz2;
- float z2 = cz + dz2;
-
- vcount = 0; // add box
-
- addPoint(ref vcount, vertices, x1, y1, z1);
- addPoint(ref vcount, vertices, x2, y1, z1);
- addPoint(ref vcount, vertices, x2, y2, z1);
- addPoint(ref vcount, vertices, x1, y2, z1);
- addPoint(ref vcount, vertices, x1, y1, z2);
- addPoint(ref vcount, vertices, x2, y1, z2);
- addPoint(ref vcount, vertices, x2, y2, z2);
- addPoint(ref vcount, vertices, x1, y2, z2);
-
- return true;
- }
- }
-
- return true;
- }
-
- private static void BringOutYourDead(List verts, out List overts, List indices)
- {
- int[] used = new int[verts.Count];
- int ocount = 0;
-
- overts = new List();
-
- for (int i = 0; i < indices.Count; i++)
- {
- int v = indices[i]; // original array index
-
- Debug.Assert(v >= 0 && v < verts.Count);
-
- if (used[v] != 0) // if already remapped
- {
- indices[i] = used[v] - 1; // index to new array
- }
- else
- {
- indices[i] = ocount; // new index mapping
-
- overts.Add(verts[v]); // copy old vert to new vert array
-
- ocount++; // increment output vert count
-
- Debug.Assert(ocount >= 0 && ocount <= verts.Count);
-
- used[v] = ocount; // assign new index remapping
- }
- }
- }
-
- public static HullError CreateConvexHull(HullDesc desc, ref HullResult result)
- {
- HullError ret = HullError.QE_FAIL;
-
- PHullResult hr = new PHullResult();
-
- uint vcount = (uint)desc.Vertices.Count;
- if (vcount < 8)
- vcount = 8;
-
- List vsource;
- float3 scale = new float3();
-
- bool ok = CleanupVertices(desc.Vertices, out vsource, desc.NormalEpsilon, out scale); // normalize point cloud, remove duplicates!
-
- if (ok)
- {
- if (true) // scale vertices back to their original size.
- {
- for (int i = 0; i < vsource.Count; i++)
- {
- float3 v = vsource[i];
- v.x *= scale[0];
- v.y *= scale[1];
- v.z *= scale[2];
- }
- }
-
- float skinwidth = 0;
- if (desc.HasHullFlag(HullFlag.QF_SKIN_WIDTH))
- skinwidth = desc.SkinWidth;
-
- ok = ComputeHull(vsource, ref hr, (int)desc.MaxVertices, skinwidth);
-
- if (ok)
- {
- List vscratch;
- BringOutYourDead(hr.Vertices, out vscratch, hr.Indices);
-
- ret = HullError.QE_OK;
-
- if (desc.HasHullFlag(HullFlag.QF_TRIANGLES)) // if he wants the results as triangle!
- {
- result.Polygons = false;
- result.Indices = hr.Indices;
- result.OutputVertices = vscratch;
- }
- else
- {
- result.Polygons = true;
- result.OutputVertices = vscratch;
-
- if (true)
- {
- List source = hr.Indices;
- List dest = new List();
- for (int i = 0; i < hr.Indices.Count / 3; i++)
- {
- dest.Add(3);
- dest.Add(source[i * 3 + 0]);
- dest.Add(source[i * 3 + 1]);
- dest.Add(source[i * 3 + 2]);
- }
-
- result.Indices = dest;
- }
- }
- }
- }
-
- return ret;
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/LICENSE.txt b/addon-modules/ConvexDecompositionDotNet/LICENSE.txt
deleted file mode 100644
index 714ae898d8..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/LICENSE.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-ConvexDecompositionDotNet
--------------------------
-
-The MIT License
-
-Copyright (c) 2010 Intel Corporation.
-All rights reserved.
-
-Based on the convexdecomposition library from
- by John W. Ratcliff and Stan Melax.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/addon-modules/ConvexDecompositionDotNet/Plane.cs b/addon-modules/ConvexDecompositionDotNet/Plane.cs
deleted file mode 100644
index d099676208..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/Plane.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class Plane
- {
- public float3 normal = new float3();
- public float dist; // distance below origin - the D from plane equasion Ax+By+Cz+D=0
-
- public Plane(float3 n, float d)
- {
- normal = new float3(n);
- dist = d;
- }
-
- public Plane(Plane p)
- {
- normal = new float3(p.normal);
- dist = p.dist;
- }
-
- public Plane()
- {
- dist = 0;
- }
-
- public void Transform(float3 position, Quaternion orientation)
- {
- // Transforms the plane to the space defined by the
- // given position/orientation
- float3 newNormal = Quaternion.Inverse(orientation) * normal;
- float3 origin = Quaternion.Inverse(orientation) * (-normal * dist - position);
-
- normal = newNormal;
- dist = -float3.dot(newNormal, origin);
- }
-
- public override int GetHashCode()
- {
- return normal.GetHashCode() ^ dist.GetHashCode();
- }
-
- public override bool Equals(object obj)
- {
- Plane p = obj as Plane;
- if (p == null)
- return false;
-
- return this == p;
- }
-
- public static bool operator ==(Plane a, Plane b)
- {
- return (a.normal == b.normal && a.dist == b.dist);
- }
-
- public static bool operator !=(Plane a, Plane b)
- {
- return !(a == b);
- }
-
- public static Plane PlaneFlip(Plane plane)
- {
- return new Plane(-plane.normal, -plane.dist);
- }
-
- public static bool coplanar(Plane a, Plane b)
- {
- return (a == b || a == PlaneFlip(b));
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/PlaneTri.cs b/addon-modules/ConvexDecompositionDotNet/PlaneTri.cs
deleted file mode 100644
index 31f0182520..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/PlaneTri.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public enum PlaneTriResult : int
- {
- PTR_FRONT,
- PTR_BACK,
- PTR_SPLIT
- }
-
- public static class PlaneTri
- {
- private static float DistToPt(float3 p, float4 plane)
- {
- return p.x * plane.x + p.y * plane.y + p.z * plane.z + plane.w;
- }
-
- private static PlaneTriResult getSidePlane(float3 p, float4 plane, float epsilon)
- {
- float d = DistToPt(p, plane);
-
- if ((d + epsilon) > 0f)
- return PlaneTriResult.PTR_FRONT; // it is 'in front' within the provided epsilon value.
-
- return PlaneTriResult.PTR_BACK;
- }
-
- private static void add(float3 p, float3[] dest, ref int pcount)
- {
- dest[pcount++] = new float3(p);
- Debug.Assert(pcount <= 4);
- }
-
- // assumes that the points are on opposite sides of the plane!
- private static void intersect(float3 p1, float3 p2, float3 split, float4 plane)
- {
- float dp1 = DistToPt(p1, plane);
- float[] dir = new float[3];
-
- dir[0] = p2[0] - p1[0];
- dir[1] = p2[1] - p1[1];
- dir[2] = p2[2] - p1[2];
-
- float dot1 = dir[0] * plane[0] + dir[1] * plane[1] + dir[2] * plane[2];
- float dot2 = dp1 - plane[3];
-
- float t = -(plane[3] + dot2) / dot1;
-
- split.x = (dir[0] * t) + p1[0];
- split.y = (dir[1] * t) + p1[1];
- split.z = (dir[2] * t) + p1[2];
- }
-
- public static PlaneTriResult planeTriIntersection(float4 plane, FaceTri triangle, float epsilon, ref float3[] front, out int fcount, ref float3[] back, out int bcount)
- {
- fcount = 0;
- bcount = 0;
-
- // get the three vertices of the triangle.
- float3 p1 = triangle.P1;
- float3 p2 = triangle.P2;
- float3 p3 = triangle.P3;
-
- PlaneTriResult r1 = getSidePlane(p1, plane, epsilon); // compute the side of the plane each vertex is on
- PlaneTriResult r2 = getSidePlane(p2, plane, epsilon);
- PlaneTriResult r3 = getSidePlane(p3, plane, epsilon);
-
- if (r1 == r2 && r1 == r3) // if all three vertices are on the same side of the plane.
- {
- if (r1 == PlaneTriResult.PTR_FRONT) // if all three are in front of the plane, then copy to the 'front' output triangle.
- {
- add(p1, front, ref fcount);
- add(p2, front, ref fcount);
- add(p3, front, ref fcount);
- }
- else
- {
- add(p1, back, ref bcount); // if all three are in 'back' then copy to the 'back' output triangle.
- add(p2, back, ref bcount);
- add(p3, back, ref bcount);
- }
- return r1; // if all three points are on the same side of the plane return result
- }
-
- // ok.. we need to split the triangle at the plane.
-
- // First test ray segment P1 to P2
- if (r1 == r2) // if these are both on the same side...
- {
- if (r1 == PlaneTriResult.PTR_FRONT)
- {
- add(p1, front, ref fcount);
- add(p2, front, ref fcount);
- }
- else
- {
- add(p1, back, ref bcount);
- add(p2, back, ref bcount);
- }
- }
- else
- {
- float3 split = new float3();
- intersect(p1, p2, split, plane);
-
- if (r1 == PlaneTriResult.PTR_FRONT)
- {
-
- add(p1, front, ref fcount);
- add(split, front, ref fcount);
-
- add(split, back, ref bcount);
- add(p2, back, ref bcount);
-
- }
- else
- {
- add(p1, back, ref bcount);
- add(split, back, ref bcount);
-
- add(split, front, ref fcount);
- add(p2, front, ref fcount);
- }
-
- }
-
- // Next test ray segment P2 to P3
- if (r2 == r3) // if these are both on the same side...
- {
- if (r3 == PlaneTriResult.PTR_FRONT)
- {
- add(p3, front, ref fcount);
- }
- else
- {
- add(p3, back, ref bcount);
- }
- }
- else
- {
- float3 split = new float3(); // split the point
- intersect(p2, p3, split, plane);
-
- if (r3 == PlaneTriResult.PTR_FRONT)
- {
- add(split, front, ref fcount);
- add(split, back, ref bcount);
-
- add(p3, front, ref fcount);
- }
- else
- {
- add(split, front, ref fcount);
- add(split, back, ref bcount);
-
- add(p3, back, ref bcount);
- }
- }
-
- // Next test ray segment P3 to P1
- if (r3 != r1) // if these are both on the same side...
- {
- float3 split = new float3(); // split the point
- intersect(p3, p1, split, plane);
-
- if (r1 == PlaneTriResult.PTR_FRONT)
- {
- add(split, front, ref fcount);
- add(split, back, ref bcount);
- }
- else
- {
- add(split, front, ref fcount);
- add(split, back, ref bcount);
- }
- }
-
- return PlaneTriResult.PTR_SPLIT;
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/Quaternion.cs b/addon-modules/ConvexDecompositionDotNet/Quaternion.cs
deleted file mode 100644
index 0ba8f17a9c..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/Quaternion.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class Quaternion : float4
- {
- public Quaternion()
- {
- x = y = z = 0.0f;
- w = 1.0f;
- }
-
- public Quaternion(float3 v, float t)
- {
- v = float3.normalize(v);
- w = (float)Math.Cos(t / 2.0f);
- v = v * (float)Math.Sin(t / 2.0f);
- x = v.x;
- y = v.y;
- z = v.z;
- }
-
- public Quaternion(float _x, float _y, float _z, float _w)
- {
- x = _x;
- y = _y;
- z = _z;
- w = _w;
- }
-
- public float angle()
- {
- return (float)Math.Acos(w) * 2.0f;
- }
-
- public float3 axis()
- {
- float3 a = new float3(x, y, z);
- if (Math.Abs(angle()) < 0.0000001f)
- return new float3(1f, 0f, 0f);
- return a * (1 / (float)Math.Sin(angle() / 2.0f));
- }
-
- public float3 xdir()
- {
- return new float3(1 - 2 * (y * y + z * z), 2 * (x * y + w * z), 2 * (x * z - w * y));
- }
-
- public float3 ydir()
- {
- return new float3(2 * (x * y - w * z), 1 - 2 * (x * x + z * z), 2 * (y * z + w * x));
- }
-
- public float3 zdir()
- {
- return new float3(2 * (x * z + w * y), 2 * (y * z - w * x), 1 - 2 * (x * x + y * y));
- }
-
- public float3x3 getmatrix()
- {
- return new float3x3(xdir(), ydir(), zdir());
- }
-
- public static implicit operator float3x3(Quaternion q)
- {
- return q.getmatrix();
- }
-
- public static Quaternion operator *(Quaternion a, Quaternion b)
- {
- Quaternion c = new Quaternion();
- c.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;
- c.x = a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y;
- c.y = a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x;
- c.z = a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w;
- return c;
- }
-
- public static float3 operator *(Quaternion q, float3 v)
- {
- // The following is equivalent to:
- //return (q.getmatrix() * v);
- float qx2 = q.x * q.x;
- float qy2 = q.y * q.y;
- float qz2 = q.z * q.z;
-
- float qxqy = q.x * q.y;
- float qxqz = q.x * q.z;
- float qxqw = q.x * q.w;
- float qyqz = q.y * q.z;
- float qyqw = q.y * q.w;
- float qzqw = q.z * q.w;
- return new float3((1 - 2 * (qy2 + qz2)) * v.x + (2 * (qxqy - qzqw)) * v.y + (2 * (qxqz + qyqw)) * v.z, (2 * (qxqy + qzqw)) * v.x + (1 - 2 * (qx2 + qz2)) * v.y + (2 * (qyqz - qxqw)) * v.z, (2 * (qxqz - qyqw)) * v.x + (2 * (qyqz + qxqw)) * v.y + (1 - 2 * (qx2 + qy2)) * v.z);
- }
-
- public static Quaternion operator +(Quaternion a, Quaternion b)
- {
- return new Quaternion(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
- }
-
- public static Quaternion operator *(Quaternion a, float b)
- {
- return new Quaternion(a.x *b, a.y *b, a.z *b, a.w *b);
- }
-
- public static Quaternion normalize(Quaternion a)
- {
- float m = (float)Math.Sqrt(a.w * a.w + a.x * a.x + a.y * a.y + a.z * a.z);
- if (m < 0.000000001f)
- {
- a.w = 1;
- a.x = a.y = a.z = 0;
- return a;
- }
- return a * (1f / m);
- }
-
- public static float dot(Quaternion a, Quaternion b)
- {
- return (a.w * b.w + a.x * b.x + a.y * b.y + a.z * b.z);
- }
-
- public static Quaternion slerp(Quaternion a, Quaternion b, float interp)
- {
- if (dot(a, b) < 0.0)
- {
- a.w = -a.w;
- a.x = -a.x;
- a.y = -a.y;
- a.z = -a.z;
- }
- float d = dot(a, b);
- if (d >= 1.0)
- {
- return a;
- }
- float theta = (float)Math.Acos(d);
- if (theta == 0.0f)
- {
- return (a);
- }
- return a * ((float)Math.Sin(theta - interp * theta) / (float)Math.Sin(theta)) + b * ((float)Math.Sin(interp * theta) / (float)Math.Sin(theta));
- }
-
- public static Quaternion Interpolate(Quaternion q0, Quaternion q1, float alpha)
- {
- return slerp(q0, q1, alpha);
- }
-
- public static Quaternion Inverse(Quaternion q)
- {
- return new Quaternion(-q.x, -q.y, -q.z, q.w);
- }
-
- public static Quaternion YawPitchRoll(float yaw, float pitch, float roll)
- {
- roll *= (3.14159264f / 180.0f);
- yaw *= (3.14159264f / 180.0f);
- pitch *= (3.14159264f / 180.0f);
- return new Quaternion(new float3(0.0f, 0.0f, 1.0f), yaw) * new Quaternion(new float3(1.0f, 0.0f, 0.0f), pitch) * new Quaternion(new float3(0.0f, 1.0f, 0.0f), roll);
- }
-
- public static float Yaw(Quaternion q)
- {
- float3 v = q.ydir();
- return (v.y == 0.0 && v.x == 0.0) ? 0.0f : (float)Math.Atan2(-v.x, v.y) * (180.0f / 3.14159264f);
- }
-
- public static float Pitch(Quaternion q)
- {
- float3 v = q.ydir();
- return (float)Math.Atan2(v.z, Math.Sqrt(v.x * v.x + v.y * v.y)) * (180.0f / 3.14159264f);
- }
-
- public static float Roll(Quaternion q)
- {
- q = new Quaternion(new float3(0.0f, 0.0f, 1.0f), -Yaw(q) * (3.14159264f / 180.0f)) * q;
- q = new Quaternion(new float3(1.0f, 0.0f, 0.0f), -Pitch(q) * (3.14159264f / 180.0f)) * q;
- return (float)Math.Atan2(-q.xdir().z, q.xdir().x) * (180.0f / 3.14159264f);
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/README.txt b/addon-modules/ConvexDecompositionDotNet/README.txt
deleted file mode 100644
index fc53ae75c8..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/README.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-ConvexDecompositionDotNet
-=========================
-
-A C# port of the ConvexDecomposition library by John W. Ratcliff and Stan Melax.
-The original C++ version is available at .
-See the blog post at
-for a thorough explanation of generating convex hulls from concave meshes.
diff --git a/addon-modules/ConvexDecompositionDotNet/SplitPlane.cs b/addon-modules/ConvexDecompositionDotNet/SplitPlane.cs
deleted file mode 100644
index 9f06a9a23f..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/SplitPlane.cs
+++ /dev/null
@@ -1,265 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class Rect3d
- {
- public float[] mMin = new float[3];
- public float[] mMax = new float[3];
-
- public Rect3d()
- {
- }
-
- public Rect3d(float[] bmin, float[] bmax)
- {
- mMin[0] = bmin[0];
- mMin[1] = bmin[1];
- mMin[2] = bmin[2];
-
- mMax[0] = bmax[0];
- mMax[1] = bmax[1];
- mMax[2] = bmax[2];
- }
-
- public void SetMin(float[] bmin)
- {
- mMin[0] = bmin[0];
- mMin[1] = bmin[1];
- mMin[2] = bmin[2];
- }
-
- public void SetMax(float[] bmax)
- {
- mMax[0] = bmax[0];
- mMax[1] = bmax[1];
- mMax[2] = bmax[2];
- }
-
- public void SetMin(float x, float y, float z)
- {
- mMin[0] = x;
- mMin[1] = y;
- mMin[2] = z;
- }
-
- public void SetMax(float x, float y, float z)
- {
- mMax[0] = x;
- mMax[1] = y;
- mMax[2] = z;
- }
- }
-
- public static class SplitPlane
- {
- public static bool computeSplitPlane(List vertices, List indices, ref float4 plane)
- {
- float[] bmin = { Single.MaxValue, Single.MaxValue, Single.MaxValue };
- float[] bmax = { Single.MinValue, Single.MinValue, Single.MinValue };
-
- for (int i = 0; i < vertices.Count; i++)
- {
- float3 p = vertices[i];
-
- if (p[0] < bmin[0])
- bmin[0] = p[0];
- if (p[1] < bmin[1])
- bmin[1] = p[1];
- if (p[2] < bmin[2])
- bmin[2] = p[2];
-
- if (p[0] > bmax[0])
- bmax[0] = p[0];
- if (p[1] > bmax[1])
- bmax[1] = p[1];
- if (p[2] > bmax[2])
- bmax[2] = p[2];
- }
-
- float dx = bmax[0] - bmin[0];
- float dy = bmax[1] - bmin[1];
- float dz = bmax[2] - bmin[2];
-
- float laxis = dx;
-
- int axis = 0;
-
- if (dy > dx)
- {
- axis = 1;
- laxis = dy;
- }
-
- if (dz > dx && dz > dy)
- {
- axis = 2;
- laxis = dz;
- }
-
- float[] p1 = new float[3];
- float[] p2 = new float[3];
- float[] p3 = new float[3];
-
- p3[0] = p2[0] = p1[0] = bmin[0] + dx * 0.5f;
- p3[1] = p2[1] = p1[1] = bmin[1] + dy * 0.5f;
- p3[2] = p2[2] = p1[2] = bmin[2] + dz * 0.5f;
-
- Rect3d b = new Rect3d(bmin, bmax);
-
- Rect3d b1 = new Rect3d();
- Rect3d b2 = new Rect3d();
-
- splitRect(axis, b, b1, b2, p1);
-
- switch (axis)
- {
- case 0:
- p2[1] = bmin[1];
- p2[2] = bmin[2];
-
- if (dz > dy)
- {
- p3[1] = bmax[1];
- p3[2] = bmin[2];
- }
- else
- {
- p3[1] = bmin[1];
- p3[2] = bmax[2];
- }
-
- break;
- case 1:
- p2[0] = bmin[0];
- p2[2] = bmin[2];
-
- if (dx > dz)
- {
- p3[0] = bmax[0];
- p3[2] = bmin[2];
- }
- else
- {
- p3[0] = bmin[0];
- p3[2] = bmax[2];
- }
-
- break;
- case 2:
- p2[0] = bmin[0];
- p2[1] = bmin[1];
-
- if (dx > dy)
- {
- p3[0] = bmax[0];
- p3[1] = bmin[1];
- }
- else
- {
- p3[0] = bmin[0];
- p3[1] = bmax[1];
- }
-
- break;
- }
-
- computePlane(p1, p2, p3, plane);
-
- return true;
- }
-
- internal static void computePlane(float[] A, float[] B, float[] C, float4 plane)
- {
- float vx = (B[0] - C[0]);
- float vy = (B[1] - C[1]);
- float vz = (B[2] - C[2]);
-
- float wx = (A[0] - B[0]);
- float wy = (A[1] - B[1]);
- float wz = (A[2] - B[2]);
-
- float vw_x = vy * wz - vz * wy;
- float vw_y = vz * wx - vx * wz;
- float vw_z = vx * wy - vy * wx;
-
- float mag = (float)Math.Sqrt((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
-
- if (mag < 0.000001f)
- {
- mag = 0;
- }
- else
- {
- mag = 1.0f / mag;
- }
-
- float x = vw_x * mag;
- float y = vw_y * mag;
- float z = vw_z * mag;
-
- float D = 0.0f - ((x * A[0]) + (y * A[1]) + (z * A[2]));
-
- plane.x = x;
- plane.y = y;
- plane.z = z;
- plane.w = D;
- }
-
- public static void splitRect(int axis, Rect3d source, Rect3d b1, Rect3d b2, float[] midpoint)
- {
- switch (axis)
- {
- case 0:
- b1.SetMin(source.mMin);
- b1.SetMax(midpoint[0], source.mMax[1], source.mMax[2]);
-
- b2.SetMin(midpoint[0], source.mMin[1], source.mMin[2]);
- b2.SetMax(source.mMax);
- break;
- case 1:
- b1.SetMin(source.mMin);
- b1.SetMax(source.mMax[0], midpoint[1], source.mMax[2]);
-
- b2.SetMin(source.mMin[0], midpoint[1], source.mMin[2]);
- b2.SetMax(source.mMax);
- break;
- case 2:
- b1.SetMin(source.mMin);
- b1.SetMax(source.mMax[0], source.mMax[1], midpoint[2]);
-
- b2.SetMin(source.mMin[0], source.mMin[1], midpoint[2]);
- b2.SetMax(source.mMax);
- break;
- }
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/VertexLookup.cs b/addon-modules/ConvexDecompositionDotNet/VertexLookup.cs
deleted file mode 100644
index 6f17c9f711..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/VertexLookup.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class VertexPool
- {
- private List mVertices = new List();
- private Dictionary mIndices = new Dictionary();
-
- public int getIndex(float3 vtx)
- {
- int idx;
- if (mIndices.TryGetValue(vtx, out idx))
- return idx;
-
- idx = mVertices.Count;
- mVertices.Add(vtx);
- mIndices.Add(vtx, idx);
- return idx;
- }
-
- public float3 Get(int idx)
- {
- return mVertices[idx];
- }
-
- public int GetSize()
- {
- return mVertices.Count;
- }
-
- public List GetVertices()
- {
- return mVertices;
- }
-
- public void Clear()
- {
- mVertices.Clear();
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/float2.cs b/addon-modules/ConvexDecompositionDotNet/float2.cs
deleted file mode 100644
index ce88fc826e..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/float2.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class float2
- {
- public float x;
- public float y;
-
- public float2()
- {
- }
-
- public float2(float _x, float _y)
- {
- x = _x;
- y = _y;
- }
-
- public float this[int i]
- {
- get
- {
- switch (i)
- {
- case 0: return x;
- case 1: return y;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
-
- public static float2 operator -(float2 a, float2 b)
- {
- return new float2(a.x - b.x, a.y - b.y);
- }
-
- public static float2 operator +(float2 a, float2 b)
- {
- return new float2(a.x + b.x, a.y + b.y);
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/float3.cs b/addon-modules/ConvexDecompositionDotNet/float3.cs
deleted file mode 100644
index 4389114848..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/float3.cs
+++ /dev/null
@@ -1,444 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class float3 : IEquatable
- {
- public float x;
- public float y;
- public float z;
-
- public float3()
- {
- x = 0;
- y = 0;
- z = 0;
- }
-
- public float3(float _x, float _y, float _z)
- {
- x = _x;
- y = _y;
- z = _z;
- }
-
- public float3(float3 f)
- {
- x = f.x;
- y = f.y;
- z = f.z;
- }
-
- public float this[int i]
- {
- get
- {
- switch (i)
- {
- case 0: return x;
- case 1: return y;
- case 2: return z;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
-
- public float Distance(float3 a)
- {
- float3 d = new float3(a.x - x, a.y - y, a.z - z);
- return d.Length();
- }
-
- public float Distance2(float3 a)
- {
- float dx = a.x - x;
- float dy = a.y - y;
- float dz = a.z - z;
- return dx * dx + dy * dy + dz * dz;
- }
-
- public float Length()
- {
- return (float)Math.Sqrt(x * x + y * y + z * z);
- }
-
- public float Area(float3 p1, float3 p2)
- {
- float A = Partial(p1);
- A += p1.Partial(p2);
- A += p2.Partial(this);
- return A * 0.5f;
- }
-
- public float Partial(float3 p)
- {
- return (x * p.y) - (p.x * y);
- }
-
- // Given a point and a line (defined by two points), compute the closest point
- // in the line. (The line is treated as infinitely long.)
- public void NearestPointInLine(float3 point, float3 line0, float3 line1)
- {
- float3 nearestPoint = new float3();
- float3 lineDelta = line1 - line0;
-
- // Handle degenerate lines
- if (lineDelta == float3.Zero)
- {
- nearestPoint = line0;
- }
- else
- {
- float delta = float3.dot(point - line0, lineDelta) / float3.dot(lineDelta, lineDelta);
- nearestPoint = line0 + lineDelta * delta;
- }
-
- this.x = nearestPoint.x;
- this.y = nearestPoint.y;
- this.z = nearestPoint.z;
- }
-
- // Given a point and a line segment (defined by two points), compute the closest point
- // in the line. Cap the point at the endpoints of the line segment.
- public void NearestPointInLineSegment(float3 point, float3 line0, float3 line1)
- {
- float3 nearestPoint = new float3();
- float3 lineDelta = line1 - line0;
-
- // Handle degenerate lines
- if (lineDelta == Zero)
- {
- nearestPoint = line0;
- }
- else
- {
- float delta = float3.dot(point - line0, lineDelta) / float3.dot(lineDelta, lineDelta);
-
- // Clamp the point to conform to the segment's endpoints
- if (delta < 0)
- delta = 0;
- else if (delta > 1)
- delta = 1;
-
- nearestPoint = line0 + lineDelta * delta;
- }
-
- this.x = nearestPoint.x;
- this.y = nearestPoint.y;
- this.z = nearestPoint.z;
- }
-
- // Given a point and a triangle (defined by three points), compute the closest point
- // in the triangle. Clamp the point so it's confined to the area of the triangle.
- public void NearestPointInTriangle(float3 point, float3 triangle0, float3 triangle1, float3 triangle2)
- {
- float3 nearestPoint = new float3();
-
- float3 lineDelta0 = triangle1 - triangle0;
- float3 lineDelta1 = triangle2 - triangle0;
-
- // Handle degenerate triangles
- if ((lineDelta0 == Zero) || (lineDelta1 == Zero))
- {
- nearestPoint.NearestPointInLineSegment(point, triangle1, triangle2);
- }
- else if (lineDelta0 == lineDelta1)
- {
- nearestPoint.NearestPointInLineSegment(point, triangle0, triangle1);
- }
- else
- {
- float3[] axis = new float3[3] { new float3(), new float3(), new float3() };
- axis[0].NearestPointInLine(triangle0, triangle1, triangle2);
- axis[1].NearestPointInLine(triangle1, triangle0, triangle2);
- axis[2].NearestPointInLine(triangle2, triangle0, triangle1);
-
- float3 axisDot = new float3();
- axisDot.x = dot(triangle0 - axis[0], point - axis[0]);
- axisDot.y = dot(triangle1 - axis[1], point - axis[1]);
- axisDot.z = dot(triangle2 - axis[2], point - axis[2]);
-
- bool bForce = true;
- float bestMagnitude2 = 0;
- float closeMagnitude2;
- float3 closePoint = new float3();
-
- if (axisDot.x < 0f)
- {
- closePoint.NearestPointInLineSegment(point, triangle1, triangle2);
- closeMagnitude2 = point.Distance2(closePoint);
- if (bForce || (bestMagnitude2 > closeMagnitude2))
- {
- bForce = false;
- bestMagnitude2 = closeMagnitude2;
- nearestPoint = closePoint;
- }
- }
- if (axisDot.y < 0f)
- {
- closePoint.NearestPointInLineSegment(point, triangle0, triangle2);
- closeMagnitude2 = point.Distance2(closePoint);
- if (bForce || (bestMagnitude2 > closeMagnitude2))
- {
- bForce = false;
- bestMagnitude2 = closeMagnitude2;
- nearestPoint = closePoint;
- }
- }
- if (axisDot.z < 0f)
- {
- closePoint.NearestPointInLineSegment(point, triangle0, triangle1);
- closeMagnitude2 = point.Distance2(closePoint);
- if (bForce || (bestMagnitude2 > closeMagnitude2))
- {
- bForce = false;
- bestMagnitude2 = closeMagnitude2;
- nearestPoint = closePoint;
- }
- }
-
- // If bForce is true at this point, it means the nearest point lies
- // inside the triangle; use the nearest-point-on-a-plane equation
- if (bForce)
- {
- float3 normal;
-
- // Get the normal of the polygon (doesn't have to be a unit vector)
- normal = float3.cross(lineDelta0, lineDelta1);
-
- float3 pointDelta = point - triangle0;
- float delta = float3.dot(normal, pointDelta) / float3.dot(normal, normal);
-
- nearestPoint = point - normal * delta;
- }
- }
-
- this.x = nearestPoint.x;
- this.y = nearestPoint.y;
- this.z = nearestPoint.z;
- }
-
- public static float3 operator +(float3 a, float3 b)
- {
- return new float3(a.x + b.x, a.y + b.y, a.z + b.z);
- }
-
- public static float3 operator -(float3 a, float3 b)
- {
- return new float3(a.x - b.x, a.y - b.y, a.z - b.z);
- }
-
- public static float3 operator -(float3 a, float s)
- {
- return new float3(a.x - s, a.y - s, a.z - s);
- }
-
- public static float3 operator -(float3 v)
- {
- return new float3(-v.x, -v.y, -v.z);
- }
-
- public static float3 operator *(float3 v, float s)
- {
- return new float3(v.x * s, v.y * s, v.z * s);
- }
-
- public static float3 operator *(float s, float3 v)
- {
- return new float3(v.x * s, v.y * s, v.z * s);
- }
-
- public static float3 operator *(float3 v, float3x3 m)
- {
- return new float3((m.x.x * v.x + m.y.x * v.y + m.z.x * v.z), (m.x.y * v.x + m.y.y * v.y + m.z.y * v.z), (m.x.z * v.x + m.y.z * v.y + m.z.z * v.z));
- }
-
- public static float3 operator *(float3x3 m, float3 v)
- {
- return new float3(dot(m.x, v), dot(m.y, v), dot(m.z, v));
- }
-
- public static float3 operator /(float3 v, float s)
- {
- float sinv = 1.0f / s;
- return new float3(v.x * sinv, v.y * sinv, v.z * sinv);
- }
-
- public bool Equals(float3 other)
- {
- return this == other;
- }
-
- public override bool Equals(object obj)
- {
- float3 f = obj as float3;
- if (f == null)
- return false;
-
- return this == f;
- }
-
- public override int GetHashCode()
- {
- return x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode();
- }
-
- public static bool operator ==(float3 a, float3 b)
- {
- // If both are null, or both are same instance, return true.
- if (System.Object.ReferenceEquals(a, b))
- return true;
- // If one is null, but not both, return false.
- if (((object)a == null) || ((object)b == null))
- return false;
-
- return (a.x == b.x && a.y == b.y && a.z == b.z);
- }
-
- public static bool operator !=(float3 a, float3 b)
- {
- return (a.x != b.x || a.y != b.y || a.z != b.z);
- }
-
- public static float dot(float3 a, float3 b)
- {
- return a.x * b.x + a.y * b.y + a.z * b.z;
- }
-
- public static float3 cmul(float3 v1, float3 v2)
- {
- return new float3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z);
- }
-
- public static float3 cross(float3 a, float3 b)
- {
- return new float3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
- }
-
- public static float3 Interpolate(float3 v0, float3 v1, float alpha)
- {
- return v0 * (1 - alpha) + v1 * alpha;
- }
-
- public static float3 Round(float3 a, int digits)
- {
- return new float3((float)Math.Round(a.x, digits), (float)Math.Round(a.y, digits), (float)Math.Round(a.z, digits));
- }
-
- public static float3 VectorMax(float3 a, float3 b)
- {
- return new float3(Math.Max(a.x, b.x), Math.Max(a.y, b.y), Math.Max(a.z, b.z));
- }
-
- public static float3 VectorMin(float3 a, float3 b)
- {
- return new float3(Math.Min(a.x, b.x), Math.Min(a.y, b.y), Math.Min(a.z, b.z));
- }
-
- public static float3 vabs(float3 v)
- {
- return new float3(Math.Abs(v.x), Math.Abs(v.y), Math.Abs(v.z));
- }
-
- public static float magnitude(float3 v)
- {
- return (float)Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
- }
-
- public static float3 normalize(float3 v)
- {
- float d = magnitude(v);
- if (d == 0)
- d = 0.1f;
- d = 1 / d;
- return new float3(v.x * d, v.y * d, v.z * d);
- }
-
- public static float3 safenormalize(float3 v)
- {
- if (magnitude(v) <= 0.0f)
- return new float3(1, 0, 0);
- else
- return normalize(v);
- }
-
- public static float Yaw(float3 v)
- {
- return (v.y == 0.0 && v.x == 0.0) ? 0.0f : (float)Math.Atan2(-v.x, v.y) * (180.0f / 3.14159264f);
- }
-
- public static float Pitch(float3 v)
- {
- return (float)Math.Atan2(v.z, Math.Sqrt(v.x * v.x + v.y * v.y)) * (180.0f / 3.14159264f);
- }
-
- public float ComputePlane(float3 A, float3 B, float3 C)
- {
- float vx, vy, vz, wx, wy, wz, vw_x, vw_y, vw_z, mag;
-
- vx = (B.x - C.x);
- vy = (B.y - C.y);
- vz = (B.z - C.z);
-
- wx = (A.x - B.x);
- wy = (A.y - B.y);
- wz = (A.z - B.z);
-
- vw_x = vy * wz - vz * wy;
- vw_y = vz * wx - vx * wz;
- vw_z = vx * wy - vy * wx;
-
- mag = (float)Math.Sqrt((vw_x * vw_x) + (vw_y * vw_y) + (vw_z * vw_z));
-
- if (mag < 0.000001f)
- {
- mag = 0;
- }
- else
- {
- mag = 1.0f / mag;
- }
-
- x = vw_x * mag;
- y = vw_y * mag;
- z = vw_z * mag;
-
- float D = 0.0f - ((x * A.x) + (y * A.y) + (z * A.z));
- return D;
- }
-
- public override string ToString()
- {
- return String.Format("<{0}, {1}, {2}>", x, y, z);
- }
-
- public static readonly float3 Zero = new float3();
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/float3x3.cs b/addon-modules/ConvexDecompositionDotNet/float3x3.cs
deleted file mode 100644
index 76cf06347a..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/float3x3.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class float3x3
- {
- public float3 x = new float3();
- public float3 y = new float3();
- public float3 z = new float3();
-
- public float3x3()
- {
- }
-
- public float3x3(float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz)
- {
- x = new float3(xx, xy, xz);
- y = new float3(yx, yy, yz);
- z = new float3(zx, zy, zz);
- }
-
- public float3x3(float3 _x, float3 _y, float3 _z)
- {
- x = new float3(_x);
- y = new float3(_y);
- z = new float3(_z);
- }
-
- public float3 this[int i]
- {
- get
- {
- switch (i)
- {
- case 0: return x;
- case 1: return y;
- case 2: return z;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
-
- public float this[int i, int j]
- {
- get
- {
- switch (i)
- {
- case 0:
- switch (j)
- {
- case 0: return x.x;
- case 1: return x.y;
- case 2: return x.z;
- }
- break;
- case 1:
- switch (j)
- {
- case 0: return y.x;
- case 1: return y.y;
- case 2: return y.z;
- }
- break;
- case 2:
- switch (j)
- {
- case 0: return z.x;
- case 1: return z.y;
- case 2: return z.z;
- }
- break;
- }
- throw new ArgumentOutOfRangeException();
- }
- set
- {
- switch (i)
- {
- case 0:
- switch (j)
- {
- case 0: x.x = value; return;
- case 1: x.y = value; return;
- case 2: x.z = value; return;
- }
- break;
- case 1:
- switch (j)
- {
- case 0: y.x = value; return;
- case 1: y.y = value; return;
- case 2: y.z = value; return;
- }
- break;
- case 2:
- switch (j)
- {
- case 0: z.x = value; return;
- case 1: z.y = value; return;
- case 2: z.z = value; return;
- }
- break;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
-
- public static float3x3 Transpose(float3x3 m)
- {
- return new float3x3(new float3(m.x.x, m.y.x, m.z.x), new float3(m.x.y, m.y.y, m.z.y), new float3(m.x.z, m.y.z, m.z.z));
- }
-
- public static float3x3 operator *(float3x3 a, float3x3 b)
- {
- return new float3x3(a.x * b, a.y * b, a.z * b);
- }
-
- public static float3x3 operator *(float3x3 a, float s)
- {
- return new float3x3(a.x * s, a.y * s, a.z * s);
- }
-
- public static float3x3 operator /(float3x3 a, float s)
- {
- float t = 1f / s;
- return new float3x3(a.x * t, a.y * t, a.z * t);
- }
-
- public static float3x3 operator +(float3x3 a, float3x3 b)
- {
- return new float3x3(a.x + b.x, a.y + b.y, a.z + b.z);
- }
-
- public static float3x3 operator -(float3x3 a, float3x3 b)
- {
- return new float3x3(a.x - b.x, a.y - b.y, a.z - b.z);
- }
-
- public static float Determinant(float3x3 m)
- {
- return m.x.x * m.y.y * m.z.z + m.y.x * m.z.y * m.x.z + m.z.x * m.x.y * m.y.z - m.x.x * m.z.y * m.y.z - m.y.x * m.x.y * m.z.z - m.z.x * m.y.y * m.x.z;
- }
-
- public static float3x3 Inverse(float3x3 a)
- {
- float3x3 b = new float3x3();
- float d = Determinant(a);
- Debug.Assert(d != 0);
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- int i1 = (i + 1) % 3;
- int i2 = (i + 2) % 3;
- int j1 = (j + 1) % 3;
- int j2 = (j + 2) % 3;
-
- // reverse indexs i&j to take transpose
- b[i, j] = (a[i1][j1] * a[i2][j2] - a[i1][j2] * a[i2][j1]) / d;
- }
- }
- return b;
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/float4.cs b/addon-modules/ConvexDecompositionDotNet/float4.cs
deleted file mode 100644
index fa6087679f..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/float4.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class float4
- {
- public float x;
- public float y;
- public float z;
- public float w;
-
- public float4()
- {
- x = 0;
- y = 0;
- z = 0;
- w = 0;
- }
-
- public float4(float _x, float _y, float _z, float _w)
- {
- x = _x;
- y = _y;
- z = _z;
- w = _w;
- }
-
- public float4(float3 v, float _w)
- {
- x = v.x;
- y = v.y;
- z = v.z;
- w = _w;
- }
-
- public float4(float4 f)
- {
- x = f.x;
- y = f.y;
- z = f.z;
- w = f.w;
- }
-
- public float this[int i]
- {
- get
- {
- switch (i)
- {
- case 0: return x;
- case 1: return y;
- case 2: return z;
- case 3: return w;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
-
- public float3 xyz()
- {
- return new float3(x, y, z);
- }
-
- public void setxyz(float3 xyz)
- {
- x = xyz.x;
- y = xyz.y;
- z = xyz.z;
- }
-
- public override int GetHashCode()
- {
- return x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ w.GetHashCode();
- }
-
- public override bool Equals(object obj)
- {
- float4 f = obj as float4;
- if (f == null)
- return false;
-
- return this == f;
- }
-
- public static float4 Homogenize(float3 v3)
- {
- return Homogenize(v3, 1.0f);
- }
-
- //C++ TO C# CONVERTER NOTE: C# does not allow default values for parameters. Overloaded methods are inserted above.
- //ORIGINAL LINE: float4 Homogenize(const float3 &v3, const float &w =1.0f)
- public static float4 Homogenize(float3 v3, float w)
- {
- return new float4(v3.x, v3.y, v3.z, w);
- }
-
- public static float4 cmul(float4 a, float4 b)
- {
- return new float4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
- }
-
- public static float4 operator +(float4 a, float4 b)
- {
- return new float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
- }
- public static float4 operator -(float4 a, float4 b)
- {
- return new float4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
- }
-
- public static float4 operator *(float4 v, float4x4 m)
- {
- return v.x * m.x + v.y * m.y + v.z * m.z + v.w * m.w; // yes this actually works
- }
-
- public static bool operator ==(float4 a, float4 b)
- {
- // If both are null, or both are same instance, return true.
- if (System.Object.ReferenceEquals(a, b))
- return true;
- // If one is null, but not both, return false.
- if (((object)a == null) || ((object)b == null))
- return false;
-
- return (a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w);
- }
-
- public static bool operator !=(float4 a, float4 b)
- {
- return !(a == b);
- }
-
- public static float4 operator *(float4 v, float s)
- {
- return new float4(v.x * s, v.y * s, v.z * s, v.w * s);
- }
-
- public static float4 operator *(float s, float4 v)
- {
- return new float4(v.x * s, v.y * s, v.z * s, v.w * s);
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/float4x4.cs b/addon-modules/ConvexDecompositionDotNet/float4x4.cs
deleted file mode 100644
index 7d1592f00c..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/float4x4.cs
+++ /dev/null
@@ -1,284 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class float4x4
- {
- public float4 x = new float4();
- public float4 y = new float4();
- public float4 z = new float4();
- public float4 w = new float4();
-
- public float4x4()
- {
- }
-
- public float4x4(float4 _x, float4 _y, float4 _z, float4 _w)
- {
- x = new float4(_x);
- y = new float4(_y);
- z = new float4(_z);
- w = new float4(_w);
- }
-
- public float4x4(
- float m00, float m01, float m02, float m03,
- float m10, float m11, float m12, float m13,
- float m20, float m21, float m22, float m23,
- float m30, float m31, float m32, float m33)
- {
- x = new float4(m00, m01, m02, m03);
- y = new float4(m10, m11, m12, m13);
- z = new float4(m20, m21, m22, m23);
- w = new float4(m30, m31, m32, m33);
- }
-
- public float4x4(float4x4 m)
- {
- x = new float4(m.x);
- y = new float4(m.y);
- z = new float4(m.z);
- w = new float4(m.w);
- }
-
- public float4 this[int i]
- {
- get
- {
- switch (i)
- {
- case 0: return x;
- case 1: return y;
- case 2: return z;
- case 3: return w;
- }
- throw new ArgumentOutOfRangeException();
- }
- set
- {
- switch (i)
- {
- case 0: x = value; return;
- case 1: y = value; return;
- case 2: z = value; return;
- case 3: w = value; return;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
-
- public override int GetHashCode()
- {
- return x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ w.GetHashCode();
- }
-
- public override bool Equals(object obj)
- {
- float4x4 m = obj as float4x4;
- if (m == null)
- return false;
-
- return this == m;
- }
-
- public static float4x4 operator *(float4x4 a, float4x4 b)
- {
- return new float4x4(a.x * b, a.y * b, a.z * b, a.w * b);
- }
-
- public static bool operator ==(float4x4 a, float4x4 b)
- {
- return (a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w);
- }
-
- public static bool operator !=(float4x4 a, float4x4 b)
- {
- return !(a == b);
- }
-
- public static float4x4 Inverse(float4x4 m)
- {
- float4x4 d = new float4x4();
- //float dst = d.x.x;
- float[] tmp = new float[12]; // temp array for pairs
- float[] src = new float[16]; // array of transpose source matrix
- float det; // determinant
- // transpose matrix
- for (int i = 0; i < 4; i++)
- {
- src[i] = m[i].x;
- src[i + 4] = m[i].y;
- src[i + 8] = m[i].z;
- src[i + 12] = m[i].w;
- }
- // calculate pairs for first 8 elements (cofactors)
- tmp[0] = src[10] * src[15];
- tmp[1] = src[11] * src[14];
- tmp[2] = src[9] * src[15];
- tmp[3] = src[11] * src[13];
- tmp[4] = src[9] * src[14];
- tmp[5] = src[10] * src[13];
- tmp[6] = src[8] * src[15];
- tmp[7] = src[11] * src[12];
- tmp[8] = src[8] * src[14];
- tmp[9] = src[10] * src[12];
- tmp[10] = src[8] * src[13];
- tmp[11] = src[9] * src[12];
- // calculate first 8 elements (cofactors)
- d.x.x = tmp[0]*src[5] + tmp[3]*src[6] + tmp[4]*src[7];
- d.x.x -= tmp[1]*src[5] + tmp[2]*src[6] + tmp[5]*src[7];
- d.x.y = tmp[1]*src[4] + tmp[6]*src[6] + tmp[9]*src[7];
- d.x.y -= tmp[0]*src[4] + tmp[7]*src[6] + tmp[8]*src[7];
- d.x.z = tmp[2]*src[4] + tmp[7]*src[5] + tmp[10]*src[7];
- d.x.z -= tmp[3]*src[4] + tmp[6]*src[5] + tmp[11]*src[7];
- d.x.w = tmp[5]*src[4] + tmp[8]*src[5] + tmp[11]*src[6];
- d.x.w -= tmp[4]*src[4] + tmp[9]*src[5] + tmp[10]*src[6];
- d.y.x = tmp[1]*src[1] + tmp[2]*src[2] + tmp[5]*src[3];
- d.y.x -= tmp[0]*src[1] + tmp[3]*src[2] + tmp[4]*src[3];
- d.y.y = tmp[0]*src[0] + tmp[7]*src[2] + tmp[8]*src[3];
- d.y.y -= tmp[1]*src[0] + tmp[6]*src[2] + tmp[9]*src[3];
- d.y.z = tmp[3]*src[0] + tmp[6]*src[1] + tmp[11]*src[3];
- d.y.z -= tmp[2]*src[0] + tmp[7]*src[1] + tmp[10]*src[3];
- d.y.w = tmp[4]*src[0] + tmp[9]*src[1] + tmp[10]*src[2];
- d.y.w -= tmp[5]*src[0] + tmp[8]*src[1] + tmp[11]*src[2];
- // calculate pairs for second 8 elements (cofactors)
- tmp[0] = src[2]*src[7];
- tmp[1] = src[3]*src[6];
- tmp[2] = src[1]*src[7];
- tmp[3] = src[3]*src[5];
- tmp[4] = src[1]*src[6];
- tmp[5] = src[2]*src[5];
- tmp[6] = src[0]*src[7];
- tmp[7] = src[3]*src[4];
- tmp[8] = src[0]*src[6];
- tmp[9] = src[2]*src[4];
- tmp[10] = src[0]*src[5];
- tmp[11] = src[1]*src[4];
- // calculate second 8 elements (cofactors)
- d.z.x = tmp[0]*src[13] + tmp[3]*src[14] + tmp[4]*src[15];
- d.z.x -= tmp[1]*src[13] + tmp[2]*src[14] + tmp[5]*src[15];
- d.z.y = tmp[1]*src[12] + tmp[6]*src[14] + tmp[9]*src[15];
- d.z.y -= tmp[0]*src[12] + tmp[7]*src[14] + tmp[8]*src[15];
- d.z.z = tmp[2]*src[12] + tmp[7]*src[13] + tmp[10]*src[15];
- d.z.z -= tmp[3]*src[12] + tmp[6]*src[13] + tmp[11]*src[15];
- d.z.w = tmp[5]*src[12] + tmp[8]*src[13] + tmp[11]*src[14];
- d.z.w-= tmp[4]*src[12] + tmp[9]*src[13] + tmp[10]*src[14];
- d.w.x = tmp[2]*src[10] + tmp[5]*src[11] + tmp[1]*src[9];
- d.w.x-= tmp[4]*src[11] + tmp[0]*src[9] + tmp[3]*src[10];
- d.w.y = tmp[8]*src[11] + tmp[0]*src[8] + tmp[7]*src[10];
- d.w.y-= tmp[6]*src[10] + tmp[9]*src[11] + tmp[1]*src[8];
- d.w.z = tmp[6]*src[9] + tmp[11]*src[11] + tmp[3]*src[8];
- d.w.z-= tmp[10]*src[11] + tmp[2]*src[8] + tmp[7]*src[9];
- d.w.w = tmp[10]*src[10] + tmp[4]*src[8] + tmp[9]*src[9];
- d.w.w-= tmp[8]*src[9] + tmp[11]*src[10] + tmp[5]*src[8];
- // calculate determinant
- det = src[0] * d.x.x + src[1] * d.x.y + src[2] * d.x.z + src[3] * d.x.w;
- // calculate matrix inverse
- det = 1/det;
- for (int j = 0; j < 4; j++)
- d[j] *= det;
- return d;
- }
-
- public static float4x4 MatrixRigidInverse(float4x4 m)
- {
- float4x4 trans_inverse = MatrixTranslation(-m.w.xyz());
- float4x4 rot = new float4x4(m);
- rot.w = new float4(0f, 0f, 0f, 1f);
- return trans_inverse * MatrixTranspose(rot);
- }
- public static float4x4 MatrixTranspose(float4x4 m)
- {
- return new float4x4(m.x.x, m.y.x, m.z.x, m.w.x, m.x.y, m.y.y, m.z.y, m.w.y, m.x.z, m.y.z, m.z.z, m.w.z, m.x.w, m.y.w, m.z.w, m.w.w);
- }
- public static float4x4 MatrixPerspectiveFov(float fovy, float aspect, float zn, float zf)
- {
- float h = 1.0f / (float)Math.Tan(fovy / 2.0f); // view space height
- float w = h / aspect; // view space width
- return new float4x4(w, 0, 0, 0, 0, h, 0, 0, 0, 0, zf / (zn - zf), -1, 0, 0, zn * zf / (zn - zf), 0);
- }
- public static float4x4 MatrixTranslation(float3 t)
- {
- return new float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t.x, t.y, t.z, 1);
- }
- public static float4x4 MatrixRotationZ(float angle_radians)
- {
- float s = (float)Math.Sin(angle_radians);
- float c = (float)Math.Cos(angle_radians);
- return new float4x4(c, s, 0, 0, -s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
- }
- public static float4x4 MatrixLookAt(float3 eye, float3 at, float3 up)
- {
- float4x4 m = new float4x4();
- m.w.w = 1.0f;
- m.w.setxyz(eye);
- m.z.setxyz(float3.normalize(eye - at));
- m.x.setxyz(float3.normalize(float3.cross(up, m.z.xyz())));
- m.y.setxyz(float3.cross(m.z.xyz(), m.x.xyz()));
- return MatrixRigidInverse(m);
- }
-
- public static float4x4 MatrixFromQuatVec(Quaternion q, float3 v)
- {
- // builds a 4x4 transformation matrix based on orientation q and translation v
- float qx2 = q.x * q.x;
- float qy2 = q.y * q.y;
- float qz2 = q.z * q.z;
-
- float qxqy = q.x * q.y;
- float qxqz = q.x * q.z;
- float qxqw = q.x * q.w;
- float qyqz = q.y * q.z;
- float qyqw = q.y * q.w;
- float qzqw = q.z * q.w;
-
- return new float4x4(
- 1 - 2 * (qy2 + qz2),
- 2 * (qxqy + qzqw),
- 2 * (qxqz - qyqw),
- 0,
- 2 * (qxqy - qzqw),
- 1 - 2 * (qx2 + qz2),
- 2 * (qyqz + qxqw),
- 0,
- 2 * (qxqz + qyqw),
- 2 * (qyqz - qxqw),
- 1 - 2 * (qx2 + qy2),
- 0,
- v.x,
- v.y,
- v.z,
- 1.0f);
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/int3.cs b/addon-modules/ConvexDecompositionDotNet/int3.cs
deleted file mode 100644
index 9c5760d7e9..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/int3.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class int3
- {
- public int x;
- public int y;
- public int z;
-
- public int3()
- {
- }
-
- public int3(int _x, int _y, int _z)
- {
- x = _x;
- y = _y;
- z = _z;
- }
-
- public int this[int i]
- {
- get
- {
- switch (i)
- {
- case 0: return x;
- case 1: return y;
- case 2: return z;
- }
- throw new ArgumentOutOfRangeException();
- }
- set
- {
- switch (i)
- {
- case 0: x = value; return;
- case 1: y = value; return;
- case 2: z = value; return;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
-
- public override int GetHashCode()
- {
- return x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode();
- }
-
- public override bool Equals(object obj)
- {
- int3 i = obj as int3;
- if (i == null)
- return false;
-
- return this == i;
- }
-
- public static bool operator ==(int3 a, int3 b)
- {
- // If both are null, or both are same instance, return true.
- if (System.Object.ReferenceEquals(a, b))
- return true;
- // If one is null, but not both, return false.
- if (((object)a == null) || ((object)b == null))
- return false;
-
- for (int i = 0; i < 3; i++)
- {
- if (a[i] != b[i])
- return false;
- }
- return true;
- }
-
- public static bool operator !=(int3 a, int3 b)
- {
- return !(a == b);
- }
-
- public static int3 roll3(int3 a)
- {
- int tmp = a[0];
- a[0] = a[1];
- a[1] = a[2];
- a[2] = tmp;
- return a;
- }
-
- public static bool isa(int3 a, int3 b)
- {
- return (a == b || roll3(a) == b || a == roll3(b));
- }
-
- public static bool b2b(int3 a, int3 b)
- {
- return isa(a, new int3(b[2], b[1], b[0]));
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/int4.cs b/addon-modules/ConvexDecompositionDotNet/int4.cs
deleted file mode 100644
index c2b32e5a4d..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/int4.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-/* The MIT License
- *
- * Copyright (c) 2010 Intel Corporation.
- * All rights reserved.
- *
- * Based on the convexdecomposition library from
- * by John W. Ratcliff and Stan Melax.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-
-namespace OpenSim.Region.Physics.ConvexDecompositionDotNet
-{
- public class int4
- {
- public int x;
- public int y;
- public int z;
- public int w;
-
- public int4()
- {
- }
-
- public int4(int _x, int _y, int _z, int _w)
- {
- x = _x;
- y = _y;
- z = _z;
- w = _w;
- }
-
- public int this[int i]
- {
- get
- {
- switch (i)
- {
- case 0: return x;
- case 1: return y;
- case 2: return z;
- case 3: return w;
- }
- throw new ArgumentOutOfRangeException();
- }
- }
- }
-}
diff --git a/addon-modules/ConvexDecompositionDotNet/prebuild.xml b/addon-modules/ConvexDecompositionDotNet/prebuild.xml
deleted file mode 100644
index aaf2695c67..0000000000
--- a/addon-modules/ConvexDecompositionDotNet/prebuild.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- ../../bin/Physics/
-
-
-
-
- ../../bin/Physics/
-
-
-
- ../../bin/
-
-
-
-
-
-
-
-
-
-
-