diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs')
-rwxr-xr-x | OpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs new file mode 100755 index 0000000..a1cf4db --- /dev/null +++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorSetTorque.cs | |||
@@ -0,0 +1,139 @@ | |||
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 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Text; | ||
32 | |||
33 | using OpenSim.Region.PhysicsModules.SharedBase; | ||
34 | |||
35 | using OMV = OpenMetaverse; | ||
36 | |||
37 | namespace OpenSim.Region.PhysicsModule.BulletS | ||
38 | { | ||
39 | public class BSActorSetTorque : BSActor | ||
40 | { | ||
41 | BSFMotor m_torqueMotor; | ||
42 | |||
43 | public BSActorSetTorque(BSScene physicsScene, BSPhysObject pObj, string actorName) | ||
44 | : base(physicsScene, pObj, actorName) | ||
45 | { | ||
46 | m_torqueMotor = null; | ||
47 | m_physicsScene.DetailLog("{0},BSActorSetTorque,constructor", m_controllingPrim.LocalID); | ||
48 | } | ||
49 | |||
50 | // BSActor.isActive | ||
51 | public override bool isActive | ||
52 | { | ||
53 | get { return Enabled && m_controllingPrim.IsPhysicallyActive; } | ||
54 | } | ||
55 | |||
56 | // Release any connections and resources used by the actor. | ||
57 | // BSActor.Dispose() | ||
58 | public override void Dispose() | ||
59 | { | ||
60 | Enabled = false; | ||
61 | DeactivateSetTorque(); | ||
62 | } | ||
63 | |||
64 | // Called when physical parameters (properties set in Bullet) need to be re-applied. | ||
65 | // Called at taint-time. | ||
66 | // BSActor.Refresh() | ||
67 | public override void Refresh() | ||
68 | { | ||
69 | m_physicsScene.DetailLog("{0},BSActorSetTorque,refresh,torque={1}", m_controllingPrim.LocalID, m_controllingPrim.RawTorque); | ||
70 | |||
71 | // If not active any more, get rid of me (shouldn't ever happen, but just to be safe) | ||
72 | if (m_controllingPrim.RawTorque == OMV.Vector3.Zero) | ||
73 | { | ||
74 | m_physicsScene.DetailLog("{0},BSActorSetTorque,refresh,notSetTorque,disabling={1}", m_controllingPrim.LocalID, ActorName); | ||
75 | Enabled = false; | ||
76 | return; | ||
77 | } | ||
78 | |||
79 | // If the object is physically active, add the hoverer prestep action | ||
80 | if (isActive) | ||
81 | { | ||
82 | ActivateSetTorque(); | ||
83 | } | ||
84 | else | ||
85 | { | ||
86 | DeactivateSetTorque(); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | // The object's physical representation is being rebuilt so pick up any physical dependencies (constraints, ...). | ||
91 | // Register a prestep action to restore physical requirements before the next simulation step. | ||
92 | // Called at taint-time. | ||
93 | // BSActor.RemoveDependencies() | ||
94 | public override void RemoveDependencies() | ||
95 | { | ||
96 | // Nothing to do for the hoverer since it is all software at pre-step action time. | ||
97 | } | ||
98 | |||
99 | // If a hover motor has not been created, create one and start the hovering. | ||
100 | private void ActivateSetTorque() | ||
101 | { | ||
102 | if (m_torqueMotor == null) | ||
103 | { | ||
104 | // A fake motor that might be used someday | ||
105 | m_torqueMotor = new BSFMotor("setTorque", 1f, 1f, 1f); | ||
106 | |||
107 | m_physicsScene.BeforeStep += Mover; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | private void DeactivateSetTorque() | ||
112 | { | ||
113 | if (m_torqueMotor != null) | ||
114 | { | ||
115 | m_physicsScene.BeforeStep -= Mover; | ||
116 | m_torqueMotor = null; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | // Called just before the simulation step. Update the vertical position for hoverness. | ||
121 | private void Mover(float timeStep) | ||
122 | { | ||
123 | // Don't do force while the object is selected. | ||
124 | if (!isActive) | ||
125 | return; | ||
126 | |||
127 | m_physicsScene.DetailLog("{0},BSActorSetTorque,preStep,force={1}", m_controllingPrim.LocalID, m_controllingPrim.RawTorque); | ||
128 | if (m_controllingPrim.PhysBody.HasPhysicalBody) | ||
129 | { | ||
130 | m_controllingPrim.AddAngularForce(m_controllingPrim.RawTorque, false, true); | ||
131 | m_controllingPrim.ActivateIfPhysical(false); | ||
132 | } | ||
133 | |||
134 | // TODO: | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | |||
139 | |||