mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
use allow-flatten-color to get beyond the silly color attrib rigamarole. I want to just flatten!
This commit is contained in:
parent
5d00f81885
commit
c415cf8dbf
@ -32,6 +32,11 @@
|
||||
#include "boundingBox.h"
|
||||
#include "config_mathutil.h"
|
||||
|
||||
|
||||
bool allow_flatten_color = ConfigVariableBool
|
||||
("allow-flatten-color", false,
|
||||
PRC_DESC("allows color to always be flattened to vertices"));
|
||||
|
||||
TypeHandle GeomNode::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -140,23 +145,36 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types,
|
||||
}
|
||||
|
||||
ra = entry->_state->get_attrib_def(ColorAttrib::get_class_slot());
|
||||
const ColorAttrib *ca = DCAST(ColorAttrib, ra);
|
||||
CPT (ColorAttrib) ca = DCAST(ColorAttrib, ra);
|
||||
if (ca->get_color_type() != ColorAttrib::T_vertex) {
|
||||
if(allow_flatten_color) {
|
||||
if(transformer.set_color(new_geom, ca->get_color())) {
|
||||
any_changed = true;
|
||||
entry->_state = entry->_state->set_attrib(ColorAttrib::make_vertex());
|
||||
}
|
||||
} else {
|
||||
if (transformer.remove_column(new_geom, InternalName::get_color())) {
|
||||
any_changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) {
|
||||
if (geom_attribs._color_scale != (const RenderAttrib *)NULL) {
|
||||
const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, geom_attribs._color_scale);
|
||||
CPT(ColorScaleAttrib) csa = DCAST(ColorScaleAttrib, geom_attribs._color_scale);
|
||||
if (csa->get_scale() != LVecBase4f(1.0f, 1.0f, 1.0f, 1.0f)) {
|
||||
|
||||
|
||||
// Now, if we have an "off" or "flat" color attribute, we
|
||||
// simply modify the color attribute, and leave the
|
||||
// vertices alone.
|
||||
const RenderAttrib *ra = entry->_state->get_attrib_def(ColorAttrib::get_class_slot());
|
||||
const ColorAttrib *ca = DCAST(ColorAttrib, ra);
|
||||
CPT(RenderAttrib) ra = entry->_state->get_attrib_def(ColorAttrib::get_class_slot());
|
||||
CPT(ColorAttrib) ca = DCAST(ColorAttrib, ra);
|
||||
if(allow_flatten_color) {
|
||||
if (transformer.transform_colors(new_geom, csa->get_scale())) {
|
||||
any_changed = true;
|
||||
}
|
||||
} else {
|
||||
if (ca->get_color_type() == ColorAttrib::T_off) {
|
||||
entry->_state = entry->_state->set_attrib(ColorAttrib::make_vertex());
|
||||
// ColorAttrib::T_off means the color scale becomes
|
||||
@ -178,6 +196,8 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types,
|
||||
if (transformer.transform_colors(new_geom, csa->get_scale())) {
|
||||
any_changed = true;
|
||||
}
|
||||
entry->_state = entry->_state->set_attrib(ColorAttrib::make_vertex());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user