Redesign of animation queue for unreal, add get_tangibles_near to drivenengine

This commit is contained in:
2023-07-24 17:19:25 -04:00
parent 4da86e6f89
commit 87aa47b96d
19 changed files with 1406 additions and 980 deletions

View File

@@ -2,6 +2,7 @@
#include "wrap-vector.hpp"
#include "util.hpp"
#include "drivenengine.hpp"
#include "world.hpp"
#include <string_view>
#include <utility>
@@ -138,6 +139,11 @@ void DrivenEngine::rescan_lua_source() {
rescan_lua_source_ = true;
}
void DrivenEngine::set_visible_world_and_actor(World *w, int64_t id) {
visible_world_ = w;
visible_actor_id_ = id;
}
void DrivenEngine::stop_driver() {
stop_driver_ = true;
for (int i = 0; i < DRV_MAX_CHAN; i++) {
@@ -190,8 +196,8 @@ inline static const char *action_string(DrvAction act) {
case PLAY_RECV_INCOMING: return "PLAY_RECV_INCOMING";
case PLAY_NOTIFY_CLOSE: return "PLAY_NOTIFY_CLOSE";
case PLAY_NOTIFY_ACCEPT: return "PLAY_NOTIFY_ACCEPT";
case PLAY_SET_LUA_SOURCE: return "PLAY_SET_LUA_SOURCE";
case PLAY_INVOKE_EVENT_UPDATE: return "PLAY_INVOKE_EVENT_UPDATE";
case PLAY_SET_LUA_SOURCE: return "PLAY_SET_LUA_SOURCE";
case PLAY_RELEASE: return "PLAY_RELEASE";
default: return "unknown";
}
@@ -403,6 +409,30 @@ bool DrivenEngine::drv_get_stop_driver() const {
return stop_driver_;
}
uint64_t DrivenEngine::drv_get_actor_id() const {
return visible_actor_id_;
}
void DrivenEngine::drv_get_tangibles_near(uint64_t tanid, double rx, double ry, double rz, uint32_t *count, int64_t **ids) {
scan_result_.clear();
if ((visible_world_ != 0) && (tanid != 0)) {
PlaneScan scan;
scan.set_near(tanid, true);
scan.set_omit_nowhere(true);
scan.set_sorted(false);
scan.set_radius(util::XYZ(rx, ry, rz));
scan.set_shape(PlaneScan::CYLINDER);
visible_world_->get_near(scan, &scan_result_);
}
*count = scan_result_.size();
if (*count > 0) {
*ids = &scan_result_[0];
} else {
*ids = nullptr;
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
@@ -465,6 +495,8 @@ void DrivenEngine::drv_set_lua_source(uint32_t srcpklen, const char *srcpk) {
rescan_lua_source_ = false;
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
@@ -522,6 +554,15 @@ static bool drv_get_stop_driver(EngineWrapper *w) {
return w->engine->drv_get_stop_driver();
}
static uint64_t drv_get_actor_id(EngineWrapper *w) {
return w->engine->drv_get_actor_id();
}
static void drv_get_tangibles_near(EngineWrapper *w, uint64_t tanid, double rx, double ry, double rz, uint32_t *count, int64_t **ids) {
return w->engine->drv_get_tangibles_near(tanid, rx, ry, rz, count, ids);
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
@@ -798,6 +839,7 @@ void replay_set_lua_source(EngineWrapper *w) {
w->engine->drv_set_lua_source(srcpack.size(), srcpack.c_str());
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
@@ -864,21 +906,13 @@ static void replaycore_step(EngineWrapper *w) {
case PLAY_RECV_INCOMING: replay_recv_incoming(w); return;
case PLAY_NOTIFY_CLOSE: replay_notify_close(w); return;
case PLAY_NOTIFY_ACCEPT: replay_notify_accept(w); return;
case PLAY_SET_LUA_SOURCE: replay_set_lua_source(w); return;
case PLAY_INVOKE_EVENT_UPDATE: replay_invoke_event_update(w); return;
case PLAY_SET_LUA_SOURCE: replay_set_lua_source(w); return;
case PLAY_RELEASE: release(w); return;
default: return reset_wrapper(w, "Replay log corrupt in command dispatcher");
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// General Mutators
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -923,6 +957,8 @@ static void init_engine_wrapper_helper(EngineWrapper *w) {
w->get_clock = drv_get_clock;
w->get_rescan_lua_source = drv_get_rescan_lua_source;
w->get_stop_driver = drv_get_stop_driver;
w->get_actor_id = drv_get_actor_id;
w->get_tangibles_near = drv_get_tangibles_near;
w->play_initialize = play_initialize;
w->play_clear_new_outgoing = play_clear_new_outgoing;