diff options
author | UbitUmarov | 2012-05-17 01:04:30 +0100 |
---|---|---|
committer | UbitUmarov | 2012-05-17 01:04:30 +0100 |
commit | 7cbc54d92a4702efb8a7bc1b0ec611c4abbc104b (patch) | |
tree | 7bd6347f1b3dd69303d699e9744771e003346738 | |
parent | collision sounds: simplify send code a bit and limit sending rate to 5 per s... (diff) | |
download | opensim-SC-7cbc54d92a4702efb8a7bc1b0ec611c4abbc104b.zip opensim-SC-7cbc54d92a4702efb8a7bc1b0ec611c4abbc104b.tar.gz opensim-SC-7cbc54d92a4702efb8a7bc1b0ec611c4abbc104b.tar.bz2 opensim-SC-7cbc54d92a4702efb8a7bc1b0ec611c4abbc104b.tar.xz |
default collision sounds. Incomplete, untested, needs revision
-rw-r--r-- | OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 204 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 |
2 files changed, 205 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs new file mode 100644 index 0000000..65c8012 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs | |||
@@ -0,0 +1,204 @@ | |||
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 copyright | ||
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 | // Ubit 2012 | ||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | |||
34 | namespace OpenSim.Region.Framework.Scenes | ||
35 | { | ||
36 | public static class CollisionSounds | ||
37 | { | ||
38 | // defines for cases | ||
39 | // only know one UUID for now (woodflesh) | ||
40 | |||
41 | private const int MaxMaterials = 7; | ||
42 | // part part | ||
43 | private static UUID snd_StoneStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
44 | private static UUID snd_StoneMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
45 | private static UUID snd_StoneGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
46 | private static UUID snd_StoneWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
47 | private static UUID snd_StoneFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
48 | private static UUID snd_StonePlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
49 | private static UUID snd_StoneRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
50 | |||
51 | private static UUID snd_MetalStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
52 | private static UUID snd_MetalMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
53 | private static UUID snd_MetalGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
54 | private static UUID snd_MetalWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
55 | private static UUID snd_MetalFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
56 | private static UUID snd_MetalPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
57 | private static UUID snd_MetalRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
58 | |||
59 | private static UUID snd_GlassStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
60 | private static UUID snd_GlassMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
61 | private static UUID snd_GlassGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
62 | private static UUID snd_GlassWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
63 | private static UUID snd_GlassFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
64 | private static UUID snd_GlassPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
65 | private static UUID snd_GlassRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
66 | |||
67 | private static UUID snd_WoodStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
68 | private static UUID snd_WoodMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
69 | private static UUID snd_WoodGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
70 | private static UUID snd_WoodWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
71 | private static UUID snd_WoodFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
72 | private static UUID snd_WoodPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
73 | private static UUID snd_WoodRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
74 | |||
75 | private static UUID snd_FleshStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
76 | private static UUID snd_FleshMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
77 | private static UUID snd_FleshGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
78 | private static UUID snd_FleshWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
79 | private static UUID snd_FleshFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
80 | private static UUID snd_FleshPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
81 | private static UUID snd_FleshRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
82 | |||
83 | private static UUID snd_PlasticStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
84 | private static UUID snd_PlasticMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
85 | private static UUID snd_PlasticGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
86 | private static UUID snd_PlasticWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
87 | private static UUID snd_PlasticFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
88 | private static UUID snd_PlasticPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
89 | private static UUID snd_PlasticRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
90 | |||
91 | private static UUID snd_RubberStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
92 | private static UUID snd_RubberMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
93 | private static UUID snd_RubberGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
94 | private static UUID snd_RubberWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
95 | private static UUID snd_RubberFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
96 | private static UUID snd_RubberPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
97 | private static UUID snd_RubberRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
98 | |||
99 | // terrain part | ||
100 | private static UUID snd_TerrainStone = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
101 | private static UUID snd_TerrainMetal = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
102 | private static UUID snd_TerrainGlass = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
103 | private static UUID snd_TerrainWood = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
104 | private static UUID snd_TerrainFlesh = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
105 | private static UUID snd_TerrainPlastic = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
106 | private static UUID snd_TerrainRubber = new UUID("be582e5d-b123-41a2-a150-454c39e961c8"); | ||
107 | |||
108 | public static UUID[] m_TerrainPart = { | ||
109 | snd_TerrainStone, | ||
110 | snd_TerrainMetal, | ||
111 | snd_TerrainGlass, | ||
112 | snd_TerrainWood, | ||
113 | snd_TerrainFlesh, | ||
114 | snd_TerrainPlastic, | ||
115 | snd_TerrainRubber | ||
116 | }; | ||
117 | |||
118 | public static UUID[] m_PartPart = { | ||
119 | snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, | ||
120 | snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, | ||
121 | snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, | ||
122 | snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, | ||
123 | snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, | ||
124 | snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber, | ||
125 | snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber | ||
126 | }; | ||
127 | |||
128 | public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders) | ||
129 | { | ||
130 | if(Colliders.Count == 0 || part == null) | ||
131 | return; | ||
132 | |||
133 | if ((part.Flags & PrimFlags.Physics) == 0) // let only active prims trigger sounds | ||
134 | return; | ||
135 | |||
136 | if (part.ParentGroup == null) | ||
137 | return; | ||
138 | |||
139 | if (part.CollisionSound == part.invalidCollisionSoundUUID) | ||
140 | return; | ||
141 | |||
142 | UUID soundID; | ||
143 | int otherMaterial; | ||
144 | |||
145 | int thisMaterial = (int) part.Material; | ||
146 | if (thisMaterial >= MaxMaterials) | ||
147 | thisMaterial = 3; | ||
148 | |||
149 | int thisMatScaled = thisMaterial * MaxMaterials; | ||
150 | int index; | ||
151 | |||
152 | bool doneownsound = false; | ||
153 | |||
154 | foreach (uint Id in Colliders) | ||
155 | { | ||
156 | if (Id == 0) | ||
157 | { | ||
158 | if (!doneownsound) | ||
159 | { | ||
160 | soundID = m_TerrainPart[thisMaterial]; | ||
161 | part.SendCollisionSound(soundID, 1.0); | ||
162 | doneownsound = true; | ||
163 | } | ||
164 | continue; | ||
165 | } | ||
166 | |||
167 | SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id); | ||
168 | if (otherPart != null) | ||
169 | { | ||
170 | if (otherPart.CollisionSound == part.invalidCollisionSoundUUID) | ||
171 | continue; | ||
172 | if (otherPart.CollisionSound != UUID.Zero) | ||
173 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume); | ||
174 | else | ||
175 | { | ||
176 | otherMaterial = (int)otherPart.Material; | ||
177 | if (otherMaterial >= MaxMaterials) | ||
178 | otherMaterial = 3; | ||
179 | index = thisMatScaled + otherMaterial; | ||
180 | soundID = m_PartPart[index]; | ||
181 | if (doneownsound) | ||
182 | otherPart.SendCollisionSound(soundID, 1.0); | ||
183 | else | ||
184 | { | ||
185 | part.SendCollisionSound(soundID, 1.0); | ||
186 | doneownsound = true; | ||
187 | } | ||
188 | } | ||
189 | } | ||
190 | else if (!doneownsound) | ||
191 | { | ||
192 | ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id); | ||
193 | if (av != null && (!av.IsChildAgent)) | ||
194 | { | ||
195 | index = thisMatScaled + 4; // flesh | ||
196 | soundID = m_PartPart[index]; | ||
197 | part.SendCollisionSound(soundID, 1.0); | ||
198 | doneownsound = true; | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 38e7a12..af9b7eb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2667,7 +2667,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2667 | SendCollisionSound(CollisionSound, CollisionSoundVolume); | 2667 | SendCollisionSound(CollisionSound, CollisionSoundVolume); |
2668 | else | 2668 | else |
2669 | { | 2669 | { |
2670 | // default sounds | 2670 | CollisionSounds.PartCollisionSound(this, startedColliders); |
2671 | } | 2671 | } |
2672 | } | 2672 | } |
2673 | 2673 | ||