better assertion checking
This commit is contained in:
parent
7852efabfb
commit
11d3460047
|
|
@ -233,11 +233,11 @@ recompute() const {
|
|||
// one of the stopped states.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CInterval::
|
||||
check_stopped(const char *method_name) const {
|
||||
check_stopped(TypeHandle type, const char *method_name) const {
|
||||
if (_state == S_started) {
|
||||
interval_cat.warning()
|
||||
<< get_name() << "." << method_name << "() called in state "
|
||||
<< _state << ".\n";
|
||||
<< type.get_name() << "::" << method_name << "() called for "
|
||||
<< get_name() << " in state " << _state << ".\n";
|
||||
nassertv(!verify_intervals);
|
||||
}
|
||||
}
|
||||
|
|
@ -249,11 +249,11 @@ check_stopped(const char *method_name) const {
|
|||
// one of the started states.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void CInterval::
|
||||
check_started(const char *method_name) const {
|
||||
check_started(TypeHandle type, const char *method_name) const {
|
||||
if (_state != S_started && _state != S_paused) {
|
||||
interval_cat.warning()
|
||||
<< get_name() << "." << method_name << "() called in state "
|
||||
<< _state << ".\n";
|
||||
<< type.get_name() << "::" << method_name << "() called for "
|
||||
<< get_name() << " in state " << _state << ".\n";
|
||||
nassertv(!verify_intervals);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ CInterval(const string &name, double duration, bool open_ended) :
|
|||
_play_rate = 1.0;
|
||||
_do_loop = false;
|
||||
_loop_count = 0;
|
||||
nassertv(_duration >= 0.0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -250,7 +251,7 @@ priv_do_event(double t, EventType event) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
priv_initialize(double t) {
|
||||
check_stopped("priv_initialize");
|
||||
check_stopped(get_class_type(), "priv_initialize");
|
||||
recompute();
|
||||
_state = S_started;
|
||||
priv_step(t);
|
||||
|
|
@ -266,7 +267,7 @@ priv_initialize(double t) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
priv_instant() {
|
||||
check_stopped("priv_instant");
|
||||
check_stopped(get_class_type(), "priv_instant");
|
||||
recompute();
|
||||
_state = S_started;
|
||||
priv_step(get_duration());
|
||||
|
|
@ -283,7 +284,7 @@ priv_instant() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
priv_step(double t) {
|
||||
check_started("priv_step");
|
||||
check_started(get_class_type(), "priv_step");
|
||||
_state = S_started;
|
||||
_curr_t = t;
|
||||
}
|
||||
|
|
@ -298,7 +299,7 @@ priv_step(double t) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
priv_finalize() {
|
||||
check_started("priv_step");
|
||||
check_started(get_class_type(), "priv_finalize");
|
||||
double duration = get_duration();
|
||||
priv_step(duration);
|
||||
_state = S_final;
|
||||
|
|
@ -315,7 +316,7 @@ priv_finalize() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
priv_reverse_initialize(double t) {
|
||||
check_stopped("priv_reverse_initialize");
|
||||
check_stopped(get_class_type(), "priv_reverse_initialize");
|
||||
recompute();
|
||||
_state = S_started;
|
||||
priv_step(t);
|
||||
|
|
@ -332,7 +333,7 @@ priv_reverse_initialize(double t) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
priv_reverse_instant() {
|
||||
check_stopped("priv_reverse_instant");
|
||||
check_stopped(get_class_type(), "priv_reverse_instant");
|
||||
recompute();
|
||||
_state = S_started;
|
||||
priv_step(0.0);
|
||||
|
|
@ -348,7 +349,7 @@ priv_reverse_instant() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
priv_reverse_finalize() {
|
||||
check_started("priv_reverse_finalize");
|
||||
check_started(get_class_type(), "priv_reverse_finalize");
|
||||
priv_step(0.0);
|
||||
_state = S_initial;
|
||||
}
|
||||
|
|
@ -369,7 +370,7 @@ priv_reverse_finalize() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CInterval::
|
||||
priv_interrupt() {
|
||||
check_started("priv_interrupt");
|
||||
check_started(get_class_type(), "priv_interrupt");
|
||||
_state = S_paused;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ protected:
|
|||
|
||||
INLINE void recompute() const;
|
||||
virtual void do_recompute();
|
||||
INLINE void check_stopped(const char *method_name) const;
|
||||
INLINE void check_started(const char *method_name) const;
|
||||
INLINE void check_stopped(TypeHandle type, const char *method_name) const;
|
||||
INLINE void check_started(TypeHandle type, const char *method_name) const;
|
||||
|
||||
State _state;
|
||||
double _curr_t;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ TypeHandle CLerpAnimEffectInterval::_type_handle;
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CLerpAnimEffectInterval::
|
||||
priv_step(double t) {
|
||||
check_started("step");
|
||||
check_started(get_class_type(), "priv_step");
|
||||
_state = S_started;
|
||||
double d = compute_delta(t);
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ CLerpNodePathInterval(const string &name, double duration,
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CLerpNodePathInterval::
|
||||
priv_initialize(double t) {
|
||||
check_stopped("initialize");
|
||||
check_stopped(get_class_type(), "priv_initialize");
|
||||
recompute();
|
||||
_prev_d = 0.0;
|
||||
_state = S_started;
|
||||
|
|
@ -98,7 +98,7 @@ priv_initialize(double t) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CLerpNodePathInterval::
|
||||
priv_instant() {
|
||||
check_stopped("instant");
|
||||
check_stopped(get_class_type(), "priv_instant");
|
||||
recompute();
|
||||
_prev_d = 0.0;
|
||||
_state = S_started;
|
||||
|
|
@ -115,7 +115,7 @@ priv_instant() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CLerpNodePathInterval::
|
||||
priv_step(double t) {
|
||||
check_started("step");
|
||||
check_started(get_class_type(), "priv_step");
|
||||
_state = S_started;
|
||||
double d = compute_delta(t);
|
||||
|
||||
|
|
@ -316,7 +316,7 @@ priv_step(double t) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CLerpNodePathInterval::
|
||||
priv_reverse_initialize(double t) {
|
||||
check_stopped("reverse_initialize");
|
||||
check_stopped(get_class_type(), "priv_reverse_initialize");
|
||||
recompute();
|
||||
_state = S_started;
|
||||
_prev_d = 1.0;
|
||||
|
|
@ -334,7 +334,7 @@ priv_reverse_initialize(double t) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void CLerpNodePathInterval::
|
||||
priv_reverse_instant() {
|
||||
check_stopped("reverse_initialize");
|
||||
check_stopped(get_class_type(), "priv_reverse_initialize");
|
||||
recompute();
|
||||
_state = S_started;
|
||||
_prev_d = 1.0;
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ priv_initialize(double t) {
|
|||
return;
|
||||
}
|
||||
|
||||
check_stopped("priv_initialize");
|
||||
check_stopped(get_class_type(), "priv_initialize");
|
||||
// It may be tempting to flush the event_queue here, but don't do
|
||||
// it. Those are events that must still be serviced from some
|
||||
// previous interval operation. Throwing them away would be a
|
||||
|
|
@ -419,7 +419,7 @@ priv_instant() {
|
|||
return;
|
||||
}
|
||||
|
||||
check_stopped("priv_instant");
|
||||
check_stopped(get_class_type(), "priv_instant");
|
||||
recompute();
|
||||
_active.clear();
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ priv_step(double t) {
|
|||
return;
|
||||
}
|
||||
|
||||
check_started("priv_step");
|
||||
check_started(get_class_type(), "priv_step");
|
||||
int now = double_to_int_time(t);
|
||||
|
||||
/*
|
||||
|
|
@ -568,7 +568,7 @@ priv_reverse_initialize(double t) {
|
|||
return;
|
||||
}
|
||||
|
||||
check_stopped("priv_reverse_initialize");
|
||||
check_stopped(get_class_type(), "priv_reverse_initialize");
|
||||
// It may be tempting to flush the event_queue here, but don't do
|
||||
// it. Those are events that must still be serviced from some
|
||||
// previous interval operation. Throwing them away would be a
|
||||
|
|
@ -624,7 +624,7 @@ priv_reverse_instant() {
|
|||
return;
|
||||
}
|
||||
|
||||
check_stopped("priv_reverse_instant");
|
||||
check_stopped(get_class_type(), "priv_reverse_instant");
|
||||
recompute();
|
||||
_active.clear();
|
||||
|
||||
|
|
@ -1176,7 +1176,8 @@ recompute_level(int n, int level_begin, int &level_end) {
|
|||
|
||||
while (n < (int)_defs.size() && _defs[n]._type != DT_pop_level) {
|
||||
IntervalDef &def = _defs[n];
|
||||
int begin_time, end_time;
|
||||
int begin_time = previous_begin;
|
||||
int end_time = previous_end;
|
||||
switch (def._type) {
|
||||
case DT_c_interval:
|
||||
begin_time = get_begin_time(def, level_begin, previous_begin, previous_end);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ HideInterval(const NodePath &node, const string &name) :
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void HideInterval::
|
||||
priv_instant() {
|
||||
check_stopped(get_class_type(), "priv_instant");
|
||||
_node.hide();
|
||||
_state = S_final;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -64,5 +66,7 @@ priv_instant() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void HideInterval::
|
||||
priv_reverse_instant() {
|
||||
check_stopped(get_class_type(), "priv_reverse_instant");
|
||||
_node.show();
|
||||
_state = S_initial;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ ShowInterval(const NodePath &node, const string &name) :
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void ShowInterval::
|
||||
priv_instant() {
|
||||
check_stopped("instant");
|
||||
check_stopped(get_class_type(), "priv_instant");
|
||||
_node.show();
|
||||
_state = S_final;
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ priv_instant() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void ShowInterval::
|
||||
priv_reverse_instant() {
|
||||
check_stopped("instant");
|
||||
check_stopped(get_class_type(), "priv_reverse_instant");
|
||||
_node.hide();
|
||||
_state = S_initial;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,15 @@ TypeHandle WaitInterval::_type_handle;
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void WaitInterval::
|
||||
priv_step(double t) {
|
||||
// The WaitInterval is normally not run directly; it just fills up
|
||||
// time when constructing a MetaInterval (specifically, a Sequence).
|
||||
#ifndef NDEBUG
|
||||
if (verify_intervals) {
|
||||
interval_cat.info()
|
||||
<< "running WaitInterval. Intentional?\n";
|
||||
}
|
||||
#endif
|
||||
check_started("priv_step");
|
||||
check_started(get_class_type(), "priv_step");
|
||||
_state = S_started;
|
||||
_curr_t = t;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue