aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/OPCODE/OPC_VolumeCollider.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/ode-0.9/OPCODE/OPC_VolumeCollider.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/libraries/ode-0.9/OPCODE/OPC_VolumeCollider.cpp b/libraries/ode-0.9/OPCODE/OPC_VolumeCollider.cpp
new file mode 100644
index 0000000..f374209
--- /dev/null
+++ b/libraries/ode-0.9/OPCODE/OPC_VolumeCollider.cpp
@@ -0,0 +1,103 @@
1///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2/*
3 * OPCODE - Optimized Collision Detection
4 * Copyright (C) 2001 Pierre Terdiman
5 * Homepage: http://www.codercorner.com/Opcode.htm
6 */
7///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
8
9///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
10/**
11 * Contains base volume collider class.
12 * \file OPC_VolumeCollider.cpp
13 * \author Pierre Terdiman
14 * \date June, 2, 2001
15 */
16///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
17
18///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
19/**
20 * Contains the abstract class for volume colliders.
21 *
22 * \class VolumeCollider
23 * \author Pierre Terdiman
24 * \version 1.3
25 * \date June, 2, 2001
26*/
27///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
28
29///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
30// Precompiled Header
31#include "Stdafx.h"
32
33using namespace Opcode;
34
35///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
36/**
37 * Constructor.
38 */
39///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40VolumeCollider::VolumeCollider() :
41 mTouchedPrimitives (null),
42 mNbVolumeBVTests (0),
43 mNbVolumePrimTests (0)
44{
45}
46
47///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48/**
49 * Destructor.
50 */
51///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52VolumeCollider::~VolumeCollider()
53{
54 mTouchedPrimitives = null;
55}
56
57///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
58/**
59 * Validates current settings. You should call this method after all the settings / callbacks have been defined for a collider.
60 * \return null if everything is ok, else a string describing the problem
61 */
62///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
63const char* VolumeCollider::ValidateSettings()
64{
65 return null;
66}
67
68// Pretty dumb way to dump - to do better - one day...
69
70#define IMPLEMENT_NOLEAFDUMP(type) \
71void VolumeCollider::_Dump(const type* node) \
72{ \
73 if(node->HasPosLeaf()) mTouchedPrimitives->Add(udword(node->GetPosPrimitive())); \
74 else _Dump(node->GetPos()); \
75 \
76 if(ContactFound()) return; \
77 \
78 if(node->HasNegLeaf()) mTouchedPrimitives->Add(udword(node->GetNegPrimitive())); \
79 else _Dump(node->GetNeg()); \
80}
81
82#define IMPLEMENT_LEAFDUMP(type) \
83void VolumeCollider::_Dump(const type* node) \
84{ \
85 if(node->IsLeaf()) \
86 { \
87 mTouchedPrimitives->Add(udword(node->GetPrimitive())); \
88 } \
89 else \
90 { \
91 _Dump(node->GetPos()); \
92 \
93 if(ContactFound()) return; \
94 \
95 _Dump(node->GetNeg()); \
96 } \
97}
98
99IMPLEMENT_NOLEAFDUMP(AABBNoLeafNode)
100IMPLEMENT_NOLEAFDUMP(AABBQuantizedNoLeafNode)
101
102IMPLEMENT_LEAFDUMP(AABBCollisionNode)
103IMPLEMENT_LEAFDUMP(AABBQuantizedNode)