Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Physics interpolation - Move out of Scenario #60147

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions scene/3d/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ void Camera::_notification(int p_what) {
if (current || first_camera) {
viewport->_camera_set(this);
}

ERR_FAIL_COND(get_world().is_null());
VisualServer::get_singleton()->camera_set_scenario(camera, get_world()->get_scenario());

} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
_request_camera_update();
Expand All @@ -132,8 +128,6 @@ void Camera::_notification(int p_what) {
}
} break;
case NOTIFICATION_EXIT_WORLD: {
VisualServer::get_singleton()->camera_set_scenario(camera, RID());

if (!get_tree()->is_node_being_edited(this)) {
if (is_current()) {
clear_current();
Expand Down
22 changes: 5 additions & 17 deletions scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,7 @@ void SceneTree::set_physics_interpolation_enabled(bool p_enabled) {
}

_physics_interpolation_enabled = p_enabled;

if (root->get_world().is_valid()) {
RID scenario = root->get_world()->get_scenario();
if (scenario.is_valid()) {
VisualServer::get_singleton()->scenario_set_physics_interpolation_enabled(scenario, p_enabled);
}
}
VisualServer::get_singleton()->set_physics_interpolation_enabled(p_enabled);
}

bool SceneTree::is_physics_interpolation_enabled() const {
Expand All @@ -535,11 +529,8 @@ bool SceneTree::iteration(float p_time) {

current_frame++;

if (root->get_world().is_valid()) {
RID scenario = root->get_world()->get_scenario();
if (scenario.is_valid()) {
VisualServer::get_singleton()->scenario_tick(scenario);
}
if (_physics_interpolation_enabled) {
VisualServer::get_singleton()->tick();
}

// Any objects performing client physics interpolation
Expand Down Expand Up @@ -686,11 +677,8 @@ bool SceneTree::idle(float p_time) {

#endif

if (root->get_world().is_valid()) {
RID scenario = root->get_world()->get_scenario();
if (scenario.is_valid()) {
VisualServer::get_singleton()->scenario_pre_draw(scenario, true);
}
if (_physics_interpolation_enabled) {
VisualServer::get_singleton()->pre_draw(true);
}

return _quit;
Expand Down
8 changes: 0 additions & 8 deletions servers/visual/visual_server_raster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ void VisualServerRaster::request_frame_drawn_callback(Object *p_where, const Str
frame_drawn_callbacks.push_back(fdc);
}

void VisualServerRaster::scenario_tick(RID p_scenario) {
VSG::scene->_scenario_tick(p_scenario);
}

void VisualServerRaster::scenario_pre_draw(RID p_scenario, bool p_will_draw) {
VSG::scene->_scenario_pre_draw(p_scenario, p_will_draw);
}

void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) {
//needs to be done before changes is reset to 0, to not force the editor to redraw
VS::get_singleton()->emit_signal("frame_pre_draw");
Expand Down
34 changes: 24 additions & 10 deletions servers/visual/visual_server_raster.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ class VisualServerRaster : public VisualServer {
#define BIND4RC(m_r, m_name, m_type1, m_type2, m_type3, m_type4) \
m_r m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4) const { return BINDBASE->m_name(arg1, arg2, arg3, arg4); }

#define BIND0N(m_name) \
void m_name() { BINDBASE->m_name(); }
#define BIND1(m_name, m_type1) \
void m_name(m_type1 arg1) { DISPLAY_CHANGED BINDBASE->m_name(arg1); }
#define BIND1N(m_name, m_type1) \
void m_name(m_type1 arg1) { BINDBASE->m_name(arg1); }
#define BIND2(m_name, m_type1, m_type2) \
void m_name(m_type1 arg1, m_type2 arg2) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2); }
#define BIND2C(m_name, m_type1, m_type2) \
Expand Down Expand Up @@ -448,10 +452,14 @@ class VisualServerRaster : public VisualServer {
//from now on, calls forwarded to this singleton
#define BINDBASE VSG::scene

/* EVENT QUEUING */

BIND0N(tick)
BIND1N(pre_draw, bool)

/* CAMERA API */

BIND0R(RID, camera_create)
BIND2(camera_set_scenario, RID, RID)
BIND4(camera_set_perspective, RID, float, float, float)
BIND4(camera_set_orthogonal, RID, float, float, float)
BIND5(camera_set_frustum, RID, float, Vector2, float, float)
Expand Down Expand Up @@ -548,20 +556,24 @@ class VisualServerRaster : public VisualServer {
BIND7(environment_set_fog_depth, RID, bool, float, float, float, bool, float)
BIND5(environment_set_fog_height, RID, bool, float, float, float)

/* SCENARIO API */

#undef BINDBASE
#define BINDBASE VSG::scene

/* INTERPOLATION */

BIND1(set_physics_interpolation_enabled, bool)

/* SCENARIO API */

BIND0R(RID, scenario_create)

BIND2(scenario_set_debug, RID, ScenarioDebugMode)
BIND2(scenario_set_environment, RID, RID)
BIND3(scenario_set_reflection_atlas_size, RID, int, int)
BIND2(scenario_set_fallback_environment, RID, RID)
BIND2(scenario_set_physics_interpolation_enabled, RID, bool)

/* INSTANCING API */

BIND0R(RID, instance_create)

BIND2(instance_set_base, RID, RID)
Expand All @@ -583,7 +595,8 @@ class VisualServerRaster : public VisualServer {

BIND2(instance_set_extra_visibility_margin, RID, real_t)

// Portals
/* PORTALS */

BIND2(instance_set_portal_mode, RID, InstancePortalMode)

BIND0R(RID, ghost_create)
Expand All @@ -596,13 +609,15 @@ class VisualServerRaster : public VisualServer {
BIND4(portal_link, RID, RID, RID, bool)
BIND2(portal_set_active, RID, bool)

// Roomgroups
/* ROOMGROUPS */

BIND0R(RID, roomgroup_create)
BIND2(roomgroup_prepare, RID, ObjectID)
BIND2(roomgroup_set_scenario, RID, RID)
BIND2(roomgroup_add_room, RID, RID)

// Occluders
/* OCCLUDERS */

BIND0R(RID, occluder_instance_create)
BIND2(occluder_instance_set_scenario, RID, RID)
BIND2(occluder_instance_link_resource, RID, RID)
Expand All @@ -616,7 +631,8 @@ class VisualServerRaster : public VisualServer {
BIND1(set_use_occlusion_culling, bool)
BIND1RC(Geometry::MeshData, occlusion_debug_get_current_polys, RID)

// Rooms
/* ROOMS */

BIND0R(RID, room_create)
BIND2(room_set_scenario, RID, RID)
BIND4(room_add_instance, RID, RID, const AABB &, const Vector<Vector3> &)
Expand Down Expand Up @@ -764,8 +780,6 @@ class VisualServerRaster : public VisualServer {
virtual bool has_changed(ChangedPriority p_priority = CHANGED_PRIORITY_ANY) const;
virtual void init();
virtual void finish();
virtual void scenario_tick(RID p_scenario);
virtual void scenario_pre_draw(RID p_scenario, bool p_will_draw);

/* STATUS INFORMATION */

Expand Down
Loading