|
@@ -16,9 +16,6 @@
|
|
|
//
|
|
//
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
-/* okcircular */
|
|
|
|
|
-#include "numericDataAttribute.h"
|
|
|
|
|
-
|
|
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
TypeHandle NumericDataTransition<NumType>::_type_handle;
|
|
TypeHandle NumericDataTransition<NumType>::_type_handle;
|
|
|
|
|
|
|
@@ -29,22 +26,8 @@ TypeHandle NumericDataTransition<NumType>::_type_handle;
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
INLINE NumericDataTransition<NumType>::
|
|
INLINE NumericDataTransition<NumType>::
|
|
|
-NumericDataTransition() :
|
|
|
|
|
- _scale(1),
|
|
|
|
|
- _offset(0)
|
|
|
|
|
-{
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: NumericDataTransition::Constructor
|
|
|
|
|
-// Access: Public
|
|
|
|
|
-// Description:
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-template<class NumType>
|
|
|
|
|
-INLINE NumericDataTransition<NumType>::
|
|
|
|
|
-NumericDataTransition(NumType scale, NumType offset) :
|
|
|
|
|
- _scale(scale),
|
|
|
|
|
- _offset(offset)
|
|
|
|
|
|
|
+NumericDataTransition(NumType value) :
|
|
|
|
|
+ _value(value)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -56,9 +39,8 @@ NumericDataTransition(NumType scale, NumType offset) :
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
INLINE NumericDataTransition<NumType>::
|
|
INLINE NumericDataTransition<NumType>::
|
|
|
NumericDataTransition(const NumericDataTransition<NumType> ©) :
|
|
NumericDataTransition(const NumericDataTransition<NumType> ©) :
|
|
|
- NodeTransition(copy),
|
|
|
|
|
- _scale(copy._scale),
|
|
|
|
|
- _offset(copy._offset)
|
|
|
|
|
|
|
+ OnTransition(copy),
|
|
|
|
|
+ _value(copy._value)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -70,195 +52,85 @@ NumericDataTransition(const NumericDataTransition<NumType> ©) :
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
INLINE void NumericDataTransition<NumType>::
|
|
INLINE void NumericDataTransition<NumType>::
|
|
|
operator = (const NumericDataTransition<NumType> ©) {
|
|
operator = (const NumericDataTransition<NumType> ©) {
|
|
|
- NodeTransition::operator = (copy);
|
|
|
|
|
- _scale = copy._scale;
|
|
|
|
|
- _offset = copy._offset;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: NumericDataTransition::is_identity
|
|
|
|
|
-// Access: Public, Virtual
|
|
|
|
|
-// Description: Returns true if this transition does not affect any
|
|
|
|
|
-// numbers going through it.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-template<class NumType>
|
|
|
|
|
-INLINE bool NumericDataTransition<NumType>::
|
|
|
|
|
-is_identity() const {
|
|
|
|
|
- return (_scale == 1.0 && _offset == 0.0);
|
|
|
|
|
|
|
+ OnTransition::operator = (copy);
|
|
|
|
|
+ _value = copy._value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: NumericDataTransition::set_scale
|
|
|
|
|
|
|
+// Function: NumericDataTransition::set_value
|
|
|
// Access: Public, Virtual
|
|
// Access: Public, Virtual
|
|
|
// Description:
|
|
// Description:
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
-void NumericDataTransition<NumType>::
|
|
|
|
|
-set_scale(NumType scale) {
|
|
|
|
|
- _scale = scale;
|
|
|
|
|
|
|
+INLINE void NumericDataTransition<NumType>::
|
|
|
|
|
+set_value(NumType value) {
|
|
|
|
|
+ _value = value;
|
|
|
state_changed();
|
|
state_changed();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: NumericDataTransition::get_scale
|
|
|
|
|
|
|
+// Function: NumericDataTransition::get_value
|
|
|
// Access: Public, Virtual
|
|
// Access: Public, Virtual
|
|
|
// Description:
|
|
// Description:
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
-NumType NumericDataTransition<NumType>::
|
|
|
|
|
-get_scale() const {
|
|
|
|
|
- return _scale;
|
|
|
|
|
|
|
+INLINE NumType NumericDataTransition<NumType>::
|
|
|
|
|
+get_value() const {
|
|
|
|
|
+ return _value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: NumericDataTransition::set_offset
|
|
|
|
|
|
|
+// Function: NumericDataTransition::set_value_from
|
|
|
// Access: Public, Virtual
|
|
// Access: Public, Virtual
|
|
|
-// Description:
|
|
|
|
|
|
|
+// Description: Copies the value from the other transition pointer,
|
|
|
|
|
+// which is guaranteed to be another NumericDataTransition.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
void NumericDataTransition<NumType>::
|
|
void NumericDataTransition<NumType>::
|
|
|
-set_offset(NumType offset) {
|
|
|
|
|
- _offset = offset;
|
|
|
|
|
- state_changed();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: NumericDataTransition::get_offset
|
|
|
|
|
-// Access: Public, Virtual
|
|
|
|
|
-// Description:
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-template<class NumType>
|
|
|
|
|
-NumType NumericDataTransition<NumType>::
|
|
|
|
|
-get_offset() const {
|
|
|
|
|
- return _offset;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: NumericDataTransition::compose
|
|
|
|
|
-// Access: Public, Virtual
|
|
|
|
|
-// Description: Returns a new transition that corresponds to the
|
|
|
|
|
-// composition of this transition with the second
|
|
|
|
|
-// transition (which must be of an equivalent type).
|
|
|
|
|
-// This may return the same pointer as either source
|
|
|
|
|
-// transition. Applying the transition returned from
|
|
|
|
|
-// this function to an attribute attribute will produce
|
|
|
|
|
-// the same effect as applying each transition
|
|
|
|
|
-// separately.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-template<class NumType>
|
|
|
|
|
-NodeTransition *NumericDataTransition<NumType>::
|
|
|
|
|
-compose(const NodeTransition *other) const {
|
|
|
|
|
|
|
+set_value_from(const OnTransition *other) {
|
|
|
const NumericDataTransition<NumType> *ot;
|
|
const NumericDataTransition<NumType> *ot;
|
|
|
- DCAST_INTO_R(ot, other, NULL);
|
|
|
|
|
-
|
|
|
|
|
- if (is_identity()) {
|
|
|
|
|
- return (NumericDataTransition<NumType> *)ot;
|
|
|
|
|
-
|
|
|
|
|
- } else if (ot->is_identity()) {
|
|
|
|
|
- return (NumericDataTransition<NumType> *)this;
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- NodeTransition *c = make_copy();
|
|
|
|
|
- NumericDataTransition<NumType> *result;
|
|
|
|
|
- DCAST_INTO_R(result, c, NULL);
|
|
|
|
|
-
|
|
|
|
|
- result->_offset = _offset + _scale * ot->_offset;
|
|
|
|
|
- result->_scale = _scale * ot->_scale;
|
|
|
|
|
- return result;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ DCAST_INTO_V(ot, other);
|
|
|
|
|
+ _value = ot->_value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: NumericDataTransition::invert
|
|
|
|
|
-// Access: Public, Virtual
|
|
|
|
|
|
|
+// Function: NumericDataTransition::compare_values
|
|
|
|
|
+// Access: Protected, Virtual
|
|
|
// Description:
|
|
// Description:
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
-NodeTransition *NumericDataTransition<NumType>::
|
|
|
|
|
-invert() const {
|
|
|
|
|
- if (is_identity()) {
|
|
|
|
|
- return (NumericDataTransition<NumType> *)this;
|
|
|
|
|
-
|
|
|
|
|
- } else if (_scale == 0) {
|
|
|
|
|
- // Singular; cannot invert.
|
|
|
|
|
- return NULL;
|
|
|
|
|
-
|
|
|
|
|
|
|
+int NumericDataTransition<NumType>::
|
|
|
|
|
+compare_values(const OnTransition *other) const {
|
|
|
|
|
+ const NumericDataTransition<NumType> *ot;
|
|
|
|
|
+ DCAST_INTO_R(ot, other, false);
|
|
|
|
|
+ if (_value < ot->_value) {
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ } else if (ot->_value < _value) {
|
|
|
|
|
+ return 1;
|
|
|
} else {
|
|
} else {
|
|
|
- NodeTransition *c = make_copy();
|
|
|
|
|
- NumericDataTransition<NumType> *result;
|
|
|
|
|
- DCAST_INTO_R(result, c, NULL);
|
|
|
|
|
-
|
|
|
|
|
- result->_offset = - _offset / _scale;
|
|
|
|
|
- result->_scale = (NumType)1 / _scale;
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ return 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: NumericDataTransition::apply
|
|
|
|
|
-// Access: Public, Virtual
|
|
|
|
|
-// Description: Returns a new attribute (or possibly the same
|
|
|
|
|
-// attribute) that represents the effect of applying this
|
|
|
|
|
-// indicated transition to the indicated attribute. The
|
|
|
|
|
-// source attribute may be NULL, indicating the initial
|
|
|
|
|
-// attribute.
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-template<class NumType>
|
|
|
|
|
-NodeAttribute *NumericDataTransition<NumType>::
|
|
|
|
|
-apply(const NodeAttribute *attrib) const {
|
|
|
|
|
- const NumericDataAttribute<NumType> *at;
|
|
|
|
|
- DCAST_INTO_R(at, attrib, NULL);
|
|
|
|
|
-
|
|
|
|
|
- if (is_identity()) {
|
|
|
|
|
- return (NumericDataAttribute<NumType> *)attrib;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- NodeAttribute *c = make_attrib();
|
|
|
|
|
- NumericDataAttribute<NumType> *result;
|
|
|
|
|
- DCAST_INTO_R(result, c, NULL);
|
|
|
|
|
-
|
|
|
|
|
- result->_value = at->_value * _scale + _offset;
|
|
|
|
|
- return result;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: NumericDataTransition::output
|
|
|
|
|
-// Access: Public, Virtual
|
|
|
|
|
-// Description:
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-template<class NumType>
|
|
|
|
|
-void NumericDataTransition<NumType>::
|
|
|
|
|
-output(ostream &out) const {
|
|
|
|
|
- out << _scale << "x + " << _offset;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-////////////////////////////////////////////////////////////////////
|
|
|
|
|
-// Function: NumericDataTransition::write
|
|
|
|
|
-// Access: Public, Virtual
|
|
|
|
|
-// Description:
|
|
|
|
|
|
|
+// Function: NumericDataTransition::output_value
|
|
|
|
|
+// Access: Protected, Virtual
|
|
|
|
|
+// Description: Formats the value for human consumption on one line.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
void NumericDataTransition<NumType>::
|
|
void NumericDataTransition<NumType>::
|
|
|
-write(ostream &out, int indent_level) const {
|
|
|
|
|
- indent(out, indent_level) << _scale << "x + " << _offset << "\n";
|
|
|
|
|
|
|
+output_value(ostream &out) const {
|
|
|
|
|
+ out << _value;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: NumericDataTransition::internal_compare_to
|
|
|
|
|
|
|
+// Function: NumericDataTransition::write_value
|
|
|
// Access: Protected, Virtual
|
|
// Access: Protected, Virtual
|
|
|
-// Description:
|
|
|
|
|
|
|
+// Description: Formats the value for human consumption on multiple
|
|
|
|
|
+// lines if necessary.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class NumType>
|
|
template<class NumType>
|
|
|
-int NumericDataTransition<NumType>::
|
|
|
|
|
-internal_compare_to(const NodeTransition *other) const {
|
|
|
|
|
- const NumericDataTransition<NumType> *ot;
|
|
|
|
|
- DCAST_INTO_R(ot, other, false);
|
|
|
|
|
-
|
|
|
|
|
- if (_scale != ot->_scale) {
|
|
|
|
|
- return (_scale < ot->_scale) ? -1 : 1;
|
|
|
|
|
- }
|
|
|
|
|
- if (_offset != ot->_offset) {
|
|
|
|
|
- return (_offset < ot->_offset) ? -1 : 1;
|
|
|
|
|
- }
|
|
|
|
|
- return 0;
|
|
|
|
|
|
|
+void NumericDataTransition<NumType>::
|
|
|
|
|
+write_value(ostream &out, int indent_level) const {
|
|
|
|
|
+ indent(out, indent_level) << _value << "\n";
|
|
|
}
|
|
}
|