[Bf-blender-cvs] [ccdb32ab7ae] soc-2021-simulation-display: Modified slider and hinge constraint and added visualisation for the piston constraint

soumya pochiraju noreply at git.blender.org
Fri Aug 6 09:42:38 CEST 2021


Commit: ccdb32ab7aedda4ccbf0a7bb5171896275553cdf
Author: soumya pochiraju
Date:   Fri Aug 6 13:11:04 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rBccdb32ab7aedda4ccbf0a7bb5171896275553cdf

Modified slider and hinge constraint and added visualisation for the piston constraint

===================================================================

M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/addons_contrib
M	source/blender/draw/engines/overlay/overlay_extra.c

===================================================================

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 62e82958a76..ca39c1459bc 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 62e82958a760dad775d9b3387d7fb535fd6de4c6
+Subproject commit ca39c1459bcd99300afe3591fa5ffe40f5ba5eef
diff --git a/release/scripts/addons b/release/scripts/addons
index 4475cbd11a6..6fb64557179 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 4475cbd11a636382d57571e0f5dfeff1f90bd6b7
+Subproject commit 6fb64557179b3783fffae5bf704ad2ab8f7046a6
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 788441f2930..32040a4a0ca 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 788441f2930465bbfba8f0797b12dcef1d46694d
+Subproject commit 32040a4a0ca1537057612590194b54ed511462c8
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c
index 158507dc814..82ccdbd3514 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -1779,7 +1779,6 @@ static void OVERLAY_velocity_extra(OVERLAY_Data *data, RigidBodyOb *rbo)
   //}
   //else {
     copy_v3_v3(vel, rbo->vel);
-    printf("vel: %f %f %f\n", vel[0], vel[1], vel[2]);
   //}
   OVERLAY_vector_extra(data, vel, rbo->pos, scale, min_clamp, color, text_flag);
 }
@@ -1798,10 +1797,11 @@ static void OVERLAY_acceleration_extra(OVERLAY_Data *data,
   /* Calculate timestep. */
   const float ctime = DEG_get_ctime(depsgraph);
   const float frame_diff = ctime - scene->rigidbody_world->ltime;
-  const float timestep = 1.0f / (float)FPS * frame_diff * scene->rigidbody_world->time_scale;
+  const float timestep = (1.0f / (float)FPS * scene->rigidbody_world->time_scale)/ scene->rigidbody_world->substeps_per_frame;
 
   float acc[3];
   sub_v3_v3v3(acc, rbo->pvel, rbo->vel);
+ // printf("acc: %f %f %f\ntimestep:%f framedif:%f timescale:%f\n", acc[0], acc[1], acc[2], timestep, frame_diff, scene->rigidbody_world->time_scale);
   mul_v3_fl(acc, 1 / timestep);
   OVERLAY_vector_extra(data, acc, rbo->pos, scale, min_clamp, color, text_flag);
 }
@@ -2026,17 +2026,31 @@ static void OVERLAY_indicate_collision(OVERLAY_Data *data, Object *ob)
         break;
       case RB_SHAPE_CONE:
         OVERLAY_bounds(cb, ob, color, OB_BOUND_CONE, true, mat);
-        OVERLAY_colliding_face_on_cone(
-            data, ob->rigidbody_object->vec_locations[0].vector, mat, dir);
+        for (int i = 0; i < 2; i++) {
+          if (!is_zero_v3(ob->rigidbody_object->norm_forces[i].vector)) {
+             OVERLAY_colliding_face_on_cone(
+                 data, ob->rigidbody_object->vec_locations[i].vector, mat, dir);
+          }
+        }
         break;
       case RB_SHAPE_CYLINDER:
         OVERLAY_bounds(cb, ob, color, OB_BOUND_CYLINDER, true, mat);
-        OVERLAY_colliding_face_on_cylinder(
-            data, ob->rigidbody_object->vec_locations[0].vector, mat, dir);
+        for (int i = 0; i < 2; i++) {
+          if (!is_zero_v3(ob->rigidbody_object->norm_forces[i].vector)) {
+              OVERLAY_colliding_face_on_cylinder(
+                  data, ob->rigidbody_object->vec_locations[i].vector, mat, dir);
+          }
+        }
         break;
       case RB_SHAPE_CAPSULE:
         OVERLAY_bounds(cb, ob, color, OB_BOUND_CAPSULE, true, NULL);
         break;
+      case RB_SHAPE_CONVEXH:
+        OVERLAY_non_primitive_collision_shape(cb, ob, color);
+        break;
+      case RB_SHAPE_TRIMESH:
+        OVERLAY_non_primitive_collision_shape(cb, ob, color);
+        break;
     }
   }
 }
@@ -2080,26 +2094,22 @@ static void OVERLAY_linear_limits_single_object_rod(RigidBodyCon *rbc,
 }
 
 /* Draw walls for ob1 if it lies close to the walls. */
-static void OVERLAY_linear_limits_walls(RigidBodyCon *rbc,
-                                             Object *ob1,
-                                             Object *ob2,
-                                             Object *constraint_ob,
-                                             int axis,
-                                             OVERLAY_Data *data) {
+static void OVERLAY_linear_limits_walls (RigidBodyCon *rbc,
+                                         Object *ob1,
+                                         Object *ob2,
+                                        float upper_wall_pos[3],
+                                        float lower_wall_pos[3],
+                                        Object *constraint_ob,
+                                        int axis,
+                                        OVERLAY_Data *data) {
     float translation_range;
     float color[4];
     copy_v4_v4(color, G_draw.block.colorLibrary);
-    float limit_start[3] = {0.0f};
-    float limit_end[3] = {0.0f};
-    float initial_offset[3];
-    float current_offset[3];
+
     float distance_from_first_wall[3];
     float distance_from_second_wall[3];
     float *wall_pos;
 
-    sub_v3_v3v3(initial_offset, ob1->loc, ob2->loc);
-    sub_v3_v3v3(current_offset, ob1->rigidbody_object->pos, ob2->rigidbody_object->pos);
-
     /* Rotate wall to correct initial orientation */
     float rot1[3][3] = {{0}};
     /* Constraint object transform. */
@@ -2111,7 +2121,6 @@ static void OVERLAY_linear_limits_walls(RigidBodyCon *rbc,
 
     /* Get rotation from object matrices. */
     float size[3];
-    float loc[3];
 
     BKE_object_rot_to_mat3(constraint_ob, rot2, false);
     mat4_to_rot(rot3, ob2->obmat);
@@ -2127,22 +2136,16 @@ static void OVERLAY_linear_limits_walls(RigidBodyCon *rbc,
     switch(axis){
        case 0:
         translation_range = (rbc->limit_lin_x_upper - rbc->limit_lin_x_lower);
-        limit_start[0] += rbc->limit_lin_x_lower;
-        limit_end[0] += rbc->limit_lin_x_upper;
         ax[1] = 1.0f;
         axis_angle_to_mat3(rot1, ax, M_PI_2);
         break;
        case 1:
         translation_range = (rbc->limit_lin_y_upper - rbc->limit_lin_y_lower);
-        limit_start[1] += rbc->limit_lin_y_lower;
-        limit_end[1] += rbc->limit_lin_y_upper;
         ax[0] = 1.0f;
         axis_angle_to_mat3(rot1, ax, M_PI_2);
         break;
        case 2:
         translation_range = (rbc->limit_lin_z_upper - rbc->limit_lin_z_lower);
-        limit_start[2] += rbc->limit_lin_z_lower;
-        limit_end[2] += rbc->limit_lin_z_upper;
         /* Artbitrary axis so that the matrix(rot1) doesn't remain empty. */
         ax[0] = 1.0f;
         axis_angle_to_mat3(rot1, ax, 0.0f);
@@ -2156,31 +2159,18 @@ static void OVERLAY_linear_limits_walls(RigidBodyCon *rbc,
     mul_v3_fl(rot1[1], size[1]);
     mul_v3_fl(rot1[2], size[2]);
 
-    mul_m3_v3(rot2, limit_start);
-    mul_m3_v3(rot2, limit_end);
-
-    add_v3_v3(limit_start, initial_offset);
-    add_v3_v3(limit_end, initial_offset);
-    mul_m3_v3(rot3, limit_start);
-    mul_m3_v3(rot3, limit_end);
-//    mul_m3_v3(rot4, limit_start);
-//    mul_m3_v3(rot4, limit_end);
-
-    add_v3_v3(limit_start, ob2->rigidbody_object->pos);
-    add_v3_v3(limit_end, ob2->rigidbody_object->pos);
-
-    sub_v3_v3v3(distance_from_first_wall, ob1->rigidbody_object->pos, limit_start);
-    sub_v3_v3v3(distance_from_second_wall, ob1->rigidbody_object->pos, limit_end);
+    sub_v3_v3v3(distance_from_first_wall, ob1->rigidbody_object->pos, upper_wall_pos);
+    sub_v3_v3v3(distance_from_second_wall, ob1->rigidbody_object->pos, lower_wall_pos);
 
     float d1 = fabsf(len_v3(distance_from_first_wall));
     float d2 = fabsf(len_v3(distance_from_second_wall));
 
-    float draw_range = translation_range < 6.0f ? (translation_range/2.0f)*0.5f : 3.0f;
+    float draw_range = translation_range < 12.0f ? (translation_range/2.0f)*0.5f : 3.0f;
 
     bool draw_wall = (d1 <= draw_range) || (d2 <= draw_range);
 
      if(fabsf(translation_range)>0.0f && draw_wall) {
-         wall_pos = (d1 <= draw_range) ? limit_start : limit_end;
+         wall_pos = (d1 <= draw_range) ? upper_wall_pos : lower_wall_pos;
          float distance = (d1 <= draw_range) ? d1 : d2;
          mul_v4_fl(color, (draw_range - distance)/draw_range);
 
@@ -2189,7 +2179,6 @@ static void OVERLAY_linear_limits_walls(RigidBodyCon *rbc,
          copy_m4_m3(final_mat, rot1);
          mul_m4_m3m4(final_mat, rot2, final_mat);
          mul_m4_m3m4(final_mat, rot3, final_mat);
-         // mul_m4_m3m4(final_mat, rot4, final_mat);
          copy_v3_v3(final_mat[3], wall_pos);
          final_mat[3][3] = 1.0f;
 
@@ -2205,7 +2194,8 @@ static void OVERLAY_linear_limits_rod(RigidBodyCon *rbc,
                                              Object *ob2,
                                              Object *constraint_ob,
                                              int axis,
-                                             OVERLAY_ExtraCallBuffers *cb) {
+                                             OVERLAY_ExtraCallBuffers *cb,
+                                             OVERLAY_Data *data) {
 
     float color[4];
     copy_v4_v4(color, G_draw.block.colorLibrary);
@@ -2214,6 +2204,8 @@ static void OVERLAY_linear_limits_rod(RigidBodyCon *rbc,
     float initial_distance_vec[3];
     float line_start[3] = {0.0f};
     float line_end[3] = {0.0f};
+    float ob1_lower_limit_mark[3] = {0.0f};
+    float ob2_lower_limit_mark[3] = {0.0f};
     float ob1_projection[3] = {0.0f};
     float ob2_projection[3] = {0.0f};
     sub_v3_v3v3(initial_distance_vec, ob1->loc, ob2->loc);
@@ -2231,121 +2223,135 @@ static void OVERLAY_linear_limits_rod(RigidBodyCon *rbc,
     BKE_object_rot_to_mat3(ob1, rot3, false);
     invert_m3(rot3);
     mul_m3_m3m3(rot2, rot2, rot3);
-    /*mul_m3_v3(rot1, constrained_axis);
-    mul_m3_v3(rot2, constrained_axis);
-
-    mul_m3_v3(rot2, initial_distance_vec);
-    sub_v3_v3(distance_vec, initial_distance_vec);
-    //dot_v3v3(distance_vec, constrained_axis); */
 
     float cross_product[3];
     cross_v3_v3v3(cross_product, distance_vec, constrained_axis);
     mul_m3_v3(rot1, constrained_axis);
     normalize_v3(constrained_axis);
 
-    bool draw_rod = true;
+    bool draw_rod = rbc->type == RBC_TYPE_SLIDER;
 
 
-    if(draw_rod) {
 
- 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list