Make physics interpolation compatible with separate-thread rendering

This commit is contained in:
Pedro J. Estébanez
2025-12-15 21:36:52 +01:00
parent 42b054a401
commit 49700eb84b
6 changed files with 43 additions and 2 deletions

View File

@@ -43,6 +43,10 @@ void VisualServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) {
void VisualServerWrapMT::thread_flush() {
}
void VisualServerWrapMT::thread_halt() {
thread_halt_semaphore.wait();
}
void VisualServerWrapMT::_thread_callback(void *_instance) {
VisualServerWrapMT *vsmt = reinterpret_cast<VisualServerWrapMT *>(_instance);
@@ -102,6 +106,19 @@ void VisualServerWrapMT::sync() {
}
}
void VisualServerWrapMT::sync_and_halt() {
if (create_thread) {
command_queue.push_and_sync(this, &VisualServerWrapMT::thread_flush);
command_queue.push(this, &VisualServerWrapMT::thread_halt);
}
}
void VisualServerWrapMT::thaw() {
if (create_thread) {
thread_halt_semaphore.post();
}
}
void VisualServerWrapMT::draw(bool p_swap_buffers, double frame_step) {
if (create_thread) {
command_queue.push(this, &VisualServerWrapMT::thread_draw, p_swap_buffers, frame_step);