diff --git a/direct/src/extensions/NodePath-extensions.py b/direct/src/extensions/NodePath-extensions.py index 62e5a9907e..3fac653785 100644 --- a/direct/src/extensions/NodePath-extensions.py +++ b/direct/src/extensions/NodePath-extensions.py @@ -905,12 +905,6 @@ base.startDirect() direct.deselect(self) - def setAlphaScale(self, alpha): - self.setColorScale(1, 1, 1, alpha) - - def setAllColorScale(self, color): - self.setColorScale(color, color, color, 1) - def showCS(self, mask = None): """showCS(self, mask) Shows the collision solids at or below this node. If mask is diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index c06e41914f..5eed0aa790 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -110,6 +110,12 @@ is_in_view_impl() { DCAST(GeometricBoundingVolume, &node_volume); int result = _view_frustum->contains(node_gbv); + + if (pgraph_cat.is_spam()) { + pgraph_cat.spam() + << _node_path << " cull result = " << hex << result << dec << "\n"; + } + if (result == BoundingVolume::IF_no_intersection) { // No intersection at all. Cull. if (!fake_view_frustum_cull) { diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index c04d0df77b..b42c953402 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -595,108 +595,6 @@ get_mat() const { return node()->get_transform()->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_color_scale -// Access: Published -// Description: Sets the color scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -set_color_scale(float sr, float sg, float sb, float sa) { - set_color_scale(LVecBase4f(sr, sg, sb, sa)); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_sr -// Access: Published -// Description: Sets the red scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -set_sr(float sr) { - LVecBase4f new_scale = get_color_scale(); - new_scale[0] = sr; - - set_color_scale(new_scale); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_sg -// Access: Published -// Description: Sets the alpha scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -set_sg(float sg) { - LVecBase4f new_scale = get_color_scale(); - new_scale[1] = sg; - - set_color_scale(new_scale); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_sb -// Access: Published -// Description: Sets the blue scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -set_sb(float sb) { - LVecBase4f new_scale = get_color_scale(); - new_scale[2] = sb; - - set_color_scale(new_scale); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_sa -// Access: Published -// Description: Sets the alpha scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -set_sa(float sa) { - LVecBase4f new_scale = get_color_scale(); - new_scale[3] = sa; - - set_color_scale(new_scale); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sr -// Access: Published -// Description: Gets the red scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE float NodePath:: -get_sr() const { - return get_color_scale()[0]; -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sg -// Access: Published -// Description: Gets the green scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE float NodePath:: -get_sg() const { - return get_color_scale()[1]; -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sb -// Access: Published -// Description: Gets the blue scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE float NodePath:: -get_sb() const { - return get_color_scale()[2]; -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sa -// Access: Published -// Description: Gets the alpha scale component of the transform -//////////////////////////////////////////////////////////////////// -INLINE float NodePath:: -get_sa() const { - return get_color_scale()[3]; -} - //////////////////////////////////////////////////////////////////// // Function: NodePath::look_at @@ -887,6 +785,108 @@ get_distance(const NodePath &other) const { return length(LVector3f(pos)); } +//////////////////////////////////////////////////////////////////// +// Function: NodePath::set_color_scale +// Access: Published +// Description: Sets the color scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE void NodePath:: +set_color_scale(float sr, float sg, float sb, float sa, int priority) { + set_color_scale(LVecBase4f(sr, sg, sb, sa), priority); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::set_sr +// Access: Published +// Description: Sets the red scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE void NodePath:: +set_sr(float sr) { + LVecBase4f new_scale = get_color_scale(); + new_scale[0] = sr; + + set_color_scale(new_scale); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::set_sg +// Access: Published +// Description: Sets the alpha scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE void NodePath:: +set_sg(float sg) { + LVecBase4f new_scale = get_color_scale(); + new_scale[1] = sg; + + set_color_scale(new_scale); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::set_sb +// Access: Published +// Description: Sets the blue scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE void NodePath:: +set_sb(float sb) { + LVecBase4f new_scale = get_color_scale(); + new_scale[2] = sb; + + set_color_scale(new_scale); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::set_sa +// Access: Published +// Description: Sets the alpha scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE void NodePath:: +set_sa(float sa) { + LVecBase4f new_scale = get_color_scale(); + new_scale[3] = sa; + + set_color_scale(new_scale); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::get_sr +// Access: Published +// Description: Gets the red scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE float NodePath:: +get_sr() const { + return get_color_scale()[0]; +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::get_sg +// Access: Published +// Description: Gets the green scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE float NodePath:: +get_sg() const { + return get_color_scale()[1]; +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::get_sb +// Access: Published +// Description: Gets the blue scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE float NodePath:: +get_sb() const { + return get_color_scale()[2]; +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::get_sa +// Access: Published +// Description: Gets the alpha scale component of the transform +//////////////////////////////////////////////////////////////////// +INLINE float NodePath:: +get_sa() const { + return get_color_scale()[3]; +} + //////////////////////////////////////////////////////////////////// // Function: NodePath::set_billboard_axis // Access: Published diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 53c106c279..b9450e5897 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -851,68 +851,6 @@ set_mat(const LMatrix4f &mat) { set_transform(TransformState::make_mat(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_color_scale -// Access: Published -// Description: Returns true if a color scale has been applied -// to the referenced node, false otherwise. It is still -// possible that color at this node might have been -// scaled by an ancestor node. -//////////////////////////////////////////////////////////////////// -bool NodePath:: -has_color_scale() const { - nassertr_always(!is_empty(), false); - return node()->has_attrib(ColorScaleAttrib::get_class_type()); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_color_scale -// Access: Published -// Description: Completely removes any color scale from the -// referenced node. This is preferable to simply -// setting the color scale to identity, as it also -// removes the overhead associated with having a color -// scale at all. -//////////////////////////////////////////////////////////////////// -void NodePath:: -clear_color_scale() { - nassertv_always(!is_empty()); - node()->clear_attrib(ColorScaleAttrib::get_class_type()); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_color_scale -// Access: Published -// Description: Sets the color scale component of the transform, -// leaving translation and rotation untouched. -//////////////////////////////////////////////////////////////////// -void NodePath:: -set_color_scale(const LVecBase4f &scale) { - nassertv_always(!is_empty()); - node()->set_attrib(ColorScaleAttrib::make(scale)); -} - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_color_scale -// Access: Published -// Description: Returns the complete color scale vector that has been -// applied to the bottom node, or all 1's (identity) if -// no scale has been applied. -//////////////////////////////////////////////////////////////////// -const LVecBase4f &NodePath:: -get_color_scale() const { - static const LVecBase4f ident_scale(1.0f, 1.0f, 1.0f, 1.0f); - nassertr_always(!is_empty(), ident_scale); - const RenderAttrib *attrib = - node()->get_attrib(ColorScaleAttrib::get_class_type()); - if (attrib != (const RenderAttrib *)NULL) { - const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); - return csa->get_scale(); - } - - return ident_scale; -} - //////////////////////////////////////////////////////////////////// // Function: NodePath::look_at // Access: Published @@ -1500,6 +1438,112 @@ get_color() const { return Colorf(1.0f, 1.0f, 1.0f, 1.0f); } +//////////////////////////////////////////////////////////////////// +// Function: NodePath::has_color_scale +// Access: Published +// Description: Returns true if a color scale has been applied +// to the referenced node, false otherwise. It is still +// possible that color at this node might have been +// scaled by an ancestor node. +//////////////////////////////////////////////////////////////////// +bool NodePath:: +has_color_scale() const { + nassertr_always(!is_empty(), false); + return node()->has_attrib(ColorScaleAttrib::get_class_type()); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::clear_color_scale +// Access: Published +// Description: Completely removes any color scale from the +// referenced node. This is preferable to simply +// setting the color scale to identity, as it also +// removes the overhead associated with having a color +// scale at all. +//////////////////////////////////////////////////////////////////// +void NodePath:: +clear_color_scale() { + nassertv_always(!is_empty()); + node()->clear_attrib(ColorScaleAttrib::get_class_type()); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::set_color_scale +// Access: Published +// Description: Sets the color scale component of the transform, +// leaving translation and rotation untouched. +//////////////////////////////////////////////////////////////////// +void NodePath:: +set_color_scale(const LVecBase4f &scale, int priority) { + nassertv_always(!is_empty()); + node()->set_attrib(ColorScaleAttrib::make(scale), priority); +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::set_alpha_scale +// Access: Published +// Description: Sets the alpha scale component of the transform +// without affecting the color scale. Note that any +// priority specified will also apply to the color +// scale. +//////////////////////////////////////////////////////////////////// +void NodePath:: +set_alpha_scale(float scale, int priority) { + nassertv_always(!is_empty()); + const RenderAttrib *attrib = + node()->get_attrib(ColorScaleAttrib::get_class_type()); + if (attrib != (const RenderAttrib *)NULL) { + const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); + const LVecBase4f &sc = csa->get_scale(); + set_color_scale(sc[0], sc[1], sc[2], scale, priority); + } else { + set_color_scale(1.0f, 1.0f, 1.0f, scale, priority); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::set_all_color_scale +// Access: Published +// Description: Scales all the color components of the object by the +// same amount, darkening the object, without affecting +// alpha. Note that any priority specified will also +// apply to the alpha scale. +//////////////////////////////////////////////////////////////////// +void NodePath:: +set_all_color_scale(float scale, int priority) { + nassertv_always(!is_empty()); + const RenderAttrib *attrib = + node()->get_attrib(ColorScaleAttrib::get_class_type()); + if (attrib != (const RenderAttrib *)NULL) { + const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); + const LVecBase4f &sc = csa->get_scale(); + set_color_scale(scale, scale, scale, sc[3], priority); + } else { + set_color_scale(scale, scale, scale, 1.0f, priority); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: NodePath::get_color_scale +// Access: Published +// Description: Returns the complete color scale vector that has been +// applied to the bottom node, or all 1's (identity) if +// no scale has been applied. +//////////////////////////////////////////////////////////////////// +const LVecBase4f &NodePath:: +get_color_scale() const { + static const LVecBase4f ident_scale(1.0f, 1.0f, 1.0f, 1.0f); + nassertr_always(!is_empty(), ident_scale); + const RenderAttrib *attrib = + node()->get_attrib(ColorScaleAttrib::get_class_type()); + if (attrib != (const RenderAttrib *)NULL) { + const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); + return csa->get_scale(); + } + + return ident_scale; +} + //////////////////////////////////////////////////////////////////// // Function: NodePath::set_bin // Access: Published diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 50c4044852..d9cbdf8da3 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -293,21 +293,6 @@ PUBLISHED: INLINE bool has_mat() const; INLINE const LMatrix4f &get_mat() const; - bool has_color_scale() const; - void clear_color_scale(); - void set_color_scale(const LVecBase4f &scale); - INLINE void set_color_scale(float sx, float sy, float sz, float sa); - INLINE void set_sr(float sr); - INLINE void set_sg(float sg); - INLINE void set_sb(float sb); - INLINE void set_sa(float sa); - - const LVecBase4f &get_color_scale() const; - INLINE float get_sr() const; - INLINE float get_sg() const; - INLINE float get_sb() const; - INLINE float get_sa() const; - INLINE void look_at(float x, float y, float z); void look_at(const LPoint3f &point, const LVector3f &up = LVector3f::up()); INLINE void heads_up(float x, float y, float z); @@ -406,6 +391,25 @@ PUBLISHED: bool has_color() const; Colorf get_color() const; + bool has_color_scale() const; + void clear_color_scale(); + void set_color_scale(const LVecBase4f &scale, + int priority = 0); + INLINE void set_color_scale(float sx, float sy, float sz, float sa, + int priority = 0); + void set_alpha_scale(float scale, int priority = 0); + void set_all_color_scale(float scale, int priority = 0); + INLINE void set_sr(float sr); + INLINE void set_sg(float sg); + INLINE void set_sb(float sb); + INLINE void set_sa(float sa); + + const LVecBase4f &get_color_scale() const; + INLINE float get_sr() const; + INLINE float get_sg() const; + INLINE float get_sb() const; + INLINE float get_sa() const; + void set_bin(const string &bin_name, int draw_order, int priority = 0); void clear_bin(); bool has_bin() const;