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