aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/BvhTriangleMeshShape.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/BvhTriangleMeshShape.cs166
1 files changed, 83 insertions, 83 deletions
diff --git a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/BvhTriangleMeshShape.cs b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/BvhTriangleMeshShape.cs
index 00247a0..03e1e44 100644
--- a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/BvhTriangleMeshShape.cs
+++ b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionShapes/BvhTriangleMeshShape.cs
@@ -1,83 +1,83 @@
1/* 1/*
2 Bullet for XNA Copyright (c) 2003-2007 Vsevolod Klementjev http://www.codeplex.com/xnadevru 2 Bullet for XNA Copyright (c) 2003-2007 Vsevolod Klementjev http://www.codeplex.com/xnadevru
3 Bullet original C++ version Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com 3 Bullet original C++ version Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com
4 4
5 This software is provided 'as-is', without any express or implied 5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages 6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software. 7 arising from the use of this software.
8 8
9 Permission is granted to anyone to use this software for any purpose, 9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it 10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions: 11 freely, subject to the following restrictions:
12 12
13 1. The origin of this software must not be misrepresented; you must not 13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software 14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be 15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required. 16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be 17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software. 18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution. 19 3. This notice may not be removed or altered from any source distribution.
20*/ 20*/
21 21
22using System; 22using System;
23using System.Collections.Generic; 23using System.Collections.Generic;
24using System.Text; 24using System.Text;
25using MonoXnaCompactMaths; 25using MonoXnaCompactMaths;
26 26
27namespace XnaDevRu.BulletX 27namespace XnaDevRu.BulletX
28{ 28{
29 class MyNodeOverlapCallback : INodeOverlapCallback 29 class MyNodeOverlapCallback : INodeOverlapCallback
30 { 30 {
31 StridingMeshInterface _meshInterface; 31 StridingMeshInterface _meshInterface;
32 ITriangleCallback _callback; 32 ITriangleCallback _callback;
33 Vector3[] _triangle = new Vector3[3]; 33 Vector3[] _triangle = new Vector3[3];
34 34
35 public MyNodeOverlapCallback(ITriangleCallback callback, StridingMeshInterface meshInterface) 35 public MyNodeOverlapCallback(ITriangleCallback callback, StridingMeshInterface meshInterface)
36 { 36 {
37 _meshInterface = meshInterface; 37 _meshInterface = meshInterface;
38 _callback = callback; 38 _callback = callback;
39 } 39 }
40 40
41 public void ProcessNode(OptimizedBvhNode node) 41 public void ProcessNode(OptimizedBvhNode node)
42 { 42 {
43 List<Vector3> verts; 43 List<Vector3> verts;
44 List<int> indicies; 44 List<int> indicies;
45 int numtriangles; 45 int numtriangles;
46 46
47 _meshInterface.GetLockedReadOnlyVertexIndexBase(out verts, out indicies, out numtriangles, node.SubPart); 47 _meshInterface.GetLockedReadOnlyVertexIndexBase(out verts, out indicies, out numtriangles, node.SubPart);
48 Vector3 meshScaling = _meshInterface.Scaling; 48 Vector3 meshScaling = _meshInterface.Scaling;
49 49
50 for (int j = 0; j < 3; j++) 50 for (int j = 0; j < 3; j++)
51 { 51 {
52 _triangle[j] = verts[indicies[j + node.TriangleIndex * 3]] * meshScaling; 52 _triangle[j] = verts[indicies[j + node.TriangleIndex * 3]] * meshScaling;
53 } 53 }
54 54
55 _callback.ProcessTriangle(_triangle, node.SubPart, node.TriangleIndex); 55 _callback.ProcessTriangle(_triangle, node.SubPart, node.TriangleIndex);
56 _meshInterface.UnLockReadOnlyVertexBase(node.SubPart); 56 _meshInterface.UnLockReadOnlyVertexBase(node.SubPart);
57 } 57 }
58 } 58 }
59 59
60 public class BvhTriangleMeshShape : TriangleMeshShape 60 public class BvhTriangleMeshShape : TriangleMeshShape
61 { 61 {
62 OptimizedBvh _bvh = new OptimizedBvh(); 62 OptimizedBvh _bvh = new OptimizedBvh();
63 63
64 public BvhTriangleMeshShape(StridingMeshInterface meshInterface) : base(meshInterface) 64 public BvhTriangleMeshShape(StridingMeshInterface meshInterface) : base(meshInterface)
65 { 65 {
66 _bvh.Build(meshInterface); 66 _bvh.Build(meshInterface);
67 } 67 }
68 68
69 public override void ProcessAllTriangles(ITriangleCallback callback, Vector3 aabbMin, Vector3 aabbMax) 69 public override void ProcessAllTriangles(ITriangleCallback callback, Vector3 aabbMin, Vector3 aabbMax)
70 { 70 {
71 MyNodeOverlapCallback myNodeCallback = new MyNodeOverlapCallback(callback, MeshInterface); 71 MyNodeOverlapCallback myNodeCallback = new MyNodeOverlapCallback(callback, MeshInterface);
72 _bvh.ReportAabbOverlappingNodex(myNodeCallback, aabbMin, aabbMax); 72 _bvh.ReportAabbOverlappingNodex(myNodeCallback, aabbMin, aabbMax);
73 } 73 }
74 74
75 public override string Name 75 public override string Name
76 { 76 {
77 get 77 get
78 { 78 {
79 return "BvhTriangleMesh"; 79 return "BvhTriangleMesh";
80 } 80 }
81 } 81 }
82 } 82 }
83} 83}