summaryrefslogtreecommitdiff
path: root/scene/3d/spatial_velocity_tracker.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/spatial_velocity_tracker.h')
-rw-r--r--scene/3d/spatial_velocity_tracker.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/scene/3d/spatial_velocity_tracker.h b/scene/3d/spatial_velocity_tracker.h
new file mode 100644
index 0000000000..65f3eaca93
--- /dev/null
+++ b/scene/3d/spatial_velocity_tracker.h
@@ -0,0 +1,31 @@
+#ifndef SPATIAL_VELOCITY_TRACKER_H
+#define SPATIAL_VELOCITY_TRACKER_H
+
+#include "scene/3d/spatial.h"
+
+class SpatialVelocityTracker : public Reference {
+ GDCLASS(SpatialVelocityTracker, Reference)
+
+ struct PositionHistory {
+ uint64_t frame;
+ Vector3 position;
+ };
+
+ bool fixed_step;
+ Vector<PositionHistory> position_history;
+ int position_history_len;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void reset(const Vector3 &p_new_pos);
+ void set_track_fixed_step(bool p_use_fixed_step);
+ bool is_tracking_fixed_step() const;
+ void update_position(const Vector3 &p_position);
+ Vector3 get_tracked_linear_velocity() const;
+
+ SpatialVelocityTracker();
+};
+
+#endif // SPATIAL_VELOCITY_TRACKER_H