diff --git a/direct/src/interval/LerpInterval.py b/direct/src/interval/LerpInterval.py index 7816dfd142..c44b6e5435 100644 --- a/direct/src/interval/LerpInterval.py +++ b/direct/src/interval/LerpInterval.py @@ -637,28 +637,32 @@ class LerpPosQuatScaleShearInterval(LerpNodePathInterval): class LerpColorInterval(LerpNodePathInterval): def __init__(self, nodePath, duration, color, startColor = None, other = None, blendType = 'noBlend', - bakeInStart = 1, name = None): + bakeInStart = 1, name = None, override = None): LerpNodePathInterval.__init__(self, name, duration, blendType, bakeInStart, 0, nodePath, other) self.setEndColor(color) if startColor != None: self.setStartColor(startColor) + if override != None: + self.setOverride(override) class LerpColorScaleInterval(LerpNodePathInterval): def __init__(self, nodePath, duration, colorScale, startColorScale = None, other = None, blendType = 'noBlend', - bakeInStart = 1, name = None): + bakeInStart = 1, name = None, override = None): LerpNodePathInterval.__init__(self, name, duration, blendType, bakeInStart, 0, nodePath, other) self.setEndColorScale(colorScale) if startColorScale != None: self.setStartColorScale(startColorScale) + if override != None: + self.setOverride(override) class LerpTexOffsetInterval(LerpNodePathInterval): def __init__(self, nodePath, duration, texOffset, startTexOffset = None, other = None, blendType = 'noBlend', textureStage = None, - bakeInStart = 1, name = None): + bakeInStart = 1, name = None, override = None): LerpNodePathInterval.__init__(self, name, duration, blendType, bakeInStart, 0, nodePath, other) self.setEndTexOffset(texOffset) @@ -666,12 +670,14 @@ class LerpTexOffsetInterval(LerpNodePathInterval): self.setStartTexOffset(startTexOffset) if textureStage != None: self.setTextureStage(textureStage) + if override != None: + self.setOverride(override) class LerpTexRotateInterval(LerpNodePathInterval): def __init__(self, nodePath, duration, texRotate, startTexRotate = None, other = None, blendType = 'noBlend', textureStage = None, - bakeInStart = 1, name = None): + bakeInStart = 1, name = None, override = None): LerpNodePathInterval.__init__(self, name, duration, blendType, bakeInStart, 0, nodePath, other) self.setEndTexRotate(texRotate) @@ -679,12 +685,14 @@ class LerpTexRotateInterval(LerpNodePathInterval): self.setStartTexRotate(startTexRotate) if textureStage != None: self.setTextureStage(textureStage) + if override != None: + self.setOverride(override) class LerpTexScaleInterval(LerpNodePathInterval): def __init__(self, nodePath, duration, texScale, startTexScale = None, other = None, blendType = 'noBlend', textureStage = None, - bakeInStart = 1, name = None): + bakeInStart = 1, name = None, override = None): LerpNodePathInterval.__init__(self, name, duration, blendType, bakeInStart, 0, nodePath, other) self.setEndTexScale(texScale) @@ -692,15 +700,31 @@ class LerpTexScaleInterval(LerpNodePathInterval): self.setStartTexScale(startTexScale) if textureStage != None: self.setTextureStage(textureStage) + if override != None: + self.setOverride(override) +# +# The remaining intervals defined in this module are the old-school +# Python-based intervals. +# + + class LerpFunctionNoStateInterval(Interval.Interval): """ Class used to execute a function over time. Function can access fromData and toData to perform blend. If fromData and toData not specified, will execute the given function passing in values ranging from 0 to 1 + + This is different from a standard LerpFunction, in that it assumes + the function is not modifying any state that needs to be kept; so + that it will only call the function while the lerp is actually + running, and will not be guaranteed to call the function with its + final value of the lerp. In particular, if the lerp interval + happens to get skipped over completely, it will not bother to call + the function at all. """ # Interval counter @@ -773,11 +797,6 @@ class LerpFuncNS(LerpFunctionNoStateInterval): LerpFunctionNoStateInterval.__init__(self, *args, **kw) -# -# The remaining intervals defined in this module are the old-school -# Python-based intervals. -# - class LerpFunctionInterval(Interval.Interval): """ Class used to execute a function over time. Function can access fromData diff --git a/direct/src/interval/cLerpNodePathInterval.I b/direct/src/interval/cLerpNodePathInterval.I index b233afc254..30b327a68a 100644 --- a/direct/src/interval/cLerpNodePathInterval.I +++ b/direct/src/interval/cLerpNodePathInterval.I @@ -447,3 +447,30 @@ set_end_tex_scale(const LVecBase2f &tex_scale) { _end_tex_scale = tex_scale; _flags |= F_end_tex_scale; } + +//////////////////////////////////////////////////////////////////// +// Function: CLerpNodePathInterval::set_override +// Access: Published +// Description: Changes the override value that will be associated +// with any state changes applied by the lerp. If this +// lerp is changing state (for instance, a color lerp or +// a tex matrix lerp), then the new attributes created +// by this lerp will be assigned the indicated override +// value when they are applied to the node. +//////////////////////////////////////////////////////////////////// +INLINE void CLerpNodePathInterval:: +set_override(int override) { + _override = override; +} + +//////////////////////////////////////////////////////////////////// +// Function: CLerpNodePathInterval::get_override +// Access: Published +// Description: Returns the override value that will be associated +// with any state changes applied by the lerp. See +// set_override(). +//////////////////////////////////////////////////////////////////// +INLINE int CLerpNodePathInterval:: +get_override() const { + return _override; +} diff --git a/direct/src/interval/cLerpNodePathInterval.cxx b/direct/src/interval/cLerpNodePathInterval.cxx index 6bc78a9e78..3cd294f663 100644 --- a/direct/src/interval/cLerpNodePathInterval.cxx +++ b/direct/src/interval/cLerpNodePathInterval.cxx @@ -65,6 +65,7 @@ CLerpNodePathInterval(const string &name, double duration, _other(other), _flags(0), _texture_stage(TextureStage::get_default()), + _override(0), _slerp(NULL) { if (bake_in_start) { @@ -431,7 +432,7 @@ priv_step(double t) { lerp_value_from_prev(color, d, _prev_d, color, _end_color); } - state = state->add_attrib(ColorAttrib::make_flat(color)); + state = state->add_attrib(ColorAttrib::make_flat(color), _override); } if ((_flags & F_end_color_scale) != 0) { @@ -453,7 +454,7 @@ priv_step(double t) { lerp_value_from_prev(color_scale, d, _prev_d, color_scale, _end_color_scale); } - state = state->add_attrib(ColorScaleAttrib::make(color_scale)); + state = state->add_attrib(ColorScaleAttrib::make(color_scale), _override); } if ((_flags & (F_end_tex_offset | F_end_tex_rotate | F_end_tex_scale)) != 0) { @@ -512,9 +513,9 @@ priv_step(double t) { // Apply the modified transform back to the state. if (tma != (TexMatrixAttrib *)NULL) { - state = state->add_attrib(tma->add_stage(_texture_stage, transform)); + state = state->add_attrib(tma->add_stage(_texture_stage, transform), _override); } else { - state = state->add_attrib(TexMatrixAttrib::make(_texture_stage, transform)); + state = state->add_attrib(TexMatrixAttrib::make(_texture_stage, transform), _override); } } diff --git a/direct/src/interval/cLerpNodePathInterval.h b/direct/src/interval/cLerpNodePathInterval.h index 17b723f07a..416329836b 100644 --- a/direct/src/interval/cLerpNodePathInterval.h +++ b/direct/src/interval/cLerpNodePathInterval.h @@ -61,6 +61,9 @@ PUBLISHED: INLINE void set_start_tex_scale(const LVecBase2f &tex_scale); INLINE void set_end_tex_scale(const LVecBase2f &tex_scale); + INLINE void set_override(int override); + INLINE int get_override() const; + virtual void priv_initialize(double t); virtual void priv_instant(); virtual void priv_step(double t); @@ -117,6 +120,7 @@ private: float _start_tex_rotate, _end_tex_rotate; LVecBase2f _start_tex_scale, _end_tex_scale; + int _override; double _prev_d; float _slerp_angle; float _slerp_denom;