37 "Collision Volumes:CollisionSolid");
39 "Collision Tests:CollisionSolid");
46CollisionSolid() : _lock(
"CollisionSolid") {
47 _flags = F_viz_geom_stale | F_tangible | F_internal_bounds_stale;
56 _effective_normal(copy._effective_normal),
57 _internal_bounds(copy._internal_bounds),
59 _lock(
"CollisionSolid")
61 _flags |= F_viz_geom_stale;
84 LightMutexHolder holder(_lock);
85 if (_flags & F_internal_bounds_stale) {
86 ((CollisionSolid *)
this)->_internal_bounds = compute_internal_bounds();
87 ((CollisionSolid *)
this)->_flags &= ~F_internal_bounds_stale;
89 return _internal_bounds;
97 LightMutexHolder holder(_lock);
98 ((CollisionSolid *)
this)->_internal_bounds = bounding_volume.make_copy();
99 ((CollisionSolid *)
this)->_flags &= ~F_internal_bounds_stale;
110 report_undefined_from_intersection(get_type());
118xform(
const LMatrix4 &mat) {
120 if ((_flags & F_effective_normal) != 0) {
121 _effective_normal = _effective_normal * mat;
122 _effective_normal.normalize();
125 _flags |= F_viz_geom_stale | F_internal_bounds_stale;
136 if ((_flags & F_viz_geom_stale) != 0) {
137 if (_viz_geom ==
nullptr) {
141 _viz_geom->remove_all_geoms();
142 _bounds_viz_geom->remove_all_geoms();
144 ((CollisionSolid *)
this)->fill_viz_geom();
145 ((CollisionSolid *)
this)->_flags &= ~F_viz_geom_stale;
149 return _bounds_viz_geom;
161 return _volume_pcollector;
170 return _test_pcollector;
177output(std::ostream &out)
const {
185write(std::ostream &out,
int indent_level)
const {
186 indent(out, indent_level) << (*this) <<
"\n";
193compute_internal_bounds()
const {
194 return new BoundingSphere;
203 report_undefined_intersection_test(CollisionSphere::get_class_type(),
214 report_undefined_intersection_test(CollisionLine::get_class_type(),
225 report_undefined_intersection_test(CollisionRay::get_class_type(),
236 report_undefined_intersection_test(CollisionSegment::get_class_type(),
247 report_undefined_intersection_test(CollisionCapsule::get_class_type(),
258 report_undefined_intersection_test(CollisionParabola::get_class_type(),
269 report_undefined_intersection_test(CollisionBox::get_class_type(),
276class CollisionSolidUndefinedPair {
278 CollisionSolidUndefinedPair(TypeHandle a, TypeHandle b) :
281 bool operator < (
const CollisionSolidUndefinedPair &other)
const {
282 if (_a != other._a) {
283 return _a < other._a;
285 return _b < other._b;
300 typedef pset<CollisionSolidUndefinedPair> Reported;
301 static Reported reported;
303 if (reported.insert(CollisionSolidUndefinedPair(from_type, into_type)).second) {
305 <<
"Invalid attempt to detect collision from " << from_type <<
" into "
306 << into_type <<
"!\n\n"
308 "This means that a " << from_type <<
" object attempted to test for an\n"
309 "intersection into a " << into_type <<
" object. This intersection\n"
310 "test has not yet been defined; it is possible the " << into_type <<
"\n"
311 "object is not intended to be collidable. Consider calling\n"
312 "set_into_collide_mask(0) on the " << into_type <<
" object, or\n"
313 "set_from_collide_mask(0) on the " << from_type <<
" object.\n\n";
323report_undefined_from_intersection(
TypeHandle from_type) {
325 typedef pset<TypeHandle> Reported;
326 static Reported reported;
328 if (reported.insert(from_type).second) {
330 <<
"Invalid attempt to detect collision from " << from_type <<
"!\n\n"
332 "This means that a " << from_type <<
" object was added to a\n"
333 "CollisionTraverser as if it were a colliding object. However,\n"
334 "no implementation for this kind of object has yet been defined\n"
335 "to collide with other objects.\n\n";
350 if ((_flags & F_effective_normal) != 0) {
351 _effective_normal.write_datagram(me);
363 if ((_flags & F_effective_normal) != 0) {
364 _effective_normal.read_datagram(scan);
369 _flags |= F_viz_geom_stale | F_internal_bounds_stale;
389get_solid_viz_state() {
392 static CPT(RenderState) base_state =
nullptr;
393 if (base_state ==
nullptr) {
400 if (!do_is_tangible()) {
401 static CPT(RenderState) intangible_state =
nullptr;
402 if (intangible_state ==
nullptr) {
403 intangible_state = base_state->add_attrib
406 return intangible_state;
408 }
else if (do_has_effective_normal()) {
409 static CPT(RenderState) fakenormal_state =
nullptr;
410 if (fakenormal_state ==
nullptr) {
411 fakenormal_state = base_state->add_attrib
414 return fakenormal_state;
417 static CPT(RenderState) tangible_state =
nullptr;
418 if (tangible_state ==
nullptr) {
419 tangible_state = base_state->add_attrib
422 return tangible_state;
435get_wireframe_viz_state() {
438 static CPT(RenderState) base_state =
nullptr;
439 if (base_state ==
nullptr) {
446 if (!do_is_tangible()) {
447 static CPT(RenderState) intangible_state =
nullptr;
448 if (intangible_state ==
nullptr) {
449 intangible_state = base_state->add_attrib
452 return intangible_state;
454 }
else if (do_has_effective_normal()) {
455 static CPT(RenderState) fakenormal_state =
nullptr;
456 if (fakenormal_state ==
nullptr) {
457 fakenormal_state = base_state->add_attrib
460 return fakenormal_state;
463 static CPT(RenderState) tangible_state =
nullptr;
464 if (tangible_state ==
nullptr) {
465 tangible_state = base_state->add_attrib
468 return tangible_state;
480get_other_viz_state() {
483 static CPT(RenderState) base_state =
nullptr;
484 if (base_state ==
nullptr) {
504get_solid_bounds_viz_state() {
507 static CPT(RenderState) base_state =
nullptr;
508 if (base_state ==
nullptr) {
515 if (!do_is_tangible()) {
516 static CPT(RenderState) intangible_state =
nullptr;
517 if (intangible_state ==
nullptr) {
518 intangible_state = base_state->add_attrib
521 return intangible_state;
523 }
else if (do_has_effective_normal()) {
524 static CPT(RenderState) fakenormal_state =
nullptr;
525 if (fakenormal_state ==
nullptr) {
526 fakenormal_state = base_state->add_attrib
529 return fakenormal_state;
532 static CPT(RenderState) tangible_state =
nullptr;
533 if (tangible_state ==
nullptr) {
534 tangible_state = base_state->add_attrib
537 return tangible_state;
550get_wireframe_bounds_viz_state() {
553 static CPT(RenderState) base_state =
nullptr;
554 if (base_state ==
nullptr) {
573get_other_bounds_viz_state() {
576 static CPT(RenderState) base_state =
nullptr;
577 if (base_state ==
nullptr) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
Defines a single collision event.
The abstract base class for all things that can collide with other things in the world,...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
virtual PStatCollector & get_test_pcollector()
Returns a PStatCollector that is used to count the number of intersection tests made against a solid ...
get_bounds
Returns the solid's bounding volume.
set_bounds
Returns the solid's bounding volume.
virtual void xform(const LMatrix4 &mat)
Transforms the solid by the indicated matrix.
virtual PStatCollector & get_volume_pcollector()
Returns a PStatCollector that is used to count the number of bounding volume tests made against a sol...
static ConstPointerTo< RenderAttrib > make_flat(const LColor &color)
Constructs a new ColorAttrib object that indicates geometry should be rendered in the indicated color...
This base class provides basic reference counting, but also can be used with a CopyOnWritePointer to ...
static ConstPointerTo< RenderAttrib > make(Mode mode=M_cull_clockwise)
Constructs a new CullFaceAttrib object that specifies how to cull geometry.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
A class to retrieve the individual data elements previously stored in a Datagram.
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
A node that holds Geom objects, renderable pieces of geometry.
Similar to MutexHolder, but for a light mutex.
A lightweight class that represents a single element that may be timed and/or counted via stats.
A basic node of the scene graph or data graph.
static ConstPointerTo< RenderAttrib > make(Mode mode, PN_stdfloat thickness=1.0f, bool perspective=false, const LColor &wireframe_color=LColor::zero())
Constructs a new RenderModeAttrib object that specifies whether to draw polygons in the normal,...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
static ConstPointerTo< RenderState > make(const RenderAttrib *attrib, int override=0)
Returns a RenderState with one attribute set.
static ConstPointerTo< RenderAttrib > make(Mode mode)
Constructs a new TransparencyAttrib object.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.