00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 INLINE CollisionEntry::
00022 CollisionEntry() {
00023 _flags = 0;
00024
00025 _t = 2.f;
00026 }
00027
00028
00029
00030
00031
00032
00033
00034 INLINE const CollisionSolid *CollisionEntry::
00035 get_from() const {
00036 return _from;
00037 }
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 INLINE bool CollisionEntry::
00050 has_into() const {
00051 return (_into != (CollisionSolid *)NULL);
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 INLINE const CollisionSolid *CollisionEntry::
00064 get_into() const {
00065 return _into;
00066 }
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 INLINE CollisionNode *CollisionEntry::
00077 get_from_node() const {
00078 return _from_node;
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 INLINE PandaNode *CollisionEntry::
00092 get_into_node() const {
00093 return _into_node;
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 INLINE NodePath CollisionEntry::
00106 get_from_node_path() const {
00107 return _from_node_path;
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 INLINE NodePath CollisionEntry::
00122 get_into_node_path() const {
00123 return _into_node_path;
00124 }
00125
00126
00127
00128
00129
00130
00131
00132 INLINE void CollisionEntry::
00133 set_t(PN_stdfloat t) {
00134 nassertv(!cnan(t));
00135 _t = t;
00136 }
00137
00138
00139
00140
00141
00142
00143
00144 INLINE PN_stdfloat CollisionEntry::
00145 get_t() const {
00146 return _t;
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 INLINE bool CollisionEntry::
00158 collided() const {
00159 return ((0.f <= _t) && (_t <= 1.f));
00160 }
00161
00162
00163
00164
00165
00166
00167 INLINE void CollisionEntry::
00168 reset_collided() {
00169 _t = 2.f;
00170 }
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 INLINE bool CollisionEntry::
00181 get_respect_prev_transform() const {
00182 return (_flags & F_respect_prev_transform) != 0;
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 INLINE void CollisionEntry::
00196 set_surface_point(const LPoint3 &point) {
00197 nassertv(!point.is_nan());
00198 _surface_point = point;
00199 _flags |= F_has_surface_point;
00200 }
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 INLINE void CollisionEntry::
00212 set_surface_normal(const LVector3 &normal) {
00213 nassertv(!normal.is_nan());
00214 _surface_normal = normal;
00215 _flags |= F_has_surface_normal;
00216 }
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 INLINE void CollisionEntry::
00232 set_interior_point(const LPoint3 &point) {
00233 nassertv(!point.is_nan());
00234 _interior_point = point;
00235 _flags |= F_has_interior_point;
00236 }
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 INLINE bool CollisionEntry::
00247 has_surface_point() const {
00248 return (_flags & F_has_surface_point) != 0;
00249 }
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 INLINE bool CollisionEntry::
00260 has_surface_normal() const {
00261 return (_flags & F_has_surface_normal) != 0;
00262 }
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 INLINE bool CollisionEntry::
00273 has_interior_point() const {
00274 return (_flags & F_has_interior_point) != 0;
00275 }
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286 INLINE void CollisionEntry::
00287 set_contact_pos(const LPoint3 &pos) {
00288 nassertv(!pos.is_nan());
00289 _contact_pos = pos;
00290 _flags |= F_has_contact_pos;
00291 }
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 INLINE void CollisionEntry::
00303 set_contact_normal(const LVector3 &normal) {
00304 nassertv(!normal.is_nan());
00305 _contact_normal = normal;
00306 _flags |= F_has_contact_normal;
00307 }
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 INLINE bool CollisionEntry::
00318 has_contact_pos() const {
00319 return (_flags & F_has_contact_pos) != 0;
00320 }
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330 INLINE bool CollisionEntry::
00331 has_contact_normal() const {
00332 return (_flags & F_has_contact_normal) != 0;
00333 }
00334
00335
00336
00337
00338
00339
00340
00341 INLINE CPT(TransformState) CollisionEntry::
00342 get_wrt_space() const {
00343 return _from_node_path.get_transform(_into_node_path);
00344 }
00345
00346
00347
00348
00349
00350
00351
00352 INLINE CPT(TransformState) CollisionEntry::
00353 get_inv_wrt_space() const {
00354 return _into_node_path.get_transform(_from_node_path);
00355 }
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 INLINE CPT(TransformState) CollisionEntry::
00366 get_wrt_prev_space() const {
00367 if (get_respect_prev_transform()) {
00368 return _from_node_path.get_prev_transform(_into_node_path);
00369 } else {
00370 return get_wrt_space();
00371 }
00372 }
00373
00374
00375
00376
00377
00378
00379
00380 INLINE const LMatrix4 &CollisionEntry::
00381 get_wrt_mat() const {
00382 return get_wrt_space()->get_mat();
00383 }
00384
00385
00386
00387
00388
00389
00390
00391 INLINE const LMatrix4 &CollisionEntry::
00392 get_inv_wrt_mat() const {
00393 return get_inv_wrt_space()->get_mat();
00394 }
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 INLINE const LMatrix4 &CollisionEntry::
00405 get_wrt_prev_mat() const {
00406 return get_wrt_prev_space()->get_mat();
00407 }
00408
00409
00410
00411
00412
00413
00414
00415
00416 INLINE const ClipPlaneAttrib *CollisionEntry::
00417 get_into_clip_planes() const {
00418 if ((_flags & F_checked_clip_planes) == 0) {
00419 ((CollisionEntry *)this)->check_clip_planes();
00420 }
00421 return _into_clip_planes;
00422 }
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433 INLINE void CollisionEntry::
00434 test_intersection(CollisionHandler *record,
00435 const CollisionTraverser *trav) const {
00436 PT(CollisionEntry) result = get_from()->test_intersection(*this);
00437 #ifdef DO_COLLISION_RECORDING
00438 if (trav->has_recorder()) {
00439 if (result != (CollisionEntry *)NULL) {
00440 trav->get_recorder()->collision_tested(*result, true);
00441 } else {
00442 trav->get_recorder()->collision_tested(*this, false);
00443 }
00444 }
00445 #endif // DO_COLLISION_RECORDING
00446 #ifdef DO_PSTATS
00447 ((CollisionSolid *)get_into())->get_test_pcollector().add_level(1);
00448 #endif // DO_PSTATS
00449
00450
00451 if (record->wants_all_potential_collidees() && result == (CollisionEntry *)NULL) {
00452 result = new CollisionEntry(*this);
00453 result->reset_collided();
00454 }
00455 if (result != (CollisionEntry *)NULL) {
00456 record->add_entry(result);
00457 }
00458 }
00459
00460 INLINE ostream &
00461 operator << (ostream &out, const CollisionEntry &entry) {
00462 entry.output(out);
00463 return out;
00464 }