Skip to content

Commit

Permalink
Fix expsilon float & point force update
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenph69 committed Jul 23, 2024
1 parent 8bf43b2 commit 4a1c2aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions gdextension/src/path/mcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ int32_t MCurve::add_point(const Vector3& position,const Vector3& in,const Vector
}
points_buffer.set(free_index,new_point);
free_buffer_indicies.remove_at(free_buffer_indicies.size() - 1);
UtilityFunctions::print("Finish creating points");
if(is_init_insert && octree != nullptr){
octree->insert_point(position,free_index,oct_id);
}
emit_signal("force_update_point",prev_conn);
emit_signal("force_update_point",free_index);
return free_index;
}

Expand Down Expand Up @@ -324,13 +325,13 @@ void MCurve::remove_point(const int32_t point_index){
// Removing from conn
for(int8_t i=0; i < MAX_CONN; i++){
if(p->conn[i]!=INVALID_POINT_INDEX){
int32_t conn_id = std::abs(p->conn[i]);
ERR_FAIL_INDEX(conn_id, points_buffer.size());
Conn conn(point_index,conn_id);
int32_t conn_point_id = std::abs(p->conn[i]);
ERR_FAIL_INDEX(conn_point_id, points_buffer.size());
Conn conn(point_index,conn_point_id);
active_conn.erase(conn.id);
conn_list.erase(conn.id);
conn_distances.erase(conn.id);
Point* conn_p = points_buffer.ptrw() + conn_id;
Point* conn_p = points_buffer.ptrw() + conn_point_id;
for(int8_t c=0; c < MAX_CONN; c++){
if(std::abs(conn_p->conn[c]) == point_index){
conn_p->conn[c] = INVALID_POINT_INDEX;
Expand All @@ -346,6 +347,11 @@ void MCurve::remove_point(const int32_t point_index){
}
free_buffer_indicies.push_back(point_index);
active_points.erase(point_index);
for(int8_t i=0; i < MAX_CONN; i++){
if(p->conn[i]!=INVALID_POINT_INDEX){
emit_signal("force_update_point",std::abs(p->conn[i]));
}
}
emit_signal("curve_updated");
emit_signal("remove_point",point_index);
}
Expand Down
2 changes: 1 addition & 1 deletion gdextension/src/path/mcurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class MCurve : public Resource{
private:
_FORCE_INLINE_ float get_length_between_basic(const Point* a, const Point* b,const Vector3& a_control, const Vector3& b_control);

#define BEZIER_EPSILON 0.001f
#define BEZIER_EPSILON 0.1f
_FORCE_INLINE_ Vector3 _get_bezier_extreme_t(const Vector3& a,const Vector3& b,const Vector3& a_control, const Vector3& b_control){
return (2*a_control - (b_control + a))/(b - a + 3*(a_control - b_control));
}
Expand Down
2 changes: 1 addition & 1 deletion gdextension/src/path/mcurve_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void MCurveMesh::_remove_mesh(int64_t id,bool is_intersection){
void MCurveMesh::restart(){
_generate_all_mesh_sliced_info();
_generate_all_intersections_info();
reload();
recreate();
}

void MCurveMesh::reload(){
Expand Down

0 comments on commit 4a1c2aa

Please sign in to comment.