mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
better color choices for showCollisions
This commit is contained in:
parent
b9009141e1
commit
1d8b862db4
@ -104,6 +104,7 @@ fill_viz_geom() {
|
|||||||
line->set_num_prims(1);
|
line->set_num_prims(1);
|
||||||
|
|
||||||
_viz_geom->add_geom(line, get_other_viz_state());
|
_viz_geom->add_geom(line, get_other_viz_state());
|
||||||
|
_bounds_viz_geom->add_geom(line, get_other_bounds_viz_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -224,7 +224,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) {
|
|||||||
Solids::iterator si;
|
Solids::iterator si;
|
||||||
for (si = _solids.begin(); si != _solids.end(); ++si) {
|
for (si = _solids.begin(); si != _solids.end(); ++si) {
|
||||||
CollisionSolid *solid = (*si);
|
CollisionSolid *solid = (*si);
|
||||||
PT(PandaNode) node = solid->get_viz(data);
|
PT(PandaNode) node = solid->get_viz(data, false);
|
||||||
if (node != (PandaNode *)NULL) {
|
if (node != (PandaNode *)NULL) {
|
||||||
CullTraverserData next_data(data, node);
|
CullTraverserData next_data(data, node);
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) {
|
|||||||
|
|
||||||
for (si = _solids.begin(); si != _solids.end(); ++si) {
|
for (si = _solids.begin(); si != _solids.end(); ++si) {
|
||||||
CollisionSolid *solid = (*si);
|
CollisionSolid *solid = (*si);
|
||||||
PT(PandaNode) node = solid->get_viz(data);
|
PT(PandaNode) node = solid->get_viz(data, false);
|
||||||
if (node != (PandaNode *)NULL) {
|
if (node != (PandaNode *)NULL) {
|
||||||
CullTraverserData next_data(data, node);
|
CullTraverserData next_data(data, node);
|
||||||
|
|
||||||
|
@ -334,6 +334,8 @@ fill_viz_geom() {
|
|||||||
|
|
||||||
_viz_geom->add_geom(quad, get_solid_viz_state());
|
_viz_geom->add_geom(quad, get_solid_viz_state());
|
||||||
_viz_geom->add_geom(quad, get_wireframe_viz_state());
|
_viz_geom->add_geom(quad, get_wireframe_viz_state());
|
||||||
|
_bounds_viz_geom->add_geom(quad, get_solid_bounds_viz_state());
|
||||||
|
_bounds_viz_geom->add_geom(quad, get_wireframe_bounds_viz_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -275,13 +275,13 @@ get_collision_origin() const {
|
|||||||
// made visible.
|
// made visible.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PT(PandaNode) CollisionPolygon::
|
PT(PandaNode) CollisionPolygon::
|
||||||
get_viz(const CullTraverserData &data) const {
|
get_viz(const CullTraverserData &data, bool bounds_only) const {
|
||||||
const RenderAttrib *cpa_attrib =
|
const RenderAttrib *cpa_attrib =
|
||||||
data._state->get_attrib(ClipPlaneAttrib::get_class_type());
|
data._state->get_attrib(ClipPlaneAttrib::get_class_type());
|
||||||
if (cpa_attrib == (const RenderAttrib *)NULL) {
|
if (cpa_attrib == (const RenderAttrib *)NULL) {
|
||||||
// Fortunately, the polygon is not clipped. This is the normal,
|
// Fortunately, the polygon is not clipped. This is the normal,
|
||||||
// easy case.
|
// easy case.
|
||||||
return CollisionSolid::get_viz(data);
|
return CollisionSolid::get_viz(data, bounds_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collide_cat.is_debug()) {
|
if (collide_cat.is_debug()) {
|
||||||
@ -300,7 +300,7 @@ get_viz(const CullTraverserData &data) const {
|
|||||||
if (apply_clip_plane(new_points, cpa, data._net_transform)) {
|
if (apply_clip_plane(new_points, cpa, data._net_transform)) {
|
||||||
// All points are behind the clip plane; just draw the original
|
// All points are behind the clip plane; just draw the original
|
||||||
// polygon.
|
// polygon.
|
||||||
return CollisionSolid::get_viz(data);
|
return CollisionSolid::get_viz(data, bounds_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_points.empty()) {
|
if (new_points.empty()) {
|
||||||
@ -309,10 +309,15 @@ get_viz(const CullTraverserData &data) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw the clipped polygon.
|
// Draw the clipped polygon.
|
||||||
PT(GeomNode) geom_node = new GeomNode("viz");
|
PT(GeomNode) viz_geom_node = new GeomNode("viz");
|
||||||
draw_polygon(geom_node, new_points);
|
PT(GeomNode) bounds_viz_geom_node = new GeomNode("bounds_viz");
|
||||||
|
draw_polygon(viz_geom_node, bounds_viz_geom_node, new_points);
|
||||||
|
|
||||||
return geom_node.p();
|
if (bounds_only) {
|
||||||
|
return bounds_viz_geom_node.p();
|
||||||
|
} else {
|
||||||
|
return viz_geom_node.p();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -769,7 +774,7 @@ fill_viz_geom() {
|
|||||||
collide_cat.debug()
|
collide_cat.debug()
|
||||||
<< "Recomputing viz for " << *this << "\n";
|
<< "Recomputing viz for " << *this << "\n";
|
||||||
}
|
}
|
||||||
draw_polygon(_viz_geom, _points);
|
draw_polygon(_viz_geom, _bounds_viz_geom, _points);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -796,7 +801,8 @@ compute_vectors(Points &points) {
|
|||||||
// points.
|
// points.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CollisionPolygon::
|
void CollisionPolygon::
|
||||||
draw_polygon(GeomNode *geom_node, const CollisionPolygon::Points &points) const {
|
draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node,
|
||||||
|
const CollisionPolygon::Points &points) const {
|
||||||
if (points.size() < 3) {
|
if (points.size() < 3) {
|
||||||
if (collide_cat.is_debug()) {
|
if (collide_cat.is_debug()) {
|
||||||
collide_cat.debug()
|
collide_cat.debug()
|
||||||
@ -821,8 +827,11 @@ draw_polygon(GeomNode *geom_node, const CollisionPolygon::Points &points) const
|
|||||||
polygon->set_num_prims(1);
|
polygon->set_num_prims(1);
|
||||||
polygon->set_lengths(lengths);
|
polygon->set_lengths(lengths);
|
||||||
|
|
||||||
geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_solid_viz_state());
|
viz_geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_solid_viz_state());
|
||||||
geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_wireframe_viz_state());
|
viz_geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_wireframe_viz_state());
|
||||||
|
|
||||||
|
bounds_viz_geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_solid_bounds_viz_state());
|
||||||
|
bounds_viz_geom_node->add_geom(polygon, ((CollisionPolygon *)this)->get_wireframe_bounds_viz_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +61,8 @@ public:
|
|||||||
virtual void xform(const LMatrix4f &mat);
|
virtual void xform(const LMatrix4f &mat);
|
||||||
virtual LPoint3f get_collision_origin() const;
|
virtual LPoint3f get_collision_origin() const;
|
||||||
|
|
||||||
virtual PT(PandaNode) get_viz(const CullTraverserData &data) const;
|
virtual PT(PandaNode) get_viz(const CullTraverserData &data,
|
||||||
|
bool bounds_only) const;
|
||||||
|
|
||||||
virtual void output(ostream &out) const;
|
virtual void output(ostream &out) const;
|
||||||
virtual void write(ostream &out, int indent_level = 0) const;
|
virtual void write(ostream &out, int indent_level = 0) const;
|
||||||
@ -94,7 +95,8 @@ private:
|
|||||||
typedef pvector<PointDef> Points;
|
typedef pvector<PointDef> Points;
|
||||||
|
|
||||||
static void compute_vectors(Points &points);
|
static void compute_vectors(Points &points);
|
||||||
void draw_polygon(GeomNode *geom_node, const Points &points) const;
|
void draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node,
|
||||||
|
const Points &points) const;
|
||||||
|
|
||||||
bool point_is_inside(const LPoint2f &p, const Points &points) const;
|
bool point_is_inside(const LPoint2f &p, const Points &points) const;
|
||||||
float dist_to_polygon(const LPoint2f &p, const Points &points) const;
|
float dist_to_polygon(const LPoint2f &p, const Points &points) const;
|
||||||
|
@ -176,6 +176,7 @@ fill_viz_geom() {
|
|||||||
line->set_num_prims(1);
|
line->set_num_prims(1);
|
||||||
|
|
||||||
_viz_geom->add_geom(line, get_other_viz_state());
|
_viz_geom->add_geom(line, get_other_viz_state());
|
||||||
|
_bounds_viz_geom->add_geom(line, get_other_bounds_viz_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -169,6 +169,7 @@ fill_viz_geom() {
|
|||||||
segment->set_num_prims(1);
|
segment->set_num_prims(1);
|
||||||
|
|
||||||
_viz_geom->add_geom(segment, get_other_viz_state());
|
_viz_geom->add_geom(segment, get_other_viz_state());
|
||||||
|
_bounds_viz_geom->add_geom(segment, get_other_bounds_viz_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -108,17 +108,24 @@ xform(const LMatrix4f &mat) {
|
|||||||
// made visible.
|
// made visible.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PT(PandaNode) CollisionSolid::
|
PT(PandaNode) CollisionSolid::
|
||||||
get_viz(const CullTraverserData &) const {
|
get_viz(const CullTraverserData &, bool bounds_only) const {
|
||||||
if ((_flags & F_viz_geom_stale) != 0) {
|
if ((_flags & F_viz_geom_stale) != 0) {
|
||||||
if (_viz_geom == (GeomNode *)NULL) {
|
if (_viz_geom == (GeomNode *)NULL) {
|
||||||
((CollisionSolid *)this)->_viz_geom = new GeomNode("viz");
|
((CollisionSolid *)this)->_viz_geom = new GeomNode("viz");
|
||||||
|
((CollisionSolid *)this)->_bounds_viz_geom = new GeomNode("bounds_viz");
|
||||||
} else {
|
} else {
|
||||||
_viz_geom->remove_all_geoms();
|
_viz_geom->remove_all_geoms();
|
||||||
|
_bounds_viz_geom->remove_all_geoms();
|
||||||
}
|
}
|
||||||
((CollisionSolid *)this)->fill_viz_geom();
|
((CollisionSolid *)this)->fill_viz_geom();
|
||||||
((CollisionSolid *)this)->_flags &= ~F_viz_geom_stale;
|
((CollisionSolid *)this)->_flags &= ~F_viz_geom_stale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bounds_only) {
|
||||||
|
return _bounds_viz_geom.p();
|
||||||
|
} else {
|
||||||
return _viz_geom.p();
|
return _viz_geom.p();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -388,21 +395,29 @@ get_wireframe_viz_state() {
|
|||||||
TransparencyAttrib::make(TransparencyAttrib::M_none));
|
TransparencyAttrib::make(TransparencyAttrib::M_none));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_tangible()) {
|
if (!is_tangible()) {
|
||||||
static CPT(RenderState) tangible_state = (const RenderState *)NULL;
|
|
||||||
if (tangible_state == (const RenderState *)NULL) {
|
|
||||||
tangible_state = base_state->add_attrib
|
|
||||||
(ColorAttrib::make_flat(Colorf(0.0f, 0.0f, 1.0f, 1.0f)));
|
|
||||||
}
|
|
||||||
return tangible_state;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
static CPT(RenderState) intangible_state = (const RenderState *)NULL;
|
static CPT(RenderState) intangible_state = (const RenderState *)NULL;
|
||||||
if (intangible_state == (const RenderState *)NULL) {
|
if (intangible_state == (const RenderState *)NULL) {
|
||||||
intangible_state = base_state->add_attrib
|
intangible_state = base_state->add_attrib
|
||||||
(ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 0.0f, 1.0f)));
|
(ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 0.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
return intangible_state;
|
return intangible_state;
|
||||||
|
|
||||||
|
} else if (has_effective_normal()) {
|
||||||
|
static CPT(RenderState) fakenormal_state = (const RenderState *)NULL;
|
||||||
|
if (fakenormal_state == (const RenderState *)NULL) {
|
||||||
|
fakenormal_state = base_state->add_attrib
|
||||||
|
(ColorAttrib::make_flat(Colorf(0.0f, 0.0f, 1.0f, 1.0f)));
|
||||||
|
}
|
||||||
|
return fakenormal_state;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
static CPT(RenderState) tangible_state = (const RenderState *)NULL;
|
||||||
|
if (tangible_state == (const RenderState *)NULL) {
|
||||||
|
tangible_state = base_state->add_attrib
|
||||||
|
(ColorAttrib::make_flat(Colorf(0.0f, 0.0f, 1.0f, 1.0f)));
|
||||||
|
}
|
||||||
|
return tangible_state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,3 +446,99 @@ get_other_viz_state() {
|
|||||||
return base_state;
|
return base_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CollisionSolid::get_solid_bounds_viz_state
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Returns a RenderState for rendering collision
|
||||||
|
// visualizations in solid. This automatically returns
|
||||||
|
// the appropriate state according to the setting of
|
||||||
|
// _tangible.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CPT(RenderState) CollisionSolid::
|
||||||
|
get_solid_bounds_viz_state() {
|
||||||
|
// Once someone asks for this pointer, we hold its reference count
|
||||||
|
// and never free it.
|
||||||
|
static CPT(RenderState) base_state = (const RenderState *)NULL;
|
||||||
|
if (base_state == (const RenderState *)NULL) {
|
||||||
|
base_state = RenderState::make
|
||||||
|
(CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise),
|
||||||
|
RenderModeAttrib::make(RenderModeAttrib::M_filled),
|
||||||
|
TransparencyAttrib::make(TransparencyAttrib::M_alpha));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_tangible()) {
|
||||||
|
static CPT(RenderState) intangible_state = (const RenderState *)NULL;
|
||||||
|
if (intangible_state == (const RenderState *)NULL) {
|
||||||
|
intangible_state = base_state->add_attrib
|
||||||
|
(ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 0.5f, 0.3f)));
|
||||||
|
}
|
||||||
|
return intangible_state;
|
||||||
|
|
||||||
|
} else if (has_effective_normal()) {
|
||||||
|
static CPT(RenderState) fakenormal_state = (const RenderState *)NULL;
|
||||||
|
if (fakenormal_state == (const RenderState *)NULL) {
|
||||||
|
fakenormal_state = base_state->add_attrib
|
||||||
|
(ColorAttrib::make_flat(Colorf(0.5f, 0.5f, 1.0f, 0.3f)));
|
||||||
|
}
|
||||||
|
return fakenormal_state;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
static CPT(RenderState) tangible_state = (const RenderState *)NULL;
|
||||||
|
if (tangible_state == (const RenderState *)NULL) {
|
||||||
|
tangible_state = base_state->add_attrib
|
||||||
|
(ColorAttrib::make_flat(Colorf(1.0f, 1.0f, 0.5f, 0.3f)));
|
||||||
|
}
|
||||||
|
return tangible_state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CollisionSolid::get_wireframe_bounds_viz_state
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Returns a RenderState for rendering collision
|
||||||
|
// visualizations in wireframe. This automatically returns
|
||||||
|
// the appropriate state according to the setting of
|
||||||
|
// _tangible.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CPT(RenderState) CollisionSolid::
|
||||||
|
get_wireframe_bounds_viz_state() {
|
||||||
|
// Once someone asks for this pointer, we hold its reference count
|
||||||
|
// and never free it.
|
||||||
|
static CPT(RenderState) base_state = (const RenderState *)NULL;
|
||||||
|
if (base_state == (const RenderState *)NULL) {
|
||||||
|
base_state = RenderState::make
|
||||||
|
(CullFaceAttrib::make(CullFaceAttrib::M_cull_none),
|
||||||
|
RenderModeAttrib::make(RenderModeAttrib::M_wireframe),
|
||||||
|
TransparencyAttrib::make(TransparencyAttrib::M_none),
|
||||||
|
ColorAttrib::make_flat(Colorf(1.0f, 0.0f, 0.0f, 1.0f)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return base_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CollisionSolid::get_other_bounds_viz_state
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Returns a RenderState for rendering collision
|
||||||
|
// visualizations for things that are neither solid nor
|
||||||
|
// exactly wireframe, like rays and segments.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CPT(RenderState) CollisionSolid::
|
||||||
|
get_other_bounds_viz_state() {
|
||||||
|
// Once someone asks for this pointer, we hold its reference count
|
||||||
|
// and never free it.
|
||||||
|
static CPT(RenderState) base_state = (const RenderState *)NULL;
|
||||||
|
if (base_state == (const RenderState *)NULL) {
|
||||||
|
base_state = RenderState::make
|
||||||
|
(CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise),
|
||||||
|
RenderModeAttrib::make(RenderModeAttrib::M_filled),
|
||||||
|
TransparencyAttrib::make(TransparencyAttrib::M_alpha));
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't bother to make a distinction here between tangible and
|
||||||
|
// intangible.
|
||||||
|
return base_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,8 @@ public:
|
|||||||
|
|
||||||
virtual void xform(const LMatrix4f &mat);
|
virtual void xform(const LMatrix4f &mat);
|
||||||
|
|
||||||
virtual PT(PandaNode) get_viz(const CullTraverserData &data) const;
|
virtual PT(PandaNode) get_viz(const CullTraverserData &data,
|
||||||
|
bool bounds_only) const;
|
||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
virtual void output(ostream &out) const;
|
virtual void output(ostream &out) const;
|
||||||
@ -103,8 +104,12 @@ protected:
|
|||||||
CPT(RenderState) get_solid_viz_state();
|
CPT(RenderState) get_solid_viz_state();
|
||||||
CPT(RenderState) get_wireframe_viz_state();
|
CPT(RenderState) get_wireframe_viz_state();
|
||||||
CPT(RenderState) get_other_viz_state();
|
CPT(RenderState) get_other_viz_state();
|
||||||
|
CPT(RenderState) get_solid_bounds_viz_state();
|
||||||
|
CPT(RenderState) get_wireframe_bounds_viz_state();
|
||||||
|
CPT(RenderState) get_other_bounds_viz_state();
|
||||||
|
|
||||||
PT(GeomNode) _viz_geom;
|
PT(GeomNode) _viz_geom;
|
||||||
|
PT(GeomNode) _bounds_viz_geom;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LVector3f _effective_normal;
|
LVector3f _effective_normal;
|
||||||
|
@ -350,6 +350,7 @@ fill_viz_geom() {
|
|||||||
sphere->set_num_prims(num_slices);
|
sphere->set_num_prims(num_slices);
|
||||||
|
|
||||||
_viz_geom->add_geom(sphere, get_solid_viz_state());
|
_viz_geom->add_geom(sphere, get_solid_viz_state());
|
||||||
|
_bounds_viz_geom->add_geom(sphere, get_solid_bounds_viz_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -436,7 +436,7 @@ fill_viz_geom() {
|
|||||||
tube->set_lengths(lengths);
|
tube->set_lengths(lengths);
|
||||||
|
|
||||||
_viz_geom->add_geom(tube, get_solid_viz_state());
|
_viz_geom->add_geom(tube, get_solid_viz_state());
|
||||||
//_viz_geom->add_geom(tube, get_wireframe_viz_state());
|
_bounds_viz_geom->add_geom(tube, get_solid_bounds_viz_state());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -145,19 +145,14 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) {
|
|||||||
// tests that are being made.
|
// tests that are being made.
|
||||||
const CollisionSolid *solid = (*si).first;
|
const CollisionSolid *solid = (*si).first;
|
||||||
const SolidInfo &solid_info = (*si).second;
|
const SolidInfo &solid_info = (*si).second;
|
||||||
PT(PandaNode) node = solid->get_viz(xform_data);
|
bool was_detected = (solid_info._detected_count > 0);
|
||||||
|
PT(PandaNode) node = solid->get_viz(xform_data, !was_detected);
|
||||||
if (node != (PandaNode *)NULL) {
|
if (node != (PandaNode *)NULL) {
|
||||||
CullTraverserData next_data(xform_data, node);
|
CullTraverserData next_data(xform_data, node);
|
||||||
|
|
||||||
// We don't want to inherit the render state from above for
|
// We don't want to inherit the render state from above for
|
||||||
// these guys. Instead, we choose the state according to
|
// these guys.
|
||||||
// whether a collision was detected or not.
|
next_data._state = get_viz_state();
|
||||||
if (solid_info._detected_count > 0) {
|
|
||||||
next_data._state = get_detected_state();
|
|
||||||
} else {
|
|
||||||
next_data._state = get_tested_state();
|
|
||||||
}
|
|
||||||
|
|
||||||
trav->traverse(next_data);
|
trav->traverse(next_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,13 +282,13 @@ collision_tested(const CollisionEntry &entry, bool detected) {
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: CollisionVisualizer::get_detected_state
|
// Function: CollisionVisualizer::get_viz_state
|
||||||
// Access: Private
|
// Access: Private
|
||||||
// Description: Returns a RenderState suitable for rendering the
|
// Description: Returns a RenderState suitable for rendering the
|
||||||
// collision solids with which a collision was detected.
|
// collision solids with which a collision was detected.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
CPT(RenderState) CollisionVisualizer::
|
CPT(RenderState) CollisionVisualizer::
|
||||||
get_detected_state() {
|
get_viz_state() {
|
||||||
// Once someone asks for this pointer, we hold its reference count
|
// Once someone asks for this pointer, we hold its reference count
|
||||||
// and never free it.
|
// and never free it.
|
||||||
static CPT(RenderState) state = (const RenderState *)NULL;
|
static CPT(RenderState) state = (const RenderState *)NULL;
|
||||||
@ -305,27 +300,4 @@ get_detected_state() {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: CollisionVisualizer::get_tested_state
|
|
||||||
// Access: Private
|
|
||||||
// Description: Returns a RenderState suitable for rendering the
|
|
||||||
// collision solids with which a collision was tested,
|
|
||||||
// but no collision was detected..
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
CPT(RenderState) CollisionVisualizer::
|
|
||||||
get_tested_state() {
|
|
||||||
// Once someone asks for this pointer, we hold its reference count
|
|
||||||
// and never free it.
|
|
||||||
static CPT(RenderState) state = (const RenderState *)NULL;
|
|
||||||
if (state == (const RenderState *)NULL) {
|
|
||||||
state = RenderState::make
|
|
||||||
(ColorScaleAttrib::make(LVecBase4f(1.0f, 1.0f, 0.5f, 0.5f)),
|
|
||||||
DepthOffsetAttrib::make());
|
|
||||||
state = state->add_attrib
|
|
||||||
(TransparencyAttrib::make(TransparencyAttrib::M_alpha), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // DO_COLLISION_RECORDING
|
#endif // DO_COLLISION_RECORDING
|
||||||
|
@ -59,8 +59,7 @@ public:
|
|||||||
virtual void collision_tested(const CollisionEntry &entry, bool detected);
|
virtual void collision_tested(const CollisionEntry &entry, bool detected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPT(RenderState) get_detected_state();
|
CPT(RenderState) get_viz_state();
|
||||||
CPT(RenderState) get_tested_state();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class SolidInfo {
|
class SolidInfo {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user