diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 317 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 108 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 133 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsActor.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 83 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 128 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 119 |
7 files changed, 562 insertions, 328 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index b1b0f5b..81ca9f1 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs | |||
@@ -33,45 +33,115 @@ using OpenSim.Framework; | |||
33 | 33 | ||
34 | namespace OpenSim.Region.Framework.Scenes | 34 | namespace OpenSim.Region.Framework.Scenes |
35 | { | 35 | { |
36 | public static class CollisionSounds | 36 | public struct CollisionForSoundInfo |
37 | { | 37 | { |
38 | // defines for cases | 38 | public uint colliderID; |
39 | // only know one UUID for now (woodflesh) | 39 | public Vector3 position; |
40 | public float relativeVel; | ||
41 | } | ||
40 | 42 | ||
43 | public static class CollisionSounds | ||
44 | { | ||
41 | private const int MaxMaterials = 7; | 45 | private const int MaxMaterials = 7; |
42 | // part part | 46 | // part part |
43 | private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 47 | /* |
44 | private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 48 | private static UUID snd_StoneStone = new UUID("be7295c0-a158-11e1-b3dd-0800200c9a66"); |
45 | private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 49 | private static UUID snd_StoneMetal = new UUID("be7295c0-a158-11e1-b3dd-0800201c9a66"); |
46 | private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 50 | private static UUID snd_StoneGlass = new UUID("be7295c0-a158-11e1-b3dd-0800202c9a66"); |
47 | private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 51 | private static UUID snd_StoneWood = new UUID("be7295c0-a158-11e1-b3dd-0800203c9a66"); |
48 | private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 52 | private static UUID snd_StoneFlesh = new UUID("be7295c0-a158-11e1-b3dd-0800204c9a66"); |
49 | private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 53 | private static UUID snd_StonePlastic = new UUID("be7295c0-a158-11e1-b3dd-0800205c9a66"); |
50 | 54 | private static UUID snd_StoneRubber = new UUID("be7295c0-a158-11e1-b3dd-0800206c9a66"); | |
51 | private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 55 | |
52 | private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 56 | private static UUID snd_MetalStone = new UUID("be7295c0-a158-11e1-b3dd-0801200c9a66"); |
53 | private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 57 | private static UUID snd_MetalMetal = new UUID("be7295c0-a158-11e1-b3dd-0801201c9a66"); |
54 | private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 58 | private static UUID snd_MetalGlass = new UUID("be7295c0-a158-11e1-b3dd-0801202c9a66"); |
55 | private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 59 | private static UUID snd_MetalWood = new UUID("be7295c0-a158-11e1-b3dd-0801203c9a66"); |
56 | private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 60 | private static UUID snd_MetalFlesh = new UUID("be7295c0-a158-11e1-b3dd-0801204c9a66"); |
57 | 61 | private static UUID snd_MetalPlastic = new UUID("be7295c0-a158-11e1-b3dd-0801205c9a66"); | |
58 | private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 62 | private static UUID snd_MetalRubber = new UUID("be7295c0-a158-11e1-b3dd-0801206c9a66"); |
59 | private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 63 | |
60 | private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 64 | private static UUID snd_GlassStone = new UUID("be7295c0-a158-11e1-b3dd-0802200c9a66"); |
61 | private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 65 | private static UUID snd_GlassMetal = new UUID("be7295c0-a158-11e1-b3dd-0802201c9a66"); |
62 | private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 66 | private static UUID snd_GlassGlass = new UUID("be7295c0-a158-11e1-b3dd-0802202c9a66"); |
63 | 67 | private static UUID snd_GlassWood = new UUID("be7295c0-a158-11e1-b3dd-0802203c9a66"); | |
64 | private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 68 | private static UUID snd_GlassFlesh = new UUID("be7295c0-a158-11e1-b3dd-0802204c9a66"); |
65 | private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 69 | private static UUID snd_GlassPlastic = new UUID("be7295c0-a158-11e1-b3dd-0802205c9a66"); |
66 | private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 70 | private static UUID snd_GlassRubber = new UUID("be7295c0-a158-11e1-b3dd-0802206c9a66"); |
67 | private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 71 | |
68 | 72 | private static UUID snd_WoodStone = new UUID("be7295c0-a158-11e1-b3dd-0803200c9a66"); | |
69 | private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 73 | private static UUID snd_WoodMetal = new UUID("be7295c0-a158-11e1-b3dd-0803201c9a66"); |
70 | private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 74 | private static UUID snd_WoodGlass = new UUID("be7295c0-a158-11e1-b3dd-0803202c9a66"); |
71 | private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 75 | private static UUID snd_WoodWood = new UUID("be7295c0-a158-11e1-b3dd-0803203c9a66"); |
72 | 76 | private static UUID snd_WoodFlesh = new UUID("be7295c0-a158-11e1-b3dd-0803204c9a66"); | |
73 | private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 77 | private static UUID snd_WoodPlastic = new UUID("be7295c0-a158-11e1-b3dd-0803205c9a66"); |
74 | private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 78 | private static UUID snd_WoodRubber = new UUID("be7295c0-a158-11e1-b3dd-0803206c9a66"); |
79 | |||
80 | private static UUID snd_FleshStone = new UUID("be7295c0-a158-11e1-b3dd-0804200c9a66"); | ||
81 | private static UUID snd_FleshMetal = new UUID("be7295c0-a158-11e1-b3dd-0804201c9a66"); | ||
82 | private static UUID snd_FleshGlass = new UUID("be7295c0-a158-11e1-b3dd-0804202c9a66"); | ||
83 | private static UUID snd_FleshWood = new UUID("be7295c0-a158-11e1-b3dd-0804203c9a66"); | ||
84 | private static UUID snd_FleshFlesh = new UUID("be7295c0-a158-11e1-b3dd-0804204c9a66"); | ||
85 | private static UUID snd_FleshPlastic = new UUID("be7295c0-a158-11e1-b3dd-0804205c9a66"); | ||
86 | private static UUID snd_FleshRubber = new UUID("be7295c0-a158-11e1-b3dd-0804206c9a66"); | ||
87 | |||
88 | private static UUID snd_PlasticStone = new UUID("be7295c0-a158-11e1-b3dd-0805200c9a66"); | ||
89 | private static UUID snd_PlasticMetal = new UUID("be7295c0-a158-11e1-b3dd-0805201c9a66"); | ||
90 | private static UUID snd_PlasticGlass = new UUID("be7295c0-a158-11e1-b3dd-0805202c9a66"); | ||
91 | private static UUID snd_PlasticWood = new UUID("be7295c0-a158-11e1-b3dd-0805203c9a66"); | ||
92 | private static UUID snd_PlasticFlesh = new UUID("be7295c0-a158-11e1-b3dd-0805204c9a66"); | ||
93 | private static UUID snd_PlasticPlastic = new UUID("be7295c0-a158-11e1-b3dd-0805205c9a66"); | ||
94 | private static UUID snd_PlasticRubber = new UUID("be7295c0-a158-11e1-b3dd-0805206c9a66"); | ||
95 | |||
96 | private static UUID snd_RubberStone = new UUID("be7295c0-a158-11e1-b3dd-0806200c9a66"); | ||
97 | private static UUID snd_RubberMetal = new UUID("be7295c0-a158-11e1-b3dd-0806201c9a66"); | ||
98 | private static UUID snd_RubberGlass = new UUID("be7295c0-a158-11e1-b3dd-0806202c9a66"); | ||
99 | private static UUID snd_RubberWood = new UUID("be7295c0-a158-11e1-b3dd-0806203c9a66"); | ||
100 | private static UUID snd_RubberFlesh = new UUID("be7295c0-a158-11e1-b3dd-0806204c9a66"); | ||
101 | private static UUID snd_RubberPlastic = new UUID("be7295c0-a158-11e1-b3dd-0806205c9a66"); | ||
102 | private static UUID snd_RubberRubber = new UUID("be7295c0-a158-11e1-b3dd-0806206c9a66"); | ||
103 | |||
104 | // terrain part | ||
105 | private static UUID snd_TerrainStone = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
106 | private static UUID snd_TerrainMetal = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
107 | private static UUID snd_TerrainGlass = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
108 | private static UUID snd_TerrainWood = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
109 | private static UUID snd_TerrainFlesh = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
110 | private static UUID snd_TerrainPlastic = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
111 | private static UUID snd_TerrainRubber = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
112 | */ | ||
113 | private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
114 | private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
115 | private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
116 | private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
117 | private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
118 | private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
119 | private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
120 | |||
121 | private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
122 | private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
123 | private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
124 | private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
125 | private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
126 | private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
127 | |||
128 | private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
129 | private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
130 | private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
131 | private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
132 | private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
133 | |||
134 | private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
135 | private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
136 | private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
137 | private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
138 | |||
139 | private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
140 | private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
141 | private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
142 | |||
143 | private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
144 | private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | ||
75 | 145 | ||
76 | private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 146 | private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
77 | 147 | ||
@@ -93,7 +163,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
93 | snd_TerrainPlastic, | 163 | snd_TerrainPlastic, |
94 | snd_TerrainRubber | 164 | snd_TerrainRubber |
95 | }; | 165 | }; |
96 | 166 | /* | |
167 | //full assimetric sounds | ||
168 | public static UUID[] m_PartPart = { | ||
169 | snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, | ||
170 | snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, | ||
171 | snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, | ||
172 | snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, | ||
173 | snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, | ||
174 | snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber, | ||
175 | snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber | ||
176 | }; | ||
177 | */ | ||
178 | // simetric sounds | ||
97 | public static UUID[] m_PartPart = { | 179 | public static UUID[] m_PartPart = { |
98 | snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, | 180 | snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, |
99 | snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, | 181 | snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, |
@@ -103,13 +185,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber, | 185 | snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber, |
104 | snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber | 186 | snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber |
105 | }; | 187 | }; |
106 | 188 | ||
107 | public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders) | 189 | public static void PartCollisionSound(SceneObjectPart part, List<CollisionForSoundInfo> collidersinfolist) |
108 | { | 190 | { |
109 | // temporary mute sounds | 191 | if (collidersinfolist.Count == 0 || part == null) |
110 | return; | ||
111 | |||
112 | if(Colliders.Count == 0 || part == null) | ||
113 | return; | 192 | return; |
114 | 193 | ||
115 | if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) | 194 | if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) |
@@ -118,124 +197,161 @@ namespace OpenSim.Region.Framework.Scenes | |||
118 | if (part.ParentGroup == null) | 197 | if (part.ParentGroup == null) |
119 | return; | 198 | return; |
120 | 199 | ||
121 | if (part.CollisionSound == part.invalidCollisionSoundUUID) | 200 | if (part.CollisionSoundType < 0) |
122 | return; | 201 | return; |
123 | 202 | ||
124 | UUID soundID; | 203 | float volume = 0.0f; |
125 | int otherMaterial; | 204 | bool HaveSound = false; |
126 | 205 | ||
127 | Vector3 position = part.AbsolutePosition; | 206 | UUID soundID = part.CollisionSound; |
128 | 207 | ||
129 | if (part.CollisionSound != UUID.Zero) | 208 | if (part.CollisionSoundType > 0) |
130 | { | 209 | { |
131 | if (part.CollisionSoundVolume > 0.0f) | 210 | // soundID = part.CollisionSound; |
132 | part.SendCollisionSound(part.CollisionSound, part.CollisionSoundVolume, position); | 211 | volume = part.CollisionSoundVolume; |
133 | return; | 212 | if (volume == 0.0f) |
213 | return; | ||
214 | HaveSound = true; | ||
134 | } | 215 | } |
135 | 216 | ||
136 | int thisMaterial = (int) part.Material; | 217 | bool doneownsound = false; |
218 | |||
219 | int thisMaterial = (int)part.Material; | ||
137 | if (thisMaterial >= MaxMaterials) | 220 | if (thisMaterial >= MaxMaterials) |
138 | thisMaterial = 3; | 221 | thisMaterial = 3; |
139 | |||
140 | int thisMatScaled = thisMaterial * MaxMaterials; | 222 | int thisMatScaled = thisMaterial * MaxMaterials; |
141 | int index; | ||
142 | 223 | ||
143 | bool doneownsound = false; | 224 | CollisionForSoundInfo colInfo; |
225 | uint id; | ||
144 | 226 | ||
145 | foreach (uint Id in Colliders) | 227 | for(int i = 0; i< collidersinfolist.Count; i++) |
146 | { | 228 | { |
147 | if (Id == 0) | 229 | colInfo = collidersinfolist[i]; |
230 | |||
231 | id = colInfo.colliderID; | ||
232 | if (id == 0) // terrain collision | ||
148 | { | 233 | { |
149 | if (!doneownsound) | 234 | if (!doneownsound) |
150 | { | 235 | { |
151 | soundID = m_TerrainPart[thisMaterial]; | 236 | if (!HaveSound) |
152 | part.SendCollisionSound(soundID, 1.0, position); | 237 | { |
238 | volume = Math.Abs(colInfo.relativeVel); | ||
239 | if (volume < 0.2f) | ||
240 | continue; | ||
241 | |||
242 | volume *= volume * .0625f; // 4m/s == full volume | ||
243 | if (volume > 1.0f) | ||
244 | volume = 1.0f; | ||
245 | |||
246 | soundID = m_TerrainPart[thisMaterial]; | ||
247 | } | ||
248 | part.SendCollisionSound(soundID, volume, colInfo.position); | ||
153 | doneownsound = true; | 249 | doneownsound = true; |
154 | } | 250 | } |
155 | continue; | 251 | continue; |
156 | } | 252 | } |
157 | 253 | ||
158 | SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id); | 254 | SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); |
159 | if (otherPart != null) | 255 | if (otherPart != null) |
160 | { | 256 | { |
161 | if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) | 257 | if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) |
162 | continue; | 258 | continue; |
163 | if (otherPart.CollisionSound != UUID.Zero) | 259 | |
164 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); | 260 | if (!HaveSound) |
165 | else | ||
166 | { | 261 | { |
167 | otherMaterial = (int)otherPart.Material; | 262 | if (otherPart.CollisionSoundType > 0) |
168 | if (otherMaterial >= MaxMaterials) | 263 | { |
169 | otherMaterial = 3; | 264 | soundID = otherPart.CollisionSound; |
170 | index = thisMatScaled + otherMaterial; | 265 | volume = otherPart.CollisionSoundVolume; |
171 | soundID = m_PartPart[index]; | 266 | if (volume == 0.0f) |
172 | if (doneownsound) | 267 | continue; |
173 | otherPart.SendCollisionSound(soundID, 1.0, position); | 268 | } |
174 | else | 269 | else |
175 | { | 270 | { |
176 | part.SendCollisionSound(soundID, 1.0, position); | 271 | volume = Math.Abs(colInfo.relativeVel); |
177 | doneownsound = true; | 272 | if (volume < 0.2f) |
273 | continue; | ||
274 | |||
275 | volume *= volume * .0625f; // 4m/s == full volume | ||
276 | if (volume > 1.0f) | ||
277 | volume = 1.0f; | ||
278 | |||
279 | int otherMaterial = (int)otherPart.Material; | ||
280 | if (otherMaterial >= MaxMaterials) | ||
281 | otherMaterial = 3; | ||
282 | |||
283 | soundID = m_PartPart[thisMatScaled + otherMaterial]; | ||
178 | } | 284 | } |
179 | } | 285 | } |
180 | } | 286 | |
181 | /* avatars get notification let them trigger the sound | 287 | if (doneownsound) |
182 | else if (!doneownsound) | 288 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); |
183 | { | 289 | else |
184 | ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id); | ||
185 | if (av != null && (!av.IsChildAgent)) | ||
186 | { | 290 | { |
187 | index = thisMatScaled + 4; // flesh | 291 | part.SendCollisionSound(soundID, volume, colInfo.position); |
188 | soundID = m_PartPart[index]; | ||
189 | part.SendCollisionSound(soundID, 1.0); | ||
190 | doneownsound = true; | 292 | doneownsound = true; |
191 | } | 293 | } |
192 | } | 294 | } |
193 | */ | ||
194 | } | 295 | } |
195 | } | 296 | } |
196 | 297 | ||
197 | public static void AvatarCollisionSound(ScenePresence av, List<uint> Colliders) | 298 | public static void AvatarCollisionSound(ScenePresence av, List<CollisionForSoundInfo> collidersinfolist) |
198 | { | 299 | { |
199 | // temporary mute sounds | 300 | if (collidersinfolist.Count == 0 || av == null) |
200 | return; | ||
201 | |||
202 | if (Colliders.Count == 0 || av == null) | ||
203 | return; | 301 | return; |
204 | 302 | ||
205 | UUID soundID; | 303 | UUID soundID; |
206 | int otherMaterial; | 304 | int otherMaterial; |
207 | 305 | ||
208 | int thisMaterial = 3; | 306 | int thisMaterial = 4; // flesh |
209 | 307 | ||
210 | int thisMatScaled = thisMaterial * MaxMaterials; | 308 | int thisMatScaled = thisMaterial * MaxMaterials; |
211 | int index; | ||
212 | // bool doneownsound = false; | ||
213 | 309 | ||
214 | Vector3 position = av.AbsolutePosition; | 310 | // bool doneownsound = false; |
215 | 311 | ||
216 | foreach (uint Id in Colliders) | 312 | CollisionForSoundInfo colInfo; |
313 | uint id; | ||
314 | float volume; | ||
315 | |||
316 | for(int i = 0; i< collidersinfolist.Count; i++) | ||
217 | { | 317 | { |
218 | if (Id == 0) | 318 | colInfo = collidersinfolist[i]; |
319 | |||
320 | id = colInfo.colliderID; | ||
321 | |||
322 | if (id == 0) // no terrain collision sounds for now | ||
219 | { | 323 | { |
220 | continue; | 324 | continue; |
325 | // volume = Math.Abs(colInfo.relativeVel); | ||
326 | // if (volume < 0.2f) | ||
327 | // continue; | ||
328 | |||
221 | } | 329 | } |
222 | 330 | ||
223 | SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id); | 331 | SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); |
224 | if (otherPart != null) | 332 | if (otherPart != null) |
225 | { | 333 | { |
226 | if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) | 334 | if (otherPart.CollisionSoundType < 0) |
227 | continue; | 335 | continue; |
228 | if (otherPart.CollisionSound != UUID.Zero) | 336 | if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) |
229 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); | 337 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); |
230 | else | 338 | else |
231 | { | 339 | { |
340 | volume = Math.Abs(colInfo.relativeVel); | ||
341 | if (volume < 0.2f) | ||
342 | continue; | ||
343 | |||
344 | volume *= volume * .0625f; // 4m/s == full volume | ||
345 | if (volume > 1.0f) | ||
346 | volume = 1.0f; | ||
232 | otherMaterial = (int)otherPart.Material; | 347 | otherMaterial = (int)otherPart.Material; |
233 | if (otherMaterial >= MaxMaterials) | 348 | if (otherMaterial >= MaxMaterials) |
234 | otherMaterial = 3; | 349 | otherMaterial = 3; |
235 | index = thisMatScaled + otherMaterial; | 350 | |
236 | soundID = m_PartPart[index]; | 351 | soundID = m_PartPart[thisMatScaled + otherMaterial]; |
237 | otherPart.SendCollisionSound(soundID, 1.0, position); | 352 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); |
238 | } | 353 | } |
354 | continue; | ||
239 | } | 355 | } |
240 | /* | 356 | /* |
241 | else if (!doneownsound) | 357 | else if (!doneownsound) |
@@ -251,6 +367,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
251 | */ | 367 | */ |
252 | } | 368 | } |
253 | } | 369 | } |
254 | |||
255 | } | 370 | } |
256 | } | 371 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b5705b7..2852c4b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -329,11 +329,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
329 | private Vector3 m_cameraAtOffset; | 329 | private Vector3 m_cameraAtOffset; |
330 | private bool m_forceMouselook; | 330 | private bool m_forceMouselook; |
331 | 331 | ||
332 | // TODO: Collision sound should have default. | 332 | |
333 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
334 | private sbyte m_collisionSoundType; | ||
333 | private UUID m_collisionSound; | 335 | private UUID m_collisionSound; |
334 | private float m_collisionSoundVolume; | 336 | private float m_collisionSoundVolume; |
335 | 337 | ||
336 | private DateTime LastColSoundSentTime; | 338 | private int LastColSoundSentTime; |
337 | 339 | ||
338 | 340 | ||
339 | private SOPVehicle m_vehicle = null; | 341 | private SOPVehicle m_vehicle = null; |
@@ -374,7 +376,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
374 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 376 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
375 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 377 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
376 | m_inventory = new SceneObjectPartInventory(this); | 378 | m_inventory = new SceneObjectPartInventory(this); |
377 | LastColSoundSentTime = DateTime.UtcNow; | 379 | LastColSoundSentTime = Util.EnvironmentTickCount(); |
378 | } | 380 | } |
379 | 381 | ||
380 | /// <summary> | 382 | /// <summary> |
@@ -1342,12 +1344,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
1342 | 1344 | ||
1343 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | 1345 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); |
1344 | 1346 | ||
1347 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1348 | // runtime thing.. do not persist | ||
1349 | [XmlIgnore] | ||
1350 | public sbyte CollisionSoundType | ||
1351 | { | ||
1352 | get | ||
1353 | { | ||
1354 | return m_collisionSoundType; | ||
1355 | } | ||
1356 | set | ||
1357 | { | ||
1358 | m_collisionSoundType = value; | ||
1359 | if (value == -1) | ||
1360 | m_collisionSound = invalidCollisionSoundUUID; | ||
1361 | else if (value == 0) | ||
1362 | m_collisionSound = UUID.Zero; | ||
1363 | } | ||
1364 | } | ||
1365 | |||
1345 | public UUID CollisionSound | 1366 | public UUID CollisionSound |
1346 | { | 1367 | { |
1347 | get { return m_collisionSound; } | 1368 | get { return m_collisionSound; } |
1348 | set | 1369 | set |
1349 | { | 1370 | { |
1350 | m_collisionSound = value; | 1371 | m_collisionSound = value; |
1372 | |||
1373 | if (value == invalidCollisionSoundUUID) | ||
1374 | m_collisionSoundType = -1; | ||
1375 | else if (value == UUID.Zero) | ||
1376 | m_collisionSoundType = 0; | ||
1377 | else | ||
1378 | m_collisionSoundType = 1; | ||
1379 | |||
1351 | aggregateScriptEvents(); | 1380 | aggregateScriptEvents(); |
1352 | } | 1381 | } |
1353 | } | 1382 | } |
@@ -1575,7 +1604,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1575 | } | 1604 | } |
1576 | } | 1605 | } |
1577 | else if (PhysActor == null) | 1606 | else if (PhysActor == null) |
1607 | { | ||
1578 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); | 1608 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); |
1609 | UpdatePhysicsSubscribedEvents(); | ||
1610 | } | ||
1579 | else | 1611 | else |
1580 | { | 1612 | { |
1581 | PhysActor.PhysicsShapeType = m_physicsShapeType; | 1613 | PhysActor.PhysicsShapeType = m_physicsShapeType; |
@@ -2632,13 +2664,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
2632 | 2664 | ||
2633 | else | 2665 | else |
2634 | { | 2666 | { |
2667 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
2668 | |||
2635 | // calculate things that started colliding this time | 2669 | // calculate things that started colliding this time |
2636 | // and build up list of colliders this time | 2670 | // and build up list of colliders this time |
2637 | foreach (uint localid in collissionswith.Keys) | 2671 | if (!VolumeDetectActive && CollisionSoundType >= 0) |
2672 | { | ||
2673 | CollisionForSoundInfo soundinfo; | ||
2674 | ContactPoint curcontact; | ||
2675 | |||
2676 | foreach (uint id in collissionswith.Keys) | ||
2677 | { | ||
2678 | thisHitColliders.Add(id); | ||
2679 | if (!m_lastColliders.Contains(id)) | ||
2680 | { | ||
2681 | startedColliders.Add(id); | ||
2682 | |||
2683 | curcontact = collissionswith[id]; | ||
2684 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2685 | { | ||
2686 | soundinfo = new CollisionForSoundInfo(); | ||
2687 | soundinfo.colliderID = id; | ||
2688 | soundinfo.position = curcontact.Position; | ||
2689 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2690 | soundinfolist.Add(soundinfo); | ||
2691 | } | ||
2692 | } | ||
2693 | } | ||
2694 | } | ||
2695 | else | ||
2638 | { | 2696 | { |
2639 | thisHitColliders.Add(localid); | 2697 | foreach (uint id in collissionswith.Keys) |
2640 | if (!m_lastColliders.Contains(localid)) | 2698 | { |
2641 | startedColliders.Add(localid); | 2699 | thisHitColliders.Add(id); |
2700 | if (!m_lastColliders.Contains(id)) | ||
2701 | startedColliders.Add(id); | ||
2702 | } | ||
2642 | } | 2703 | } |
2643 | 2704 | ||
2644 | // calculate things that ended colliding | 2705 | // calculate things that ended colliding |
@@ -2655,17 +2716,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2655 | // remove things that ended colliding from the last colliders list | 2716 | // remove things that ended colliding from the last colliders list |
2656 | foreach (uint localID in endedColliders) | 2717 | foreach (uint localID in endedColliders) |
2657 | m_lastColliders.Remove(localID); | 2718 | m_lastColliders.Remove(localID); |
2658 | } | ||
2659 | |||
2660 | // play the sound. | ||
2661 | 2719 | ||
2662 | bool IsNotVolumeDtc = !VolumeDetectActive; | 2720 | // play sounds. |
2663 | 2721 | if (soundinfolist.Count > 0) | |
2664 | if (IsNotVolumeDtc && startedColliders.Count > 0 && CollisionSound != invalidCollisionSoundUUID) | 2722 | CollisionSounds.PartCollisionSound(this, soundinfolist); |
2665 | CollisionSounds.PartCollisionSound(this, startedColliders); | 2723 | } |
2666 | 2724 | ||
2667 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2725 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2668 | if (IsNotVolumeDtc) | 2726 | if (!VolumeDetectActive) |
2669 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2727 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); |
2670 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2728 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2671 | 2729 | ||
@@ -3210,8 +3268,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3210 | if (volume < 0) | 3268 | if (volume < 0) |
3211 | volume = 0; | 3269 | volume = 0; |
3212 | 3270 | ||
3213 | DateTime now = DateTime.UtcNow; | 3271 | int now = Util.EnvironmentTickCount(); |
3214 | if((now - LastColSoundSentTime).Milliseconds < 200) // reduce rate to 5 per sec per part ?? | 3272 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) |
3215 | return; | 3273 | return; |
3216 | 3274 | ||
3217 | LastColSoundSentTime = now; | 3275 | LastColSoundSentTime = now; |
@@ -4609,7 +4667,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4609 | /// </remarks> | 4667 | /// </remarks> |
4610 | public void RemoveFromPhysics() | 4668 | public void RemoveFromPhysics() |
4611 | { | 4669 | { |
4612 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4670 | PhysicsActor pa = PhysActor; |
4671 | if (pa != null) | ||
4672 | { | ||
4673 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4674 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4675 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4676 | |||
4677 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4678 | } | ||
4613 | PhysActor = null; | 4679 | PhysActor = null; |
4614 | } | 4680 | } |
4615 | 4681 | ||
@@ -4778,7 +4844,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4778 | 4844 | ||
4779 | pa.OnCollisionUpdate -= PhysicsCollision; | 4845 | pa.OnCollisionUpdate -= PhysicsCollision; |
4780 | 4846 | ||
4781 | bool hassound = ( CollisionSound != invalidCollisionSoundUUID); | 4847 | bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive); |
4848 | |||
4782 | scriptEvents CombinedEvents = AggregateScriptEvents; | 4849 | scriptEvents CombinedEvents = AggregateScriptEvents; |
4783 | 4850 | ||
4784 | // merge with root part | 4851 | // merge with root part |
@@ -4787,10 +4854,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4787 | 4854 | ||
4788 | // submit to this part case | 4855 | // submit to this part case |
4789 | if (VolumeDetectActive) | 4856 | if (VolumeDetectActive) |
4790 | { | ||
4791 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | 4857 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; |
4792 | hassound = false; | ||
4793 | } | ||
4794 | else if ((Flags & PrimFlags.Phantom) != 0) | 4858 | else if ((Flags & PrimFlags.Phantom) != 0) |
4795 | CombinedEvents &= PhyscicsPhantonSubsEvents; | 4859 | CombinedEvents &= PhyscicsPhantonSubsEvents; |
4796 | else | 4860 | else |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ebddf21..5a3b518 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2032,7 +2032,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2032 | // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); | 2032 | // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); |
2033 | 2033 | ||
2034 | if (PhysicsActor != null) | 2034 | if (PhysicsActor != null) |
2035 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2035 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2036 | 2036 | ||
2037 | bool canSit = false; | 2037 | bool canSit = false; |
2038 | pos = part.AbsolutePosition + offset; | 2038 | pos = part.AbsolutePosition + offset; |
@@ -4098,6 +4098,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4098 | 4098 | ||
4099 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | 4099 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) |
4100 | { | 4100 | { |
4101 | /* | ||
4101 | lock(m_collisionEventLock) | 4102 | lock(m_collisionEventLock) |
4102 | { | 4103 | { |
4103 | if (m_collisionEventFlag) | 4104 | if (m_collisionEventFlag) |
@@ -4107,76 +4108,106 @@ namespace OpenSim.Region.Framework.Scenes | |||
4107 | 4108 | ||
4108 | Util.FireAndForget(delegate(object x) | 4109 | Util.FireAndForget(delegate(object x) |
4109 | { | 4110 | { |
4111 | */ | ||
4110 | try | 4112 | try |
4111 | { | 4113 | { |
4112 | List<uint> thisHitColliders = new List<uint>(); | 4114 | List<uint> thisHitColliders = new List<uint>(); |
4113 | List<uint> endedColliders = new List<uint>(); | 4115 | List<uint> endedColliders = new List<uint>(); |
4114 | List<uint> startedColliders = new List<uint>(); | 4116 | List<uint> startedColliders = new List<uint>(); |
4117 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4118 | CollisionForSoundInfo soundinfo; | ||
4119 | ContactPoint curcontact; | ||
4115 | 4120 | ||
4116 | foreach (uint localid in coldata.Keys) | 4121 | if (coldata.Count == 0) |
4117 | { | 4122 | { |
4118 | thisHitColliders.Add(localid); | 4123 | if (m_lastColliders.Count == 0) |
4119 | if (!m_lastColliders.Contains(localid)) | 4124 | return; // nothing to do |
4120 | { | 4125 | |
4121 | startedColliders.Add(localid); | 4126 | foreach (uint localID in m_lastColliders) |
4122 | } | ||
4123 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4124 | } | ||
4125 | |||
4126 | // calculate things that ended colliding | ||
4127 | foreach (uint localID in m_lastColliders) | ||
4128 | { | ||
4129 | if (!thisHitColliders.Contains(localID)) | ||
4130 | { | 4127 | { |
4131 | endedColliders.Add(localID); | 4128 | endedColliders.Add(localID); |
4132 | } | 4129 | } |
4133 | } | 4130 | m_lastColliders.Clear(); |
4134 | //add the items that started colliding this time to the last colliders list. | ||
4135 | foreach (uint localID in startedColliders) | ||
4136 | { | ||
4137 | m_lastColliders.Add(localID); | ||
4138 | } | ||
4139 | // remove things that ended colliding from the last colliders list | ||
4140 | foreach (uint localID in endedColliders) | ||
4141 | { | ||
4142 | m_lastColliders.Remove(localID); | ||
4143 | } | 4131 | } |
4144 | 4132 | ||
4145 | // do event notification | 4133 | else |
4146 | if (startedColliders.Count > 0) | ||
4147 | { | 4134 | { |
4148 | CollisionSounds.AvatarCollisionSound(this, startedColliders); | 4135 | foreach (uint id in coldata.Keys) |
4149 | |||
4150 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
4151 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4152 | foreach (uint localId in startedColliders) | ||
4153 | { | 4136 | { |
4154 | if (localId == 0) | 4137 | thisHitColliders.Add(id); |
4155 | continue; | 4138 | if (!m_lastColliders.Contains(id)) |
4139 | { | ||
4140 | startedColliders.Add(id); | ||
4141 | curcontact = coldata[id]; | ||
4142 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4143 | { | ||
4144 | soundinfo = new CollisionForSoundInfo(); | ||
4145 | soundinfo.colliderID = id; | ||
4146 | soundinfo.position = curcontact.Position; | ||
4147 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4148 | soundinfolist.Add(soundinfo); | ||
4149 | } | ||
4150 | } | ||
4151 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4152 | } | ||
4156 | 4153 | ||
4157 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | 4154 | // calculate things that ended colliding |
4158 | string data = ""; | 4155 | foreach (uint localID in m_lastColliders) |
4159 | if (obj != null) | 4156 | { |
4157 | if (!thisHitColliders.Contains(localID)) | ||
4160 | { | 4158 | { |
4161 | DetectedObject detobj = new DetectedObject(); | 4159 | endedColliders.Add(localID); |
4162 | detobj.keyUUID = obj.UUID; | ||
4163 | detobj.nameStr = obj.Name; | ||
4164 | detobj.ownerUUID = obj.OwnerID; | ||
4165 | detobj.posVector = obj.AbsolutePosition; | ||
4166 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4167 | detobj.velVector = obj.Velocity; | ||
4168 | detobj.colliderType = 0; | ||
4169 | detobj.groupUUID = obj.GroupID; | ||
4170 | colliding.Add(detobj); | ||
4171 | } | 4160 | } |
4172 | } | 4161 | } |
4162 | //add the items that started colliding this time to the last colliders list. | ||
4163 | foreach (uint localID in startedColliders) | ||
4164 | { | ||
4165 | m_lastColliders.Add(localID); | ||
4166 | } | ||
4167 | // remove things that ended colliding from the last colliders list | ||
4168 | foreach (uint localID in endedColliders) | ||
4169 | { | ||
4170 | m_lastColliders.Remove(localID); | ||
4171 | } | ||
4173 | 4172 | ||
4174 | if (colliding.Count > 0) | 4173 | if (soundinfolist.Count > 0) |
4174 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4175 | |||
4176 | // do event notification | ||
4177 | if (startedColliders.Count > 0) | ||
4175 | { | 4178 | { |
4176 | StartCollidingMessage.Colliders = colliding; | ||
4177 | 4179 | ||
4178 | foreach (SceneObjectGroup att in GetAttachments()) | 4180 | ColliderArgs StartCollidingMessage = new ColliderArgs(); |
4179 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | 4181 | List<DetectedObject> colliding = new List<DetectedObject>(); |
4182 | foreach (uint localId in startedColliders) | ||
4183 | { | ||
4184 | if (localId == 0) | ||
4185 | continue; | ||
4186 | |||
4187 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4188 | string data = ""; | ||
4189 | if (obj != null) | ||
4190 | { | ||
4191 | DetectedObject detobj = new DetectedObject(); | ||
4192 | detobj.keyUUID = obj.UUID; | ||
4193 | detobj.nameStr = obj.Name; | ||
4194 | detobj.ownerUUID = obj.OwnerID; | ||
4195 | detobj.posVector = obj.AbsolutePosition; | ||
4196 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4197 | detobj.velVector = obj.Velocity; | ||
4198 | detobj.colliderType = 0; | ||
4199 | detobj.groupUUID = obj.GroupID; | ||
4200 | colliding.Add(detobj); | ||
4201 | } | ||
4202 | } | ||
4203 | |||
4204 | if (colliding.Count > 0) | ||
4205 | { | ||
4206 | StartCollidingMessage.Colliders = colliding; | ||
4207 | |||
4208 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4209 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
4210 | } | ||
4180 | } | 4211 | } |
4181 | } | 4212 | } |
4182 | 4213 | ||
@@ -4257,7 +4288,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4257 | { | 4288 | { |
4258 | m_collisionEventFlag = false; | 4289 | m_collisionEventFlag = false; |
4259 | } | 4290 | } |
4260 | }); | 4291 | // }); |
4261 | } | 4292 | } |
4262 | 4293 | ||
4263 | private void TeleportFlagsDebug() { | 4294 | private void TeleportFlagsDebug() { |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index b66d7f1..fb90887 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -59,12 +59,14 @@ namespace OpenSim.Region.Physics.Manager | |||
59 | public Vector3 Position; | 59 | public Vector3 Position; |
60 | public Vector3 SurfaceNormal; | 60 | public Vector3 SurfaceNormal; |
61 | public float PenetrationDepth; | 61 | public float PenetrationDepth; |
62 | public float RelativeSpeed; | ||
62 | 63 | ||
63 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) | 64 | public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) |
64 | { | 65 | { |
65 | Position = position; | 66 | Position = position; |
66 | SurfaceNormal = surfaceNormal; | 67 | SurfaceNormal = surfaceNormal; |
67 | PenetrationDepth = penetrationDepth; | 68 | PenetrationDepth = penetrationDepth; |
69 | RelativeSpeed = 0f; // for now let this one be set explicity | ||
68 | } | 70 | } |
69 | } | 71 | } |
70 | 72 | ||
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index b0711d7..1084b0e 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | |||
@@ -128,9 +128,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
128 | public d.Mass ShellMass; | 128 | public d.Mass ShellMass; |
129 | // public bool collidelock = false; | 129 | // public bool collidelock = false; |
130 | 130 | ||
131 | private bool m_haseventsubscription = false; | ||
132 | public int m_eventsubscription = 0; | 131 | public int m_eventsubscription = 0; |
133 | private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); | 132 | private int m_cureventsubscription = 0; |
133 | private CollisionEventUpdate CollisionEventsThisFrame = null; | ||
134 | private bool SentEmptyCollisionsEvent; | ||
134 | 135 | ||
135 | // unique UUID of this character object | 136 | // unique UUID of this character object |
136 | public UUID m_uuid; | 137 | public UUID m_uuid; |
@@ -239,7 +240,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
239 | 240 | ||
240 | public override bool IsPhysical | 241 | public override bool IsPhysical |
241 | { | 242 | { |
242 | get { return false; } | 243 | get { return m_isPhysical; } |
243 | set { return; } | 244 | set { return; } |
244 | } | 245 | } |
245 | 246 | ||
@@ -783,8 +784,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
783 | 784 | ||
784 | // the Amotor still lets avatar rotation to drift during colisions | 785 | // the Amotor still lets avatar rotation to drift during colisions |
785 | // so force it back to identity | 786 | // so force it back to identity |
786 | |||
787 | |||
788 | 787 | ||
789 | d.Quaternion qtmp; | 788 | d.Quaternion qtmp; |
790 | qtmp.W = 1; | 789 | qtmp.W = 1; |
@@ -903,6 +902,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
903 | contact.SurfaceNormal.X = 0f; | 902 | contact.SurfaceNormal.X = 0f; |
904 | contact.SurfaceNormal.Y = 0f; | 903 | contact.SurfaceNormal.Y = 0f; |
905 | contact.SurfaceNormal.Z = -1f; | 904 | contact.SurfaceNormal.Z = -1f; |
905 | contact.RelativeSpeed = -vel.Z; | ||
906 | AddCollisionEvent(0, contact); | 906 | AddCollisionEvent(0, contact); |
907 | 907 | ||
908 | vec.Z *= 0.5f; | 908 | vec.Z *= 0.5f; |
@@ -1119,47 +1119,71 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1119 | 1119 | ||
1120 | public override void SubscribeEvents(int ms) | 1120 | public override void SubscribeEvents(int ms) |
1121 | { | 1121 | { |
1122 | m_requestedUpdateFrequency = ms; | ||
1123 | m_eventsubscription = ms; | 1122 | m_eventsubscription = ms; |
1124 | _parent_scene.AddCollisionEventReporting(this); | 1123 | m_cureventsubscription = 0; |
1125 | m_haseventsubscription = true; | 1124 | if (CollisionEventsThisFrame == null) |
1125 | CollisionEventsThisFrame = new CollisionEventUpdate(); | ||
1126 | SentEmptyCollisionsEvent = false; | ||
1126 | } | 1127 | } |
1127 | 1128 | ||
1128 | public override void UnSubscribeEvents() | 1129 | public override void UnSubscribeEvents() |
1129 | { | 1130 | { |
1130 | m_haseventsubscription = false; | 1131 | if (CollisionEventsThisFrame != null) |
1131 | _parent_scene.RemoveCollisionEventReporting(this); | 1132 | { |
1132 | m_requestedUpdateFrequency = 0; | 1133 | CollisionEventsThisFrame.Clear(); |
1134 | CollisionEventsThisFrame = null; | ||
1135 | } | ||
1133 | m_eventsubscription = 0; | 1136 | m_eventsubscription = 0; |
1134 | } | 1137 | } |
1135 | 1138 | ||
1136 | public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) | 1139 | public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) |
1137 | { | 1140 | { |
1138 | if (m_haseventsubscription) | 1141 | if (CollisionEventsThisFrame == null) |
1139 | { | 1142 | CollisionEventsThisFrame = new CollisionEventUpdate(); |
1140 | // m_log.DebugFormat( | 1143 | CollisionEventsThisFrame.AddCollider(CollidedWith, contact); |
1141 | // "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact); | ||
1142 | |||
1143 | CollisionEventsThisFrame.AddCollider(CollidedWith, contact); | ||
1144 | } | ||
1145 | } | 1144 | } |
1146 | 1145 | ||
1147 | public void SendCollisions() | 1146 | public void SendCollisions() |
1148 | { | 1147 | { |
1149 | if (m_haseventsubscription && m_eventsubscription > m_requestedUpdateFrequency) | 1148 | if (CollisionEventsThisFrame == null) |
1149 | return; | ||
1150 | |||
1151 | if (m_cureventsubscription < m_eventsubscription) | ||
1152 | return; | ||
1153 | |||
1154 | m_cureventsubscription = 0; | ||
1155 | |||
1156 | int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count; | ||
1157 | |||
1158 | if (!SentEmptyCollisionsEvent || ncolisions > 0) | ||
1150 | { | 1159 | { |
1151 | if (CollisionEventsThisFrame != null) | 1160 | base.SendCollisionUpdate(CollisionEventsThisFrame); |
1161 | |||
1162 | if (ncolisions == 0) | ||
1152 | { | 1163 | { |
1153 | base.SendCollisionUpdate(CollisionEventsThisFrame); | 1164 | SentEmptyCollisionsEvent = true; |
1165 | _parent_scene.RemoveCollisionEventReporting(this); | ||
1154 | } | 1166 | } |
1155 | CollisionEventsThisFrame = new CollisionEventUpdate(); | 1167 | else |
1156 | m_eventsubscription = 0; | 1168 | { |
1157 | } | 1169 | SentEmptyCollisionsEvent = false; |
1170 | CollisionEventsThisFrame.Clear(); | ||
1171 | } | ||
1172 | } | ||
1173 | } | ||
1174 | |||
1175 | internal void AddCollisionFrameTime(int t) | ||
1176 | { | ||
1177 | // protect it from overflow crashing | ||
1178 | if (m_cureventsubscription < 50000) | ||
1179 | m_cureventsubscription += t; | ||
1158 | } | 1180 | } |
1159 | 1181 | ||
1160 | public override bool SubscribedEvents() | 1182 | public override bool SubscribedEvents() |
1161 | { | 1183 | { |
1162 | return m_haseventsubscription; | 1184 | if (m_eventsubscription > 0) |
1185 | return true; | ||
1186 | return false; | ||
1163 | } | 1187 | } |
1164 | 1188 | ||
1165 | private void changePhysicsStatus(bool NewStatus) | 1189 | private void changePhysicsStatus(bool NewStatus) |
@@ -1465,14 +1489,5 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1465 | { | 1489 | { |
1466 | _parent_scene.AddChange((PhysicsActor)this, what, arg); | 1490 | _parent_scene.AddChange((PhysicsActor)this, what, arg); |
1467 | } | 1491 | } |
1468 | |||
1469 | |||
1470 | internal void AddCollisionFrameTime(int p) | ||
1471 | { | ||
1472 | // protect it from overflow crashing | ||
1473 | if (m_eventsubscription + p >= int.MaxValue) | ||
1474 | m_eventsubscription = 0; | ||
1475 | m_eventsubscription += p; | ||
1476 | } | ||
1477 | } | 1492 | } |
1478 | } | 1493 | } |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 5db4f17..62fd279 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | |||
@@ -477,58 +477,58 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
477 | 477 | ||
478 | // if(childPrim) we only know about physical linksets | 478 | // if(childPrim) we only know about physical linksets |
479 | return Ptot; | 479 | return Ptot; |
480 | /* | 480 | /* |
481 | float tmass = _mass; | 481 | float tmass = _mass; |
482 | Ptot *= tmass; | 482 | Ptot *= tmass; |
483 | 483 | ||
484 | float m; | 484 | float m; |
485 | 485 | ||
486 | foreach (OdePrim prm in childrenPrim) | 486 | foreach (OdePrim prm in childrenPrim) |
487 | { | 487 | { |
488 | m = prm._mass; | 488 | m = prm._mass; |
489 | Ptot += prm.CenterOfMass * m; | 489 | Ptot += prm.CenterOfMass * m; |
490 | tmass += m; | 490 | tmass += m; |
491 | } | 491 | } |
492 | 492 | ||
493 | if (tmass == 0) | 493 | if (tmass == 0) |
494 | tmass = 0; | 494 | tmass = 0; |
495 | else | 495 | else |
496 | tmass = 1.0f / tmass; | 496 | tmass = 1.0f / tmass; |
497 | 497 | ||
498 | Ptot *= tmass; | 498 | Ptot *= tmass; |
499 | return Ptot; | 499 | return Ptot; |
500 | */ | 500 | */ |
501 | } | 501 | } |
502 | else | 502 | else |
503 | return _position; | 503 | return _position; |
504 | } | 504 | } |
505 | } | 505 | } |
506 | } | 506 | } |
507 | /* | 507 | /* |
508 | public override Vector3 PrimOOBsize | 508 | public override Vector3 PrimOOBsize |
509 | { | 509 | { |
510 | get | 510 | get |
511 | { | 511 | { |
512 | return primOOBsize; | 512 | return primOOBsize; |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | public override Vector3 PrimOOBoffset | 516 | public override Vector3 PrimOOBoffset |
517 | { | 517 | { |
518 | get | 518 | get |
519 | { | 519 | { |
520 | return primOOBoffset; | 520 | return primOOBoffset; |
521 | } | 521 | } |
522 | } | 522 | } |
523 | 523 | ||
524 | public override float PrimOOBRadiusSQ | 524 | public override float PrimOOBRadiusSQ |
525 | { | 525 | { |
526 | get | 526 | get |
527 | { | 527 | { |
528 | return primOOBradiusSQ; | 528 | return primOOBradiusSQ; |
529 | } | 529 | } |
530 | } | 530 | } |
531 | */ | 531 | */ |
532 | public override PrimitiveBaseShape Shape | 532 | public override PrimitiveBaseShape Shape |
533 | { | 533 | { |
534 | set | 534 | set |
@@ -582,7 +582,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
582 | if (value.IsFinite()) | 582 | if (value.IsFinite()) |
583 | { | 583 | { |
584 | AddChange(changes.Velocity, value); | 584 | AddChange(changes.Velocity, value); |
585 | // _velocity = value; | 585 | // _velocity = value; |
586 | 586 | ||
587 | } | 587 | } |
588 | else | 588 | else |
@@ -937,12 +937,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
937 | if (CollisionEventsThisFrame == null) | 937 | if (CollisionEventsThisFrame == null) |
938 | CollisionEventsThisFrame = new CollisionEventUpdate(); | 938 | CollisionEventsThisFrame = new CollisionEventUpdate(); |
939 | SentEmptyCollisionsEvent = false; | 939 | SentEmptyCollisionsEvent = false; |
940 | _parent_scene.AddCollisionEventReporting(this); | ||
941 | } | 940 | } |
942 | 941 | ||
943 | public override void UnSubscribeEvents() | 942 | public override void UnSubscribeEvents() |
944 | { | 943 | { |
945 | _parent_scene.RemoveCollisionEventReporting(this); | ||
946 | if (CollisionEventsThisFrame != null) | 944 | if (CollisionEventsThisFrame != null) |
947 | { | 945 | { |
948 | CollisionEventsThisFrame.Clear(); | 946 | CollisionEventsThisFrame.Clear(); |
@@ -975,7 +973,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
975 | base.SendCollisionUpdate(CollisionEventsThisFrame); | 973 | base.SendCollisionUpdate(CollisionEventsThisFrame); |
976 | 974 | ||
977 | if (ncolisions == 0) | 975 | if (ncolisions == 0) |
976 | { | ||
978 | SentEmptyCollisionsEvent = true; | 977 | SentEmptyCollisionsEvent = true; |
978 | _parent_scene.RemoveCollisionEventReporting(this); | ||
979 | } | ||
979 | else | 980 | else |
980 | { | 981 | { |
981 | SentEmptyCollisionsEvent = false; | 982 | SentEmptyCollisionsEvent = false; |
@@ -986,11 +987,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
986 | 987 | ||
987 | internal void AddCollisionFrameTime(int t) | 988 | internal void AddCollisionFrameTime(int t) |
988 | { | 989 | { |
989 | // protect it from overflow crashing | 990 | if (m_cureventsubscription < 50000) |
990 | if (m_cureventsubscription + t >= int.MaxValue) | 991 | m_cureventsubscription += t; |
991 | m_cureventsubscription = 0; | ||
992 | m_cureventsubscription += t; | ||
993 | } | 992 | } |
993 | |||
994 | public override bool SubscribedEvents() | 994 | public override bool SubscribedEvents() |
995 | { | 995 | { |
996 | if (m_eventsubscription > 0) | 996 | if (m_eventsubscription > 0) |
@@ -1735,8 +1735,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1735 | 1735 | ||
1736 | d.BodySetAutoDisableFlag(Body, true); | 1736 | d.BodySetAutoDisableFlag(Body, true); |
1737 | d.BodySetAutoDisableSteps(Body, body_autodisable_frames); | 1737 | d.BodySetAutoDisableSteps(Body, body_autodisable_frames); |
1738 | // d.BodySetLinearDampingThreshold(Body, 0.01f); | 1738 | // d.BodySetLinearDampingThreshold(Body, 0.01f); |
1739 | // d.BodySetAngularDampingThreshold(Body, 0.001f); | 1739 | // d.BodySetAngularDampingThreshold(Body, 0.001f); |
1740 | d.BodySetDamping(Body, .002f, .002f); | 1740 | d.BodySetDamping(Body, .002f, .002f); |
1741 | 1741 | ||
1742 | if (m_targetSpace != IntPtr.Zero) | 1742 | if (m_targetSpace != IntPtr.Zero) |
@@ -2966,7 +2966,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2966 | givefakepos--; | 2966 | givefakepos--; |
2967 | if (givefakepos < 0) | 2967 | if (givefakepos < 0) |
2968 | givefakepos = 0; | 2968 | givefakepos = 0; |
2969 | // changeSelectedStatus(); | 2969 | // changeSelectedStatus(); |
2970 | resetCollisionAccounting(); | 2970 | resetCollisionAccounting(); |
2971 | } | 2971 | } |
2972 | 2972 | ||
@@ -2981,14 +2981,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2981 | { | 2981 | { |
2982 | _orientation = newOri; | 2982 | _orientation = newOri; |
2983 | } | 2983 | } |
2984 | /* | 2984 | /* |
2985 | else if (m_forcePosOrRotation && _orientation != newOri && Body != IntPtr.Zero) | 2985 | else if (m_forcePosOrRotation && _orientation != newOri && Body != IntPtr.Zero) |
2986 | { | 2986 | { |
2987 | FixInertia(_position, newOri); | 2987 | FixInertia(_position, newOri); |
2988 | if (!d.BodyIsEnabled(Body)) | 2988 | if (!d.BodyIsEnabled(Body)) |
2989 | d.BodyEnable(Body); | 2989 | d.BodyEnable(Body); |
2990 | } | 2990 | } |
2991 | */ | 2991 | */ |
2992 | } | 2992 | } |
2993 | else | 2993 | else |
2994 | { | 2994 | { |
@@ -3939,12 +3939,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3939 | changevelocity((Vector3)arg); | 3939 | changevelocity((Vector3)arg); |
3940 | break; | 3940 | break; |
3941 | 3941 | ||
3942 | // case changes.Acceleration: | 3942 | // case changes.Acceleration: |
3943 | // changeacceleration((Vector3)arg); | 3943 | // changeacceleration((Vector3)arg); |
3944 | // break; | 3944 | // break; |
3945 | // case changes.AngVelocity: | 3945 | // case changes.AngVelocity: |
3946 | // changeangvelocity((Vector3)arg); | 3946 | // changeangvelocity((Vector3)arg); |
3947 | // break; | 3947 | // break; |
3948 | 3948 | ||
3949 | case changes.Force: | 3949 | case changes.Force: |
3950 | changeForce((Vector3)arg); | 3950 | changeForce((Vector3)arg); |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index ddfdea4..bfcfd21 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -190,6 +190,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
190 | 190 | ||
191 | public float ODE_STEPSIZE = 0.020f; | 191 | public float ODE_STEPSIZE = 0.020f; |
192 | public float HalfOdeStep = 0.01f; | 192 | public float HalfOdeStep = 0.01f; |
193 | public int odetimestepMS = 20; // rounded | ||
193 | private float metersInSpace = 25.6f; | 194 | private float metersInSpace = 25.6f; |
194 | private float m_timeDilation = 1.0f; | 195 | private float m_timeDilation = 1.0f; |
195 | 196 | ||
@@ -247,6 +248,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
247 | /// A list of actors that should receive collision events. | 248 | /// A list of actors that should receive collision events. |
248 | /// </summary> | 249 | /// </summary> |
249 | private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>(); | 250 | private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>(); |
251 | private readonly List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>(); | ||
250 | 252 | ||
251 | private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); | 253 | private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); |
252 | public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); | 254 | public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); |
@@ -489,6 +491,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
489 | } | 491 | } |
490 | 492 | ||
491 | HalfOdeStep = ODE_STEPSIZE * 0.5f; | 493 | HalfOdeStep = ODE_STEPSIZE * 0.5f; |
494 | odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); | ||
492 | 495 | ||
493 | ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); | 496 | ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); |
494 | GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); | 497 | GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); |
@@ -1064,7 +1067,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1064 | obj2LocalID = 0; | 1067 | obj2LocalID = 0; |
1065 | bool p1events = p1.SubscribedEvents(); | 1068 | bool p1events = p1.SubscribedEvents(); |
1066 | bool p2events = p2.SubscribedEvents(); | 1069 | bool p2events = p2.SubscribedEvents(); |
1067 | 1070 | ||
1068 | if (p1.IsVolumeDtc) | 1071 | if (p1.IsVolumeDtc) |
1069 | p2events = false; | 1072 | p2events = false; |
1070 | if (p2.IsVolumeDtc) | 1073 | if (p2.IsVolumeDtc) |
@@ -1073,6 +1076,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1073 | if (!(p2events || p1events)) | 1076 | if (!(p2events || p1events)) |
1074 | return; | 1077 | return; |
1075 | 1078 | ||
1079 | if (p1events) | ||
1080 | AddCollisionEventReporting(p1); | ||
1081 | |||
1082 | if (p2events) | ||
1083 | AddCollisionEventReporting(p2); | ||
1084 | |||
1085 | Vector3 vel = Vector3.Zero; | ||
1086 | if (p2 != null && p2.IsPhysical) | ||
1087 | vel = p2.Velocity; | ||
1088 | |||
1089 | if (p1 != null && p1.IsPhysical) | ||
1090 | vel -= p1.Velocity; | ||
1091 | |||
1092 | contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); | ||
1093 | |||
1076 | switch ((ActorTypes)p1.PhysicsActorType) | 1094 | switch ((ActorTypes)p1.PhysicsActorType) |
1077 | { | 1095 | { |
1078 | case ActorTypes.Agent: | 1096 | case ActorTypes.Agent: |
@@ -1246,20 +1264,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1246 | } | 1264 | } |
1247 | 1265 | ||
1248 | #endregion | 1266 | #endregion |
1249 | |||
1250 | |||
1251 | |||
1252 | /// <summary> | 1267 | /// <summary> |
1253 | /// Add actor to the list that should receive collision events in the simulate loop. | 1268 | /// Add actor to the list that should receive collision events in the simulate loop. |
1254 | /// </summary> | 1269 | /// </summary> |
1255 | /// <param name="obj"></param> | 1270 | /// <param name="obj"></param> |
1256 | public void AddCollisionEventReporting(PhysicsActor obj) | 1271 | public void AddCollisionEventReporting(PhysicsActor obj) |
1257 | { | 1272 | { |
1258 | lock (_collisionEventPrim) | 1273 | if (!_collisionEventPrim.Contains(obj)) |
1259 | { | 1274 | _collisionEventPrim.Add(obj); |
1260 | if (!_collisionEventPrim.Contains(obj)) | ||
1261 | _collisionEventPrim.Add(obj); | ||
1262 | } | ||
1263 | } | 1275 | } |
1264 | 1276 | ||
1265 | /// <summary> | 1277 | /// <summary> |
@@ -1268,13 +1280,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1268 | /// <param name="obj"></param> | 1280 | /// <param name="obj"></param> |
1269 | public void RemoveCollisionEventReporting(PhysicsActor obj) | 1281 | public void RemoveCollisionEventReporting(PhysicsActor obj) |
1270 | { | 1282 | { |
1271 | lock (_collisionEventPrim) | 1283 | if (_collisionEventPrim.Contains(obj) && !_collisionEventPrimRemove.Contains(obj)) |
1272 | { | 1284 | _collisionEventPrimRemove.Add(obj); |
1273 | if (_collisionEventPrim.Contains(obj)) | ||
1274 | _collisionEventPrim.Remove(obj); | ||
1275 | } | ||
1276 | } | 1285 | } |
1277 | 1286 | ||
1287 | |||
1278 | #region Add/Remove Entities | 1288 | #region Add/Remove Entities |
1279 | 1289 | ||
1280 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | 1290 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) |
@@ -1463,6 +1473,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1463 | { | 1473 | { |
1464 | // lock (OdeLock) | 1474 | // lock (OdeLock) |
1465 | { | 1475 | { |
1476 | |||
1466 | OdePrim p = (OdePrim)prim; | 1477 | OdePrim p = (OdePrim)prim; |
1467 | p.setPrimForRemoval(); | 1478 | p.setPrimForRemoval(); |
1468 | } | 1479 | } |
@@ -1818,7 +1829,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1818 | { | 1829 | { |
1819 | int ttmpstart = Util.EnvironmentTickCount(); | 1830 | int ttmpstart = Util.EnvironmentTickCount(); |
1820 | int ttmp; | 1831 | int ttmp; |
1821 | int ttmp2; | ||
1822 | 1832 | ||
1823 | while(ChangesQueue.Dequeue(out item)) | 1833 | while(ChangesQueue.Dequeue(out item)) |
1824 | { | 1834 | { |
@@ -1840,11 +1850,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1840 | if (ttmp > 20) | 1850 | if (ttmp > 20) |
1841 | break; | 1851 | break; |
1842 | } | 1852 | } |
1843 | |||
1844 | ttmp2 = Util.EnvironmentTickCountSubtract(ttmpstart); | ||
1845 | if (ttmp2 > 50) | ||
1846 | ttmp2 = 0; | ||
1847 | |||
1848 | } | 1853 | } |
1849 | 1854 | ||
1850 | // Move characters | 1855 | // Move characters |
@@ -1881,53 +1886,55 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1881 | 1886 | ||
1882 | collision_optimized(); | 1887 | collision_optimized(); |
1883 | 1888 | ||
1884 | lock (_collisionEventPrim) | 1889 | foreach (PhysicsActor obj in _collisionEventPrim) |
1885 | { | 1890 | { |
1886 | foreach (PhysicsActor obj in _collisionEventPrim) | 1891 | if (obj == null) |
1892 | continue; | ||
1893 | |||
1894 | switch ((ActorTypes)obj.PhysicsActorType) | ||
1887 | { | 1895 | { |
1888 | if (obj == null) | 1896 | case ActorTypes.Agent: |
1889 | continue; | 1897 | OdeCharacter cobj = (OdeCharacter)obj; |
1898 | cobj.AddCollisionFrameTime((int)(odetimestepMS)); | ||
1899 | cobj.SendCollisions(); | ||
1900 | break; | ||
1890 | 1901 | ||
1891 | switch ((ActorTypes)obj.PhysicsActorType) | 1902 | case ActorTypes.Prim: |
1892 | { | 1903 | OdePrim pobj = (OdePrim)obj; |
1893 | case ActorTypes.Agent: | 1904 | if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds)) |
1894 | OdeCharacter cobj = (OdeCharacter)obj; | 1905 | { |
1895 | cobj.AddCollisionFrameTime((int)(ODE_STEPSIZE*1000.0f)); | 1906 | pobj.AddCollisionFrameTime((int)(odetimestepMS)); |
1896 | cobj.SendCollisions(); | 1907 | pobj.SendCollisions(); |
1897 | break; | 1908 | } |
1898 | 1909 | break; | |
1899 | case ActorTypes.Prim: | ||
1900 | OdePrim pobj = (OdePrim)obj; | ||
1901 | if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds)) | ||
1902 | { | ||
1903 | pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f)); | ||
1904 | pobj.SendCollisions(); | ||
1905 | } | ||
1906 | break; | ||
1907 | } | ||
1908 | } | 1910 | } |
1909 | } | 1911 | } |
1910 | 1912 | ||
1913 | foreach (PhysicsActor obj in _collisionEventPrimRemove) | ||
1914 | _collisionEventPrim.Remove(obj); | ||
1915 | |||
1916 | _collisionEventPrimRemove.Clear(); | ||
1917 | |||
1911 | // do a ode simulation step | 1918 | // do a ode simulation step |
1912 | d.WorldQuickStep(world, ODE_STEPSIZE); | 1919 | d.WorldQuickStep(world, ODE_STEPSIZE); |
1913 | d.JointGroupEmpty(contactgroup); | 1920 | d.JointGroupEmpty(contactgroup); |
1914 | 1921 | ||
1915 | // update managed ideia of physical data and do updates to core | 1922 | // update managed ideia of physical data and do updates to core |
1916 | /* | 1923 | /* |
1917 | lock (_characters) | 1924 | lock (_characters) |
1918 | { | 1925 | { |
1919 | foreach (OdeCharacter actor in _characters) | 1926 | foreach (OdeCharacter actor in _characters) |
1920 | { | 1927 | { |
1921 | if (actor != null) | 1928 | if (actor != null) |
1922 | { | 1929 | { |
1923 | if (actor.bad) | 1930 | if (actor.bad) |
1924 | m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); | 1931 | m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); |
1925 | 1932 | ||
1926 | actor.UpdatePositionAndVelocity(); | 1933 | actor.UpdatePositionAndVelocity(); |
1927 | } | 1934 | } |
1928 | } | 1935 | } |
1929 | } | 1936 | } |
1930 | */ | 1937 | */ |
1931 | 1938 | ||
1932 | lock (_activegroups) | 1939 | lock (_activegroups) |
1933 | { | 1940 | { |