Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
physinttest.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef TT_INCLUDE_PHYSINTTEST_H
13#define TT_INCLUDE_PHYSINTTEST_H
14#include "inttest.h"
15#include "MeshClass.h"
16class PhysAABoxIntersectionTestClass : public AABoxIntersectionTestClass
17{
18public:
19 PhysAABoxIntersectionTestClass(const AABoxClass & box,int col_group,int col_type,MultiListClass<PhysClass> * result_list = NULL) :
20 AABoxIntersectionTestClass(box,col_type),
21 CollisionGroup(col_group),
22 IntersectedObjects(result_list),
23 CheckStaticObjs(true),
24 CheckDynamicObjs(true)
25 {
26 }
27 void Add_Intersected_Object(PhysClass * obj) { if (IntersectedObjects) IntersectedObjects->Add(obj); }
28public:
29 int CollisionGroup;
30 bool CheckStaticObjs;
31 bool CheckDynamicObjs;
32private:
33 MultiListClass<PhysClass> * IntersectedObjects;
34 PhysAABoxIntersectionTestClass(const PhysAABoxIntersectionTestClass & );
35 PhysAABoxIntersectionTestClass & operator = (const PhysAABoxIntersectionTestClass & );
36};
37class PhysOBBoxIntersectionTestClass : public OBBoxIntersectionTestClass
38{
39public:
40 PhysOBBoxIntersectionTestClass(const OBBoxClass & box,int col_group,int col_type,MultiListClass<PhysClass> * result_list = NULL) :
41 OBBoxIntersectionTestClass(box,col_type),
42 CollisionGroup(col_group),
43 IntersectedObjects(result_list),
44 CheckStaticObjs(true),
45 CheckDynamicObjs(true)
46 {
47 }
48 void Add_Intersected_Object(PhysClass * obj) { if (IntersectedObjects) IntersectedObjects->Add(obj); }
49public:
50 int CollisionGroup;
51 bool CheckStaticObjs;
52 bool CheckDynamicObjs;
53private:
54 MultiListClass<PhysClass> * IntersectedObjects;
55 PhysOBBoxIntersectionTestClass(const PhysOBBoxIntersectionTestClass & );
56 PhysOBBoxIntersectionTestClass & operator = (const PhysOBBoxIntersectionTestClass & );
57};
58class PhysMeshIntersectionTestClass : public IntersectionTestClass
59{
60public:
61 PhysMeshIntersectionTestClass::PhysMeshIntersectionTestClass(MeshClass * mesh,int col_group,int col_type,MultiListClass<PhysClass> * result_list) :
62 IntersectionTestClass(col_type),
63 Mesh(NULL),
64 CollisionGroup(col_group),
65 IntersectedObjects(result_list),
66 CheckStaticObjs(true),
67 CheckDynamicObjs(true)
68 {
69 REF_PTR_SET(Mesh,mesh);
70 if (mesh)
71 {
72 BoundingBox = Mesh->Get_Bounding_Box();
73 }
74 }
75 ~PhysMeshIntersectionTestClass(void)
76 {
77 REF_PTR_RELEASE(Mesh);
78 }
79 bool Cull(const Vector3 & min,const Vector3 & max);
80 bool Cull(const AABoxClass & box);
81 void Add_Intersected_Object(PhysClass * obj) { if (IntersectedObjects) IntersectedObjects->Add(obj); }
82public:
83 MeshClass * Mesh;
84 AABoxClass BoundingBox;
85 int CollisionGroup;
86 bool CheckStaticObjs;
87 bool CheckDynamicObjs;
88private:
89 MultiListClass<PhysClass> * IntersectedObjects;
90private:
91 PhysMeshIntersectionTestClass(const PhysMeshIntersectionTestClass & );
92 PhysMeshIntersectionTestClass & operator = (const PhysMeshIntersectionTestClass & );
93};
94
95inline bool PhysMeshIntersectionTestClass::Cull(const Vector3 & cull_min,const Vector3 & cull_max)
96{
97 Vector3 box_min;
98 Vector3::Subtract(BoundingBox.Center,BoundingBox.Extent,&box_min);
99 Vector3 box_max;
100 Vector3::Add(BoundingBox.Center,BoundingBox.Extent,&box_max);
101 if ((box_min.X > cull_max.X) || (box_max.X < cull_min.X)) return true;
102 if ((box_min.Y > cull_max.Y) || (box_max.Y < cull_min.Y)) return true;
103 if ((box_min.Z > cull_max.Z) || (box_max.Z < cull_min.Z)) return true;
104 return false;
105}
106inline bool PhysMeshIntersectionTestClass::Cull(const AABoxClass & cull_box)
107{
108 Vector3 dc;
109 Vector3 r;
110 Vector3::Subtract(cull_box.Center,BoundingBox.Center,&dc);
111 Vector3::Add(cull_box.Extent,BoundingBox.Extent,&r);
112 if (WWMath::Fabs(dc.X) > r.X) return true;
113 if (WWMath::Fabs(dc.Y) > r.Y) return true;
114 if (WWMath::Fabs(dc.Z) > r.Z) return true;
115 return false;
116}
117#endif