summaryrefslogtreecommitdiff
path: root/scene/animation/root_motion_view.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation/root_motion_view.cpp')
-rw-r--r--scene/animation/root_motion_view.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp
index 1625b80db4..098bd05e9a 100644
--- a/scene/animation/root_motion_view.cpp
+++ b/scene/animation/root_motion_view.cpp
@@ -1,3 +1,33 @@
+/*************************************************************************/
+/* root_motion_view.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
#include "root_motion_view.h"
#include "scene/animation/animation_tree.h"
#include "scene/resources/material.h"
@@ -37,6 +67,14 @@ float RootMotionView::get_radius() const {
return radius;
}
+void RootMotionView::set_zero_y(bool p_zero_y) {
+ zero_y = p_zero_y;
+}
+
+bool RootMotionView::get_zero_y() const {
+ return zero_y;
+}
+
void RootMotionView::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
@@ -77,9 +115,11 @@ void RootMotionView::_notification(int p_what) {
transform.orthonormalize(); //dont want scale, too imprecise
transform.affine_invert();
- accumulated = accumulated * transform;
+ accumulated = transform * accumulated;
accumulated.origin.x = Math::fposmod(accumulated.origin.x, cell_size);
- accumulated.origin.y = Math::fposmod(accumulated.origin.y, cell_size);
+ if (zero_y) {
+ accumulated.origin.y = 0;
+ }
accumulated.origin.z = Math::fposmod(accumulated.origin.z, cell_size);
VS::get_singleton()->immediate_clear(immediate);
@@ -142,13 +182,18 @@ void RootMotionView::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_radius", "size"), &RootMotionView::set_radius);
ClassDB::bind_method(D_METHOD("get_radius"), &RootMotionView::get_radius);
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "animation_path"), "set_animation_path", "get_animation_path");
+ ClassDB::bind_method(D_METHOD("set_zero_y", "enable"), &RootMotionView::set_zero_y);
+ ClassDB::bind_method(D_METHOD("get_zero_y"), &RootMotionView::get_zero_y);
+
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "animation_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "AnimationTree"), "set_animation_path", "get_animation_path");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_size", PROPERTY_HINT_RANGE, "0.1,16,0.01,or_greater"), "set_cell_size", "get_cell_size");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.1,16,0.01,or_greater"), "set_radius", "get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "zero_y"), "set_zero_y", "get_zero_y");
}
RootMotionView::RootMotionView() {
+ zero_y = true;
radius = 10;
cell_size = 1;
set_process_internal(true);