summaryrefslogtreecommitdiff
path: root/scene/resources/curve.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/curve.h')
-rw-r--r--scene/resources/curve.h75
1 files changed, 74 insertions, 1 deletions
diff --git a/scene/resources/curve.h b/scene/resources/curve.h
index 046359b9b6..e361604ce3 100644
--- a/scene/resources/curve.h
+++ b/scene/resources/curve.h
@@ -30,7 +30,7 @@
#define CURVE_H
#include "resource.h"
-
+#if 0
class Curve2D : public Resource {
OBJ_TYPE(Curve2D,Resource);
@@ -79,6 +79,79 @@ public:
Curve2D();
};
+#endif
+
+
+class Curve2D : public Resource {
+
+ OBJ_TYPE(Curve2D,Resource);
+
+ struct Point {
+
+ Vector2 in;
+ Vector2 out;
+ Vector2 pos;
+ };
+
+
+ Vector<Point> points;
+
+ struct BakedPoint {
+
+ float ofs;
+ Vector2 point;
+ };
+
+ mutable bool baked_cache_dirty;
+ mutable Vector2Array baked_point_cache;
+ mutable float baked_max_ofs;
+
+
+ void _bake() const;
+
+ float bake_interval;
+
+ void _bake_segment2d(Map<float,Vector2>& r_bake, float p_begin, float p_end,const Vector2& p_a,const Vector2& p_out,const Vector2& p_b, const Vector2& p_in,int p_depth,int p_max_depth,float p_tol) const;
+ Dictionary _get_data() const;
+ void _set_data(const Dictionary &p_data);
+
+protected:
+
+ static void _bind_methods();
+
+
+
+public:
+
+
+ int get_point_count() const;
+ void add_point(const Vector2& p_pos, const Vector2& p_in=Vector2(), const Vector2& p_out=Vector2(),int p_atpos=-1);
+ void set_point_pos(int p_index, const Vector2& p_pos);
+ Vector2 get_point_pos(int p_index) const;
+ void set_point_in(int p_index, const Vector2& p_in);
+ Vector2 get_point_in(int p_index) const;
+ void set_point_out(int p_index, const Vector2& p_out);
+ Vector2 get_point_out(int p_index) const;
+ void remove_point(int p_index);
+
+ Vector2 interpolate(int p_index, float p_offset) const;
+ Vector2 interpolatef(real_t p_findex) const;
+
+
+ void set_bake_interval(float p_distance);
+ float get_bake_interval() const;
+
+
+ float get_baked_length() const;
+ Vector2 interpolate_baked(float p_offset,bool p_cubic=false) const;
+ Vector2Array get_baked_points() const; //useful for going thru
+
+ Vector2Array tesselate(int p_max_stages=5,float p_tolerance=4) const; //useful for display
+
+
+ Curve2D();
+};
+
class Curve3D : public Resource {