diff options
| author | Juan Linietsky | 2016-08-02 19:11:47 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2016-08-02 19:11:47 -0300 |
| commit | 3d1d190dcd2993f87d5804de8a60e8bf5fc2cf49 (patch) | |
| tree | aa2c814b744ab970ae79931b419908ff7ebc850e /core/math | |
| parent | ad313097ebcb2a0c02c956fdf74a6610c3f7c9a8 (diff) | |
| parent | cea949180688add09eb9e69f5e405f361dc96d40 (diff) | |
| download | godot-3d1d190dcd2993f87d5804de8a60e8bf5fc2cf49.tar.gz godot-3d1d190dcd2993f87d5804de8a60e8bf5fc2cf49.tar.zst godot-3d1d190dcd2993f87d5804de8a60e8bf5fc2cf49.zip | |
Merge branch 'master' of https://github.com/godotengine/godot
Diffstat (limited to 'core/math')
| -rw-r--r-- | core/math/geometry.cpp | 14 | ||||
| -rw-r--r-- | core/math/math_2d.h | 8 | ||||
| -rw-r--r-- | core/math/math_funcs.cpp | 34 | ||||
| -rw-r--r-- | core/math/math_funcs.h | 2 | ||||
| -rw-r--r-- | core/math/quat.cpp | 2 |
5 files changed, 32 insertions, 28 deletions
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 5b767212f..790903eff 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -629,7 +629,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro // create and initialize cells to zero - print_line("Wrapper: Initializing Cells"); + //print_line("Wrapper: Initializing Cells"); uint8_t ***cell_status=memnew_arr(uint8_t**,div_x); for(int i=0;i<div_x;i++) { @@ -648,7 +648,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro } // plot faces into cells - print_line("Wrapper (1/6): Plotting Faces"); + //print_line("Wrapper (1/6): Plotting Faces"); for (int i=0;i<face_count;i++) { @@ -663,7 +663,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro // determine which cells connect to the outside by traversing the outside and recursively flood-fill marking - print_line("Wrapper (2/6) Flood Filling"); + //print_line("Wrapper (2/6): Flood Filling"); for (int i=0;i<div_x;i++) { @@ -694,7 +694,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro // build faces for the inside-outside cell divisors - print_line("Wrapper (3/6): Building Faces"); + //print_line("Wrapper (3/6): Building Faces"); DVector<Face3> wrapped_faces; @@ -709,7 +709,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro } } - print_line("Wrapper (4/6): Transforming Back Vertices"); + //print_line("Wrapper (4/6): Transforming Back Vertices"); // transform face vertices to global coords @@ -728,7 +728,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro } // clean up grid - print_line("Wrapper (5/6): Grid Cleanup"); + //print_line("Wrapper (5/6): Grid Cleanup"); for(int i=0;i<div_x;i++) { @@ -744,7 +744,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro if (p_error) *p_error=voxelsize.length(); - print_line("Wrapper (6/6): Finished."); + //print_line("Wrapper (6/6): Finished."); return wrapped_faces; } diff --git a/core/math/math_2d.h b/core/math/math_2d.h index ad4655b8f..fbf700fb9 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -157,7 +157,7 @@ struct Vector2 { float get_aspect() const { return width/height; } - operator String() const { return String::num(x)+","+String::num(y); } + operator String() const { return String::num(x)+", "+String::num(y); } _FORCE_INLINE_ Vector2(float p_x,float p_y) { x=p_x; y=p_y; } _FORCE_INLINE_ Vector2() { x=0; y=0; } @@ -356,7 +356,7 @@ struct Rect2 { } - operator String() const { return String(pos)+","+String(size); } + operator String() const { return String(pos)+", "+String(size); } Rect2() {} Rect2( float p_x, float p_y, float p_width, float p_height) { pos=Point2(p_x,p_y); size=Size2( p_width, p_height ); } @@ -409,7 +409,7 @@ struct Point2i { float get_aspect() const { return width/(float)height; } - operator String() const { return String::num(x)+","+String::num(y); } + operator String() const { return String::num(x)+", "+String::num(y); } operator Vector2() const { return Vector2(x,y); } inline Point2i(const Vector2& p_vec2) { x=(int)p_vec2.x; y=(int)p_vec2.y; } @@ -540,7 +540,7 @@ struct Rect2i { } - operator String() const { return String(pos)+","+String(size); } + operator String() const { return String(pos)+", "+String(size); } operator Rect2() const { return Rect2(pos,size); } Rect2i(const Rect2& p_r2) { pos=p_r2.pos; size=p_r2.size; } diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 0fbd03121..64615fe6b 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -206,25 +206,29 @@ double Math::ceil(double p_x) { return ::ceil(p_x); } -int Math::decimals(double p_step) { +int Math::step_decimals(double p_step) { - int max=4; - double llimit = Math::pow(0.1,max); - double ulimit = 1.0-llimit; - int i=0; - while( max) { - - float d = absf(p_step) - Math::floor(absf(p_step)); + static const int maxn=9; + static const double sd[maxn]={ + 0.9999, // somehow compensate for floating point error + 0.09999, + 0.009999, + 0.0009999, + 0.00009999, + 0.000009999, + 0.0000009999, + 0.00000009999, + 0.000000009999 + }; - if (d<llimit || d>ulimit) - break; - p_step*=10.0; - max--; - i++; + double as=absf(p_step); + for(int i=0;i<maxn;i++) { + if (as>=sd[i]) { + return i; + } } - return i; - + return maxn; } double Math::ease(double p_x, double p_c) { diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 2e1b9c989..fc76d96b2 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -66,7 +66,7 @@ public: static double floor(double p_x); static double ceil(double p_x); static double ease(double p_x, double p_c); - static int decimals(double p_step); + static int step_decimals(double p_step); static double stepify(double p_value,double p_step); static void seed(uint32_t x=0); static void randomize(); diff --git a/core/math/quat.cpp b/core/math/quat.cpp index c6c12129b..73124e5e8 100644 --- a/core/math/quat.cpp +++ b/core/math/quat.cpp @@ -252,7 +252,7 @@ Quat Quat::cubic_slerp(const Quat& q, const Quat& prep, const Quat& postq,const Quat::operator String() const { - return String::num(x)+","+String::num(y)+","+ String::num(z)+","+ String::num(w); + return String::num(x)+", "+String::num(y)+", "+ String::num(z)+", "+ String::num(w); } Quat::Quat(const Vector3& axis, const real_t& angle) { |
