mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
rationalize done event
This commit is contained in:
parent
fdded6a238
commit
707fd440c9
@ -422,6 +422,8 @@ priv_instant() {
|
|||||||
|
|
||||||
if (_event_queue.empty()) {
|
if (_event_queue.empty()) {
|
||||||
interval_done();
|
interval_done();
|
||||||
|
} else {
|
||||||
|
enqueue_done_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,6 +519,8 @@ priv_finalize() {
|
|||||||
|
|
||||||
if (_event_queue.empty()) {
|
if (_event_queue.empty()) {
|
||||||
interval_done();
|
interval_done();
|
||||||
|
} else {
|
||||||
|
enqueue_done_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,15 +694,6 @@ pop_event() {
|
|||||||
nassertv(def._type == DT_ext_index);
|
nassertv(def._type == DT_ext_index);
|
||||||
#endif
|
#endif
|
||||||
_event_queue.pop_front();
|
_event_queue.pop_front();
|
||||||
|
|
||||||
// Really, we should set a flag to call this at the next call to
|
|
||||||
// service_event_queue(), instead of calling it immediately, because
|
|
||||||
// the just-popped event probably hasn't been processed yet. But we
|
|
||||||
// can get away with calling this here for now because Python
|
|
||||||
// doesn't process C++ events immediately.
|
|
||||||
if (_state == S_final) {
|
|
||||||
interval_done();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -1042,6 +1037,18 @@ enqueue_self_event(CInterval::EventType event_type, double t) {
|
|||||||
_event_queue.push_back(EventQueueEntry(-1, event_type, time));
|
_event_queue.push_back(EventQueueEntry(-1, event_type, time));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: CMetaInterval::enqueue_done_event
|
||||||
|
// Access: Private
|
||||||
|
// Description: Enqueues a special "event" that simply marks the end
|
||||||
|
// of processing of the interval; the interval's done
|
||||||
|
// event should be thrown now, if it is defined.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void CMetaInterval::
|
||||||
|
enqueue_done_event() {
|
||||||
|
_event_queue.push_back(EventQueueEntry(-2, ET_finalize, 0));
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: CMetaInterval::service_event_queue
|
// Function: CMetaInterval::service_event_queue
|
||||||
// Access: Private
|
// Access: Private
|
||||||
@ -1055,13 +1062,6 @@ enqueue_self_event(CInterval::EventType event_type, double t) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool CMetaInterval::
|
bool CMetaInterval::
|
||||||
service_event_queue() {
|
service_event_queue() {
|
||||||
if (_event_queue.empty()) {
|
|
||||||
// Return early if we're empty on entry, so we don't throw the
|
|
||||||
// done event more than once.
|
|
||||||
nassertr(!_processing_events, false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!_event_queue.empty()) {
|
while (!_event_queue.empty()) {
|
||||||
nassertr(!_processing_events, true);
|
nassertr(!_processing_events, true);
|
||||||
const EventQueueEntry &entry = _event_queue.front();
|
const EventQueueEntry &entry = _event_queue.front();
|
||||||
@ -1069,6 +1069,11 @@ service_event_queue() {
|
|||||||
// Index -1 is a special code for *this* interval.
|
// Index -1 is a special code for *this* interval.
|
||||||
priv_do_event(int_to_double_time(entry._time), entry._event_type);
|
priv_do_event(int_to_double_time(entry._time), entry._event_type);
|
||||||
|
|
||||||
|
} else if (entry._n == -2) {
|
||||||
|
// Index -2 is a special code to indicate the interval is now
|
||||||
|
// done, and its done event should be thrown.
|
||||||
|
interval_done();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nassertr(entry._n >= 0 && entry._n < (int)_defs.size(), false);
|
nassertr(entry._n >= 0 && entry._n < (int)_defs.size(), false);
|
||||||
const IntervalDef &def = _defs[entry._n];
|
const IntervalDef &def = _defs[entry._n];
|
||||||
@ -1090,13 +1095,8 @@ service_event_queue() {
|
|||||||
_event_queue.pop_front();
|
_event_queue.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_state == S_final) {
|
|
||||||
interval_done();
|
|
||||||
}
|
|
||||||
|
|
||||||
// No more events on the queue.
|
// No more events on the queue.
|
||||||
nassertr(!_processing_events, false);
|
nassertr(!_processing_events, false);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +151,7 @@ private:
|
|||||||
void enqueue_event(int n, CInterval::EventType event_type, bool is_initial,
|
void enqueue_event(int n, CInterval::EventType event_type, bool is_initial,
|
||||||
int time = 0);
|
int time = 0);
|
||||||
void enqueue_self_event(CInterval::EventType event_type, double t = 0.0);
|
void enqueue_self_event(CInterval::EventType event_type, double t = 0.0);
|
||||||
|
void enqueue_done_event();
|
||||||
bool service_event_queue();
|
bool service_event_queue();
|
||||||
|
|
||||||
int recompute_level(int n, int level_begin, int &level_end);
|
int recompute_level(int n, int level_begin, int &level_end);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user