| | 1 | #include "system.h" |
| | 2 | #include "prototyp.h" |
| | 3 | #include "dynblock.h" |
| | 4 | #include <stdio.h> |
| | 5 | #include <assert.h> |
| | 6 | |
| | 7 | static const DYNAMICSBLOCK DynamicsTemplate[]= |
| | 8 | { |
| | 9 | /* DYNAMICS_TEMPLATE_DEFAULT*/ |
| | 10 | { |
| | 11 | {0,0,0},/* EULER OrientEuler - Euler Orientation */ |
| | 12 | {0,0,0,0,0,0,0,0,0},/* MATRIXCH OrientMat - Local -> World Orientation Matrix */ |
| | 13 | {0,0,0},/* EULER PrevOrientEuler - Euler Orientation */ |
| | 14 | {65536,0,0,0,65536,0,0,0,65536},/* MATRIXCH PrevOrientMat - Local -> World Orientation Matrix */ |
| | 15 | |
| | 16 | {0,0,0},/* VECTORCH Position */ |
| | 17 | {0,0,0},/* VECTORCH PrevPosition */ |
| | 18 | |
| | 19 | {0,0,0},/* VECTORCH LinVelocity */ |
| | 20 | {0,0,0},/* VECTORCH LinImpulse */ |
| | 21 | |
| | 22 | {0,0,0},/* EULER AngVelocity */ |
| | 23 | |
| | 24 | NULL, /* struct collisionreport *CollisionReportPtr; */ |
| | 25 | |
| | 26 | {0,65536,0},/* VECTORCH GravityDirection */ |
| | 27 | 0, /* int TimeNotInContactWithFloor */ |
| | 28 | |
| | 29 | 0,/* int Friction; */ |
| | 30 | 0,/* int Elasticity; */ |
| | 31 | 80, /* int Mass */ |
| | 32 | |
| | 33 | DYN_TYPE_NRBB_COLLISIONS, |
| | 34 | TOPPLE_FORCE_NONE, |
| | 35 | |
| | 36 | 1,/* GravityOn :1; */ |
| | 37 | 1,/* UseStandardGravity :1 - ie. in direction of increasing Y */ |
| | 38 | 0,/* StopOnCollision :1; */ |
| | 39 | 1,/* CanClimbStairs :1; */ |
| | 40 | 0,/* IsStatic :1; */ |
| | 41 | 0,/* OnlyCollideWithObjects :1; */ |
| | 42 | 0,/* IsNetGhost :1; */ |
| | 43 | 0,/* IgnoreSameObjectsAsYou :1; */ |
| | 44 | 0,/* IgnoreThePlayer :1; */ |
| | 45 | 0,/* UseDisplacement :1; */ |
| | 46 | 0,/* OnlyCollideWithEnvironment :1; */ |
| | 47 | 0,/* IsInContactWithFloor :1 */ |
| | 48 | 0,/* IsInContactWithNearlyFlatFloor */ |
| | 49 | 0,/* IsFloating :1 */ |
| | 50 | 0,/* IsPickupObject :1 */ |
| | 51 | 0,/* IsInanimate :1; */ |
| | 52 | 0,/* IgnoresNotVisPolys :1; */ |
| | 53 | 0, |
| | 54 | 0, |
| | 55 | {0,0,0}, |
| | 56 | }, |
| | 57 | /* DYNAMICS_TEMPLATE_GRENADE */ |
| | 58 | { |
| | 59 | {0,0,0},/* EULER OrientEuler - Euler Orientation */ |
| | 60 | {0,0,0,0,0,0,0,0,0},/* MATRIXCH OrientMat - Local -> World Orientation Matrix */ |
| | 61 | {0,0,0},/* EULER PrevOrientEuler - Euler Orientation */ |
| | 62 | {65536,0,0,0,65536,0,0,0,65536},/* MATRIXCH PrevOrientMat - Local -> World Orientation Matrix */ |
| | 63 | |
| | 64 | {0,0,0},/* VECTORCH Position */ |
| | 65 | {0,0,0},/* VECTORCH PrevPosition */ |
| | 66 | |
| | 67 | {0,0,0},/* VECTORCH LinVelocity */ |
| | 68 | {0,0,0},/* VECTORCH LinImpulse */ |
| | 69 | |
| | 70 | {0,0,0},/* EULER AngVelocity */ |
| | 71 | |
| | 72 | NULL, /* struct collisionreport *CollisionReportPtr; */ |
| | 73 | |
| | 74 | {0,0,0},/* VECTORCH GravityDirection */ |
| | 75 | 0, /* int TimeNotInContactWithFloor */ |
| | 76 | |
| | 77 | 0,/* int Friction; */ |
| | 78 | 32768/2,/* int Elasticity; */ |
| | 79 | 1, /* int Mass */ |
| | 80 | |
| | 81 | DYN_TYPE_NRBB_COLLISIONS, |
| | 82 | TOPPLE_FORCE_FULL, |
| | 83 | |
| | 84 | 1,/* GravityOn :1; */ |
| | 85 | 1,/* UseStandardGravity :1 - ie. in direction of increasing Y */ |
| | 86 | 0,/* StopOnCollision :1; */ |
| | 87 | 0,/* CanClimbStairs :1; */ |
| | 88 | 0,/* IsStatic :1; */ |
| | 89 | 0,/* OnlyCollideWithObjects :1; */ |
| | 90 | 0,/* IsNetGhost :1; */ |
| | 91 | 0,/* IgnoreSameObjectsAsYou :1; */ |
| | 92 | 1,/* IgnoreThePlayer :1; */ |
| | 93 | 0,/* UseDisplacement :1; */ |
| | 94 | 0,/* OnlyCollideWithEnvironment :1; */ |
| | 95 | 0,/* IsInContactWithFloor :1 */ |
| | 96 | 0,/* IsInContactWithNearlyFlatFloor */ |
| | 97 | 0,/* IsFloating :1 */ |
| | 98 | 0,/* IsPickupObject :1 */ |
| | 99 | 0,/* IsInanimate :1; */ |
| | 100 | 0,/* IgnoresNotVisPolys :1; */ |
| | 101 | 0, |
| | 102 | 0, |
| | 103 | {0,0,0}, |
| | 104 | }, |
| | 105 | /* DYNAMICS_TEMPLATE_ROCKET & predator disc weapon */ |
| | 106 | { |
| | 107 | {0,0,0},/* EULER OrientEuler - Euler Orientation */ |
| | 108 | {0,0,0,0,0,0,0,0,0},/* MATRIXCH OrientMat - Local -> World Orientation Matrix */ |
| | 109 | {0,0,0},/* EULER PrevOrientEuler - Euler Orientation */ |
| | 110 | {65536,0,0,0,65536,0,0,0,65536},/* MATRIXCH PrevOrientMat - Local -> World Orientation Matrix */ |
| | 111 | |
| | 112 | {0,0,0},/* VECTORCH Position */ |
| | 113 | {0,0,0},/* VECTORCH PrevPosition */ |
| | 114 | |
| | 115 | {0,0,0},/* VECTORCH LinVelocity */ |
| | 116 | {0,0,0},/* VECTORCH LinImpulse */ |
| | 117 | |
| | 118 | {0,0,0},/* EULER AngVelocity */ |
| | 119 | |
| | 120 | NULL, /* struct collisionreport *CollisionReportPtr; */ |
| | 121 | |
| | 122 | {0,0,0},/* VECTORCH GravityDirection */ |
| | 123 | 0, /* int TimeNotInContactWithFloor */ |
| | 124 | |
| | 125 | 0,/* int Friction; */ |
| | 126 | 65536,/* int Elasticity; */ |
| | 127 | 5, /* int Mass */ |
| | 128 | |
| | 129 | DYN_TYPE_NRBB_COLLISIONS, |
| | 130 | TOPPLE_FORCE_NONE, |
| | 131 | |
| | 132 | 0,/* GravityOn :1; */ |
| | 133 | 0,/* UseStandardGravity :1 - ie. in direction of increasing Y */ |
| | 134 | 1,/* StopOnCollision :1; */ |
| | 135 | 0,/* CanClimbStairs :1; */ |
| | 136 | 0,/* IsStatic :1; */ |
| | 137 | 0,/* OnlyCollideWithObjects :1; */ |
| | 138 | 0,/* IsNetGhost :1; */ |
| | 139 | 0,/* IgnoreSameObjectsAsYou :1; */ |
| | 140 | 1,/* IgnoreThePlayer :1; */ |
| | 141 | 0,/* UseDisplacement :1; */ |
| | 142 | 0,/* OnlyCollideWithEnvironment :1; */ |
| | 143 | 0,/* IsInContactWithFloor :1 */ |
| | 144 | 0,/* IsInContactWithNearlyFlatFloor */ |
| | 145 | 0,/* IsFloating :1 */ |
| | 146 | 0,/* IsPickupObject :1 */ |
| | 147 | 0,/* IsInanimate :1; */ |
| | 148 | 0,/* IgnoresNotVisPolys :1; */ |
| | 149 | 0, |
| | 150 | 0, |
| | 151 | {0,0,0}, |
| | 152 | }, |
| | 153 | /* DYNAMICS_TEMPLATE_STATIC */ |
| | 154 | { |
| | 155 | {0,0,0},/* EULER OrientEuler - Euler Orientation */ |
| | 156 | {65536,0,0,0,65536,0,0,0,65536},/* MATRIXCH OrientMat - Local -> World Orientation Matrix */ |
| | 157 | {0,0,0},/* EULER PrevOrientEuler - Euler Orientation */ |
| | 158 | {65536,0,0,0,65536,0,0,0,65536},/* MATRIXCH PrevOrientMat - Local -> World Orientation Matrix */ |
| | 159 | |
| | 160 | {0,0,0},/* VECTORCH Position */ |
| | 161 | {0,0,0},/* VECTORCH PrevPosition */ |
| | 162 | |
| | 163 | {0,0,0},/* VECTORCH LinVelocity */ |
| | 164 | {0,0,0},/* VECTORCH LinImpulse */ |
| | 165 | |
| | 166 | {0,0,0},/* EULER AngVelocity */ |
| | 167 | |
| | 168 | NULL, /* struct collisionreport *CollisionReportPtr; */ |
| | 169 | |
| | 170 | {0,0,0},/* VECTORCH GravityDirection */ |
| | 171 | 0, /* int TimeNotInContactWithFloor */ |
| | 172 | |
| | 173 | 0,/* int Friction; */ |
| | 174 | 0,/* int Elasticity; */ |
| | 175 | 100, /* int Mass */ |
| | 176 | |
| | 177 | DYN_TYPE_NRBB_COLLISIONS, |
| | 178 | TOPPLE_FORCE_NONE, |
| | 179 | |
| | 180 | 1,/* GravityOn :1; */ |
| | 181 | 1,/* UseStandardGravity :1 - ie. in direction of increasing Y */ |
| | 182 | 0,/* StopOnCollision :1; */ |
| | 183 | 0,/* CanClimbStairs :1; */ |
| | 184 | 1,/* IsStatic :1; */ |
| | 185 | 0,/* OnlyCollideWithObjects :1; */ |
| | 186 | 0,/* IsNetGhost :1; */ |
| | 187 | 0,/* IgnoreSameObjectsAsYou :1; */ |
| | 188 | 0,/* IgnoreThePlayer :1; */ |
| | 189 | 0,/* UseDisplacement :1; */ |
| | 190 | 0,/* OnlyCollideWithEnvironment :1; */ |
| | 191 | 0,/* IsInContactWithFloor :1 */ |
| | 192 | 0,/* IsInContactWithNearlyFlatFloor */ |
| | 193 | 0,/* IsFloating :1 */ |
| | 194 | 0,/* IsPickupObject :1 */ |
| | 195 | 0,/* IsInanimate :1; */ |
| | 196 | 0,/* IgnoresNotVisPolys :1; */ |
| | 197 | 0, |
| | 198 | 0, |
| | 199 | {0,0,0}, |
| | 200 | } |
| | 201 | }; |
| | 202 | |
| | 203 | static int NumFreeDynBlocks = MAX_NO_OF_DYNAMICS_BLOCKS; |
| | 204 | static DYNAMICSBLOCK **FreeDynBlockListPtr = NULL; |
| | 205 | |
| | 206 | void InitialiseDynamicsBlocks() |
| | 207 | { |
| | 208 | static DYNAMICSBLOCK DynBlockStorage[MAX_NO_OF_DYNAMICS_BLOCKS]; |
| | 209 | static DYNAMICSBLOCK *FreeDynBlockList[MAX_NO_OF_DYNAMICS_BLOCKS]; |
| | 210 | int blk; |
| | 211 | |
| | 212 | for(blk = 0; blk < MAX_NO_OF_DYNAMICS_BLOCKS; blk++) |
| | 213 | FreeDynBlockList[blk] = &DynBlockStorage[blk]; |
| | 214 | |
| | 215 | FreeDynBlockListPtr = &FreeDynBlockList[MAX_NO_OF_DYNAMICS_BLOCKS - 1]; |
| | 216 | NumFreeDynBlocks = MAX_NO_OF_DYNAMICS_BLOCKS; |
| | 217 | } |
| | 218 | |
| | 219 | DYNAMICSBLOCK* AllocateDynamicsBlock(enum DYNAMICS_TEMPLATE_ID templateID) |
| | 220 | { |
| | 221 | if (NumFreeDynBlocks) |
| | 222 | { |
| | 223 | DYNAMICSBLOCK *dynPtr = *FreeDynBlockListPtr--; |
| | 224 | *dynPtr = DynamicsTemplate[templateID]; |
| | 225 | NumFreeDynBlocks--; |
| | 226 | return dynPtr; |
| | 227 | } |
| | 228 | |
| | 229 | return NULL; |
| | 230 | } |
| | 231 | |
| | 232 | void DeallocateDynamicsBlock(DYNAMICSBLOCK *dynPtr) |
| | 233 | { |
| | 234 | *(++FreeDynBlockListPtr) = dynPtr; |
| | 235 | NumFreeDynBlocks++; |
| | 236 | } |
| | 237 | |
| | 238 | int DynamicObjectIsMoving(const DYNAMICSBLOCK *dynPtr) |
| | 239 | { |
| | 240 | return ( (dynPtr->Position.vx != dynPtr->PrevPosition.vx) |
| | 241 | || |
| | 242 | (dynPtr->Position.vy != dynPtr->PrevPosition.vy) |
| | 243 | || |
| | 244 | (dynPtr->Position.vz != dynPtr->PrevPosition.vz)); |
| | 245 | } |