[Bf-blender-cvs] [5a7f89354b0] soc-2021-simulation-display: Cleanup: Panels for drawing constraints

soumya pochiraju noreply at git.blender.org
Wed Aug 11 07:41:19 CEST 2021


Commit: 5a7f89354b0ae3d05d4b23204e359303b86974d4
Author: soumya pochiraju
Date:   Mon Aug 9 09:12:44 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB5a7f89354b0ae3d05d4b23204e359303b86974d4

Cleanup: Panels for drawing constraints

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

M	release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
M	source/blender/makesdna/DNA_rigidbody_types.h
M	source/blender/makesrna/intern/rna_rigidbody.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
index 51a0aa3203b..cfce8da6543 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody_constraint.py
@@ -474,6 +474,30 @@ class PHYSICS_PT_rigid_body_constraint_springs_linear(PHYSICS_PT_rigidbody_const
         sub.prop(rbc, "spring_stiffness_z", text="Stiffness")
         sub.prop(rbc, "spring_damping_z", text="Damping")
 
+class PHYSICS_PT_rigid_body_constraint_debug_draw(PHYSICS_PT_rigidbody_constraint_panel, Panel):
+    bl_label = "Debug draw"
+    bl_parent_id = 'PHYSICS_PT_rigid_body_constraint'
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        rbc = ob.rigid_body_constraint
+
+        return (ob and rbc
+                and (rbc.type in {'SLIDER', 'HINGE', 'PISTON'})
+                and context.engine in cls.COMPAT_ENGINES)
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
+
+        ob = context.object
+        rbc = ob.rigid_body_constraint
+
+        col = flow.column()
+        col.prop(rbc, "debug_draw_limits", text="Debug draw")
 
 classes = (
     PHYSICS_PT_rigid_body_constraint,
@@ -489,6 +513,7 @@ classes = (
     PHYSICS_PT_rigid_body_constraint_springs,
     PHYSICS_PT_rigid_body_constraint_springs_angular,
     PHYSICS_PT_rigid_body_constraint_springs_linear,
+    PHYSICS_PT_rigid_body_constraint_debug_draw,
 )
 
 
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index 5935da037f1..4dfaac3cf3d 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -422,6 +422,8 @@ typedef enum eRigidBodyCon_Flag {
   RBC_FLAG_USE_SPRING_ANG_X = (1 << 16),
   RBC_FLAG_USE_SPRING_ANG_Y = (1 << 17),
   RBC_FLAG_USE_SPRING_ANG_Z = (1 << 18),
+  /* Debug draw constraint limits */
+  RBC_FLAG_DRAW_CONSTRAINT_LIMITS = (1 << 19),
 } eRigidBodyCon_Flag;
 
 /* ******************************** */
diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c
index 7af2223dd38..6b7fad46e7e 100644
--- a/source/blender/makesrna/intern/rna_rigidbody.c
+++ b/source/blender/makesrna/intern/rna_rigidbody.c
@@ -1430,6 +1430,11 @@ static void rna_def_rigidbody_constraint(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Linear Motor", "Enable linear motor");
   RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
 
+  prop = RNA_def_property(srna, "debug_draw_limits", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_DRAW_CONSTRAINT_LIMITS);
+  RNA_def_property_ui_text(prop, "Visualise Limits", "Display the limits imposed by the constraint");
+  RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
+
   prop = RNA_def_property(srna, "use_motor_ang", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_MOTOR_ANG);
   RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_use_motor_ang_set");



More information about the Bf-blender-cvs mailing list