add set_auto_recompute()

This commit is contained in:
David Rose 2011-12-30 19:24:47 +00:00
parent a56760cbcf
commit b405b6bfac
3 changed files with 58 additions and 6 deletions

View File

@ -172,9 +172,39 @@ get_frame_color() const {
return _frame_color;
}
////////////////////////////////////////////////////////////////////
// Function: ProjectionScreen::set_auto_recompute
// Access: Published
// Description: Sets the auto_recompute flag. When this is true,
// the ProjectionScreen will always be recomputed if
// necessary before the frame is drawn; when it is
// false, an explicit call to recompute_if_stale() may
// be required.
////////////////////////////////////////////////////////////////////
INLINE void ProjectionScreen::
set_auto_recompute(bool auto_recompute) {
_auto_recompute = auto_recompute;
}
////////////////////////////////////////////////////////////////////
// Function: ProjectionScreen::set_auto_recompute
// Access: Published
// Description: Returns the auto_recompute flag. When this is true,
// the ProjectionScreen will always be recomputed if
// necessary before the frame is drawn; when it is
// false, an explicit call to recompute_if_stale() may
// be required.
////////////////////////////////////////////////////////////////////
INLINE bool ProjectionScreen::
get_auto_recompute() const {
return _auto_recompute;
}
////////////////////////////////////////////////////////////////////
// Function: ProjectionScreen::get_last_screen
// Access: Public
// Access: Published
// Description: Returns an UpdateSeq corresponding to the last time a
// screen mesh was generated for the ProjectionScreen.
// Each time generate_screen() is called, this number is
@ -186,3 +216,4 @@ INLINE const UpdateSeq &ProjectionScreen::
get_last_screen() const {
return _last_screen;
}

View File

@ -45,6 +45,7 @@ ProjectionScreen(const string &name) : PandaNode(name)
_frame_color.set(1.0f, 1.0f, 1.0f, 1.0f);
_computed_rel_top_mat = false;
_stale = true;
_auto_recompute = true;
}
////////////////////////////////////////////////////////////////////
@ -69,7 +70,8 @@ ProjectionScreen(const ProjectionScreen &copy) :
_texcoord_name(copy._texcoord_name),
_vignette_on(copy._vignette_on),
_vignette_color(copy._vignette_color),
_frame_color(copy._frame_color)
_frame_color(copy._frame_color),
_auto_recompute(copy._auto_recompute)
{
_computed_rel_top_mat = false;
_stale = true;
@ -115,7 +117,9 @@ make_copy() const {
////////////////////////////////////////////////////////////////////
bool ProjectionScreen::
cull_callback(CullTraverser *, CullTraverserData &data) {
recompute_if_stale(data._node_path.get_node_path());
if (_auto_recompute) {
recompute_if_stale(data._node_path.get_node_path());
}
return true;
}
@ -337,7 +341,21 @@ recompute() {
////////////////////////////////////////////////////////////////////
// Function: ProjectionScreen::recompute_if_stale
// Access: Public
// Access: Published
// Description: Calls recompute() only if the relative transform
// between the ProjectionScreen and the projector has
// changed, or if any other relevant property has
// changed.
////////////////////////////////////////////////////////////////////
void ProjectionScreen::
recompute_if_stale() {
NodePath this_np(NodePath::any_path(this));
recompute_if_stale(this_np);
}
////////////////////////////////////////////////////////////////////
// Function: ProjectionScreen::recompute_if_stale
// Access: Published
// Description: Calls recompute() only if the relative transform
// between the ProjectionScreen and the projector has
// changed, or if any other relevant property has

View File

@ -90,10 +90,12 @@ PUBLISHED:
INLINE void set_frame_color(const LColor &frame_color);
INLINE const LColor &get_frame_color() const;
void recompute();
INLINE void set_auto_recompute(bool auto_recompute);
INLINE bool get_auto_recompute() const;
public:
void recompute();
INLINE const UpdateSeq &get_last_screen() const;
void recompute_if_stale();
void recompute_if_stale(const NodePath &this_np);
private:
@ -130,6 +132,7 @@ private:
bool _stale;
UpdateSeq _projector_lens_change;
UpdateSeq _last_screen;
bool _auto_recompute;
public:
static TypeHandle get_class_type() {