summaryrefslogtreecommitdiff
path: root/scene/animation
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/root_motion_view.cpp34
-rw-r--r--scene/animation/root_motion_view.h6
2 files changed, 22 insertions, 18 deletions
diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp
index b963cf5702..770996820d 100644
--- a/scene/animation/root_motion_view.cpp
+++ b/scene/animation/root_motion_view.cpp
@@ -77,7 +77,7 @@ bool RootMotionView::get_zero_y() const {
void RootMotionView::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- RS::get_singleton()->immediate_set_material(immediate, StandardMaterial3D::get_material_rid_for_2d(false, true, false, false, false));
+ immediate_material = StandardMaterial3D::get_material_for_2d(false, true, false, false, false);
first = true;
}
@@ -119,11 +119,12 @@ void RootMotionView::_notification(int p_what) {
}
accumulated.origin.z = Math::fposmod(accumulated.origin.z, cell_size);
- RS::get_singleton()->immediate_clear(immediate);
+ immediate->clear_surfaces();
int cells_in_radius = int((radius / cell_size) + 1.0);
- RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_LINES);
+ immediate->surface_begin(Mesh::PRIMITIVE_LINES, immediate_material);
+
for (int i = -cells_in_radius; i < cells_in_radius; i++) {
for (int j = -cells_in_radius; j < cells_in_radius; j++) {
Vector3 from(i * cell_size, 0, j * cell_size);
@@ -138,21 +139,21 @@ void RootMotionView::_notification(int p_what) {
c_i.a *= MAX(0, 1.0 - from_i.length() / radius);
c_j.a *= MAX(0, 1.0 - from_j.length() / radius);
- RS::get_singleton()->immediate_color(immediate, c);
- RS::get_singleton()->immediate_vertex(immediate, from);
+ immediate->surface_set_color(c);
+ immediate->surface_add_vertex(from);
- RS::get_singleton()->immediate_color(immediate, c_i);
- RS::get_singleton()->immediate_vertex(immediate, from_i);
+ immediate->surface_set_color(c_i);
+ immediate->surface_add_vertex(from_i);
- RS::get_singleton()->immediate_color(immediate, c);
- RS::get_singleton()->immediate_vertex(immediate, from);
+ immediate->surface_set_color(c);
+ immediate->surface_add_vertex(from);
- RS::get_singleton()->immediate_color(immediate, c_j);
- RS::get_singleton()->immediate_vertex(immediate, from_j);
+ immediate->surface_set_color(c_j);
+ immediate->surface_add_vertex(from_j);
}
}
- RS::get_singleton()->immediate_end(immediate);
+ immediate->surface_end();
}
}
@@ -188,12 +189,13 @@ void RootMotionView::_bind_methods() {
}
RootMotionView::RootMotionView() {
- set_process_internal(true);
- immediate = RenderingServer::get_singleton()->immediate_create();
- set_base(immediate);
+ if (Engine::get_singleton()->is_editor_hint()) {
+ set_process_internal(true);
+ }
+ immediate.instantiate();
+ set_base(immediate->get_rid());
}
RootMotionView::~RootMotionView() {
set_base(RID());
- RenderingServer::get_singleton()->free(immediate);
}
diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h
index 4cd3c7b443..55fd2d2b73 100644
--- a/scene/animation/root_motion_view.h
+++ b/scene/animation/root_motion_view.h
@@ -32,12 +32,12 @@
#define ROOT_MOTION_VIEW_H
#include "scene/3d/visual_instance_3d.h"
-
+#include "scene/resources/immediate_mesh.h"
class RootMotionView : public VisualInstance3D {
GDCLASS(RootMotionView, VisualInstance3D);
public:
- RID immediate;
+ Ref<ImmediateMesh> immediate;
NodePath path;
float cell_size = 1.0;
float radius = 10.0;
@@ -46,6 +46,8 @@ public:
bool first = true;
bool zero_y = true;
+ Ref<Material> immediate_material;
+
Transform3D accumulated;
private: