aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs347
1 files changed, 175 insertions, 172 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 1c569b5..638fae1 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -1,173 +1,176 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyrightD 9 * * Redistributions in binary form must reproduce the above copyrightD
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30 30
31using OMV = OpenMetaverse; 31using OMV = OpenMetaverse;
32 32
33namespace OpenSim.Region.Physics.BulletSPlugin 33namespace OpenSim.Region.Physics.BulletSPlugin
34{ 34{
35public sealed class BSLinksetCompound : BSLinkset 35public sealed class BSLinksetCompound : BSLinkset
36{ 36{
37 // private static string LogHeader = "[BULLETSIM LINKSET CONSTRAINTS]"; 37 // private static string LogHeader = "[BULLETSIM LINKSET CONSTRAINTS]";
38 38
39 public BSLinksetCompound(BSScene scene, BSPhysObject parent) 39 public BSLinksetCompound(BSScene scene, BSPhysObject parent)
40 { 40 {
41 base.Initialize(scene, parent); 41 base.Initialize(scene, parent);
42 } 42 }
43 43
44 // When physical properties are changed the linkset needs to recalculate 44 // When physical properties are changed the linkset needs to recalculate
45 // its internal properties. 45 // its internal properties.
46 // This is queued in the 'post taint' queue so the 46 // This is queued in the 'post taint' queue so the
47 // refresh will happen once after all the other taints are applied. 47 // refresh will happen once after all the other taints are applied.
48 public override void Refresh(BSPhysObject requestor) 48 public override void Refresh(BSPhysObject requestor)
49 { 49 {
50 // Queue to happen after all the other taint processing 50 // Queue to happen after all the other taint processing
51 PhysicsScene.PostTaintObject("BSLinksetcompound.Refresh", requestor.LocalID, delegate() 51 PhysicsScene.PostTaintObject("BSLinksetcompound.Refresh", requestor.LocalID, delegate()
52 { 52 {
53 if (HasAnyChildren && IsRoot(requestor)) 53 if (HasAnyChildren && IsRoot(requestor))
54 RecomputeLinksetCompound(); 54 RecomputeLinksetCompound();
55 }); 55 });
56 } 56 }
57 57
58 // The object is going dynamic (physical). Do any setup necessary 58 // The object is going dynamic (physical). Do any setup necessary
59 // for a dynamic linkset. 59 // for a dynamic linkset.
60 // Only the state of the passed object can be modified. The rest of the linkset 60 // Only the state of the passed object can be modified. The rest of the linkset
61 // has not yet been fully constructed. 61 // has not yet been fully constructed.
62 // Return 'true' if any properties updated on the passed object. 62 // Return 'true' if any properties updated on the passed object.
63 // Called at taint-time! 63 // Called at taint-time!
64 public override bool MakeDynamic(BSPhysObject child) 64 public override bool MakeDynamic(BSPhysObject child)
65 { 65 {
66 // What is done for each object in BSPrim is what we want. 66 // What is done for each object in BSPrim is what we want.
67 return false; 67 return false;
68 } 68 }
69 69
70 // The object is going static (non-physical). Do any setup necessary for a static linkset. 70 // The object is going static (non-physical). Do any setup necessary for a static linkset.
71 // Return 'true' if any properties updated on the passed object. 71 // Return 'true' if any properties updated on the passed object.
72 // This doesn't normally happen -- OpenSim removes the objects from the physical 72 // This doesn't normally happen -- OpenSim removes the objects from the physical
73 // world if it is a static linkset. 73 // world if it is a static linkset.
74 // Called at taint-time! 74 // Called at taint-time!
75 public override bool MakeStatic(BSPhysObject child) 75 public override bool MakeStatic(BSPhysObject child)
76 { 76 {
77 // What is done for each object in BSPrim is what we want. 77 // What is done for each object in BSPrim is what we want.
78 return false; 78 return false;
79 } 79 }
80 80
81 // Called at taint-time!! 81 // Called at taint-time!!
82 public override void UpdateProperties(BSPhysObject updated) 82 public override void UpdateProperties(BSPhysObject updated)
83 { 83 {
84 // Nothing to do for constraints on property updates 84 // Nothing to do for constraints on property updates
85 } 85 }
86 86
87 // Routine called when rebuilding the body of some member of the linkset. 87 // Routine called when rebuilding the body of some member of the linkset.
88 // Destroy all the constraints have have been made to root and set 88 // Destroy all the constraints have have been made to root and set
89 // up to rebuild the constraints before the next simulation step. 89 // up to rebuild the constraints before the next simulation step.
90 // Returns 'true' of something was actually removed and would need restoring 90 // Returns 'true' of something was actually removed and would need restoring
91 // Called at taint-time!! 91 // Called at taint-time!!
92 public override bool RemoveBodyDependencies(BSPrim child) 92 public override bool RemoveBodyDependencies(BSPrim child)
93 { 93 {
94 bool ret = false; 94 bool ret = false;
95 95
96 DetailLog("{0},BSLinksetcompound.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}", 96 DetailLog("{0},BSLinksetcompound.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}",
97 child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X")); 97 child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"));
98 98
99 // Cause the current shape to be freed and the new one to be built. 99 // Cause the current shape to be freed and the new one to be built.
100 Refresh(LinksetRoot); 100 Refresh(LinksetRoot);
101 101
102 return ret; 102 return ret;
103 } 103 }
104 104
105 // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true', 105 // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true',
106 // this routine will restore the removed constraints. 106 // this routine will restore the removed constraints.
107 // Called at taint-time!! 107 // Called at taint-time!!
108 public override void RestoreBodyDependencies(BSPrim child) 108 public override void RestoreBodyDependencies(BSPrim child)
109 { 109 {
110 // The Refresh operation queued by RemoveBodyDependencies() will build any missing constraints. 110 // The Refresh operation queued by RemoveBodyDependencies() will build any missing constraints.
111 } 111 }
112 112
113 // ================================================================ 113 // ================================================================
114 114
115 // Add a new child to the linkset. 115 // Add a new child to the linkset.
116 // Called while LinkActivity is locked. 116 // Called while LinkActivity is locked.
117 protected override void AddChildToLinkset(BSPhysObject child) 117 protected override void AddChildToLinkset(BSPhysObject child)
118 { 118 {
119 if (!HasChild(child)) 119 if (!HasChild(child))
120 { 120 {
121 m_children.Add(child); 121 m_children.Add(child);
122 122
123 DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); 123 DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID);
124 124
125 // Cause constraints and assorted properties to be recomputed before the next simulation step. 125 // Cause constraints and assorted properties to be recomputed before the next simulation step.
126 Refresh(LinksetRoot); 126 Refresh(LinksetRoot);
127 } 127 }
128 return; 128 return;
129 } 129 }
130 130
131 // Remove the specified child from the linkset. 131 // Remove the specified child from the linkset.
132 // Safe to call even if the child is not really in my linkset. 132 // Safe to call even if the child is not really in my linkset.
133 protected override void RemoveChildFromLinkset(BSPhysObject child) 133 protected override void RemoveChildFromLinkset(BSPhysObject child)
134 { 134 {
135 if (m_children.Remove(child)) 135 if (m_children.Remove(child))
136 { 136 {
137 DetailLog("{0},BSLinksetCompound.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", 137 DetailLog("{0},BSLinksetCompound.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}",
138 child.LocalID, 138 child.LocalID,
139 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), 139 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"),
140 child.LocalID, child.PhysBody.ptr.ToString("X")); 140 child.LocalID, child.PhysBody.ptr.ToString("X"));
141 141
142 // See that the linkset parameters are recomputed at the end of the taint time. 142 // See that the linkset parameters are recomputed at the end of the taint time.
143 Refresh(LinksetRoot); 143 Refresh(LinksetRoot);
144 } 144 }
145 else 145 else
146 { 146 {
147 // Non-fatal occurance. 147 // Non-fatal occurance.
148 // PhysicsScene.Logger.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset", LogHeader); 148 // PhysicsScene.Logger.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset", LogHeader);
149 } 149 }
150 return; 150 return;
151 } 151 }
152 152
153 153
154 // Call each of the constraints that make up this linkset and recompute the 154 // Call each of the constraints that make up this linkset and recompute the
155 // various transforms and variables. Create constraints of not created yet. 155 // various transforms and variables. Create constraints of not created yet.
156 // Called before the simulation step to make sure the constraint based linkset 156 // Called before the simulation step to make sure the constraint based linkset
157 // is all initialized. 157 // is all initialized.
158 // Called at taint time!! 158 // Called at taint time!!
159 private void RecomputeLinksetCompound() 159 private void RecomputeLinksetCompound()
160 { 160 {
161 float linksetMass = LinksetMass; 161 // Release the existing shape
162 LinksetRoot.UpdatePhysicalMassProperties(linksetMass); 162 PhysicsScene.Shapes.DereferenceShape(LinksetRoot.PhysShape, true, null);
163 163
164 // DEBUG: see of inter-linkset collisions are causing problems 164 float linksetMass = LinksetMass;
165 // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, 165 LinksetRoot.UpdatePhysicalMassProperties(linksetMass);
166 // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); 166
167 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,set,rBody={1},linksetMass={2}", 167 // DEBUG: see of inter-linkset collisions are causing problems
168 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), linksetMass); 168 // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr,
169 169 // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask);
170 170 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,set,rBody={1},linksetMass={2}",
171 } 171 LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), linksetMass);
172} 172
173
174 }
175}
173} \ No newline at end of file 176} \ No newline at end of file