@@ -2226,21 +2226,22 @@ bool PhysicalBone3D::PinJointData::_set(const StringName &p_name, const Variant
2226
2226
return true ;
2227
2227
}
2228
2228
2229
+ bool is_valid_pin = j.is_valid () && PhysicsServer3D::get_singleton ()->joint_get_type (j) == PhysicsServer3D::JOINT_TYPE_PIN;
2229
2230
if (" joint_constraints/bias" == p_name) {
2230
2231
bias = p_value;
2231
- if (j. is_valid () ) {
2232
+ if (is_valid_pin ) {
2232
2233
PhysicsServer3D::get_singleton ()->pin_joint_set_param (j, PhysicsServer3D::PIN_JOINT_BIAS, bias);
2233
2234
}
2234
2235
2235
2236
} else if (" joint_constraints/damping" == p_name) {
2236
2237
damping = p_value;
2237
- if (j. is_valid () ) {
2238
+ if (is_valid_pin ) {
2238
2239
PhysicsServer3D::get_singleton ()->pin_joint_set_param (j, PhysicsServer3D::PIN_JOINT_DAMPING, damping);
2239
2240
}
2240
2241
2241
2242
} else if (" joint_constraints/impulse_clamp" == p_name) {
2242
2243
impulse_clamp = p_value;
2243
- if (j. is_valid () ) {
2244
+ if (is_valid_pin ) {
2244
2245
PhysicsServer3D::get_singleton ()->pin_joint_set_param (j, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp);
2245
2246
}
2246
2247
@@ -2282,33 +2283,34 @@ bool PhysicalBone3D::ConeJointData::_set(const StringName &p_name, const Variant
2282
2283
return true ;
2283
2284
}
2284
2285
2286
+ bool is_valid_cone = j.is_valid () && PhysicsServer3D::get_singleton ()->joint_get_type (j) == PhysicsServer3D::JOINT_TYPE_CONE_TWIST;
2285
2287
if (" joint_constraints/swing_span" == p_name) {
2286
2288
swing_span = Math::deg_to_rad (real_t (p_value));
2287
- if (j. is_valid () ) {
2289
+ if (is_valid_cone ) {
2288
2290
PhysicsServer3D::get_singleton ()->cone_twist_joint_set_param (j, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, swing_span);
2289
2291
}
2290
2292
2291
2293
} else if (" joint_constraints/twist_span" == p_name) {
2292
2294
twist_span = Math::deg_to_rad (real_t (p_value));
2293
- if (j. is_valid () ) {
2295
+ if (is_valid_cone ) {
2294
2296
PhysicsServer3D::get_singleton ()->cone_twist_joint_set_param (j, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, twist_span);
2295
2297
}
2296
2298
2297
2299
} else if (" joint_constraints/bias" == p_name) {
2298
2300
bias = p_value;
2299
- if (j. is_valid () ) {
2301
+ if (is_valid_cone ) {
2300
2302
PhysicsServer3D::get_singleton ()->cone_twist_joint_set_param (j, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, bias);
2301
2303
}
2302
2304
2303
2305
} else if (" joint_constraints/softness" == p_name) {
2304
2306
softness = p_value;
2305
- if (j. is_valid () ) {
2307
+ if (is_valid_cone ) {
2306
2308
PhysicsServer3D::get_singleton ()->cone_twist_joint_set_param (j, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, softness);
2307
2309
}
2308
2310
2309
2311
} else if (" joint_constraints/relaxation" == p_name) {
2310
2312
relaxation = p_value;
2311
- if (j. is_valid () ) {
2313
+ if (is_valid_cone ) {
2312
2314
PhysicsServer3D::get_singleton ()->cone_twist_joint_set_param (j, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, relaxation);
2313
2315
}
2314
2316
@@ -2356,39 +2358,40 @@ bool PhysicalBone3D::HingeJointData::_set(const StringName &p_name, const Varian
2356
2358
return true ;
2357
2359
}
2358
2360
2361
+ bool is_valid_hinge = j.is_valid () && PhysicsServer3D::get_singleton ()->joint_get_type (j) == PhysicsServer3D::JOINT_TYPE_HINGE;
2359
2362
if (" joint_constraints/angular_limit_enabled" == p_name) {
2360
2363
angular_limit_enabled = p_value;
2361
- if (j. is_valid () ) {
2364
+ if (is_valid_hinge ) {
2362
2365
PhysicsServer3D::get_singleton ()->hinge_joint_set_flag (j, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled);
2363
2366
}
2364
2367
2365
2368
} else if (" joint_constraints/angular_limit_upper" == p_name) {
2366
2369
angular_limit_upper = Math::deg_to_rad (real_t (p_value));
2367
- if (j. is_valid () ) {
2370
+ if (is_valid_hinge ) {
2368
2371
PhysicsServer3D::get_singleton ()->hinge_joint_set_param (j, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper);
2369
2372
}
2370
2373
2371
2374
} else if (" joint_constraints/angular_limit_lower" == p_name) {
2372
2375
angular_limit_lower = Math::deg_to_rad (real_t (p_value));
2373
- if (j. is_valid () ) {
2376
+ if (is_valid_hinge ) {
2374
2377
PhysicsServer3D::get_singleton ()->hinge_joint_set_param (j, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower);
2375
2378
}
2376
2379
2377
2380
} else if (" joint_constraints/angular_limit_bias" == p_name) {
2378
2381
angular_limit_bias = p_value;
2379
- if (j. is_valid () ) {
2382
+ if (is_valid_hinge ) {
2380
2383
PhysicsServer3D::get_singleton ()->hinge_joint_set_param (j, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias);
2381
2384
}
2382
2385
2383
2386
} else if (" joint_constraints/angular_limit_softness" == p_name) {
2384
2387
angular_limit_softness = p_value;
2385
- if (j. is_valid () ) {
2388
+ if (is_valid_hinge ) {
2386
2389
PhysicsServer3D::get_singleton ()->hinge_joint_set_param (j, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness);
2387
2390
}
2388
2391
2389
2392
} else if (" joint_constraints/angular_limit_relaxation" == p_name) {
2390
2393
angular_limit_relaxation = p_value;
2391
- if (j. is_valid () ) {
2394
+ if (is_valid_hinge ) {
2392
2395
PhysicsServer3D::get_singleton ()->hinge_joint_set_param (j, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation);
2393
2396
}
2394
2397
@@ -2439,63 +2442,64 @@ bool PhysicalBone3D::SliderJointData::_set(const StringName &p_name, const Varia
2439
2442
return true ;
2440
2443
}
2441
2444
2445
+ bool is_valid_slider = j.is_valid () && PhysicsServer3D::get_singleton ()->joint_get_type (j) == PhysicsServer3D::JOINT_TYPE_SLIDER;
2442
2446
if (" joint_constraints/linear_limit_upper" == p_name) {
2443
2447
linear_limit_upper = p_value;
2444
- if (j. is_valid () ) {
2448
+ if (is_valid_slider ) {
2445
2449
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper);
2446
2450
}
2447
2451
2448
2452
} else if (" joint_constraints/linear_limit_lower" == p_name) {
2449
2453
linear_limit_lower = p_value;
2450
- if (j. is_valid () ) {
2454
+ if (is_valid_slider ) {
2451
2455
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower);
2452
2456
}
2453
2457
2454
2458
} else if (" joint_constraints/linear_limit_softness" == p_name) {
2455
2459
linear_limit_softness = p_value;
2456
- if (j. is_valid () ) {
2460
+ if (is_valid_slider ) {
2457
2461
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness);
2458
2462
}
2459
2463
2460
2464
} else if (" joint_constraints/linear_limit_restitution" == p_name) {
2461
2465
linear_limit_restitution = p_value;
2462
- if (j. is_valid () ) {
2466
+ if (is_valid_slider ) {
2463
2467
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution);
2464
2468
}
2465
2469
2466
2470
} else if (" joint_constraints/linear_limit_damping" == p_name) {
2467
2471
linear_limit_damping = p_value;
2468
- if (j. is_valid () ) {
2472
+ if (is_valid_slider ) {
2469
2473
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution);
2470
2474
}
2471
2475
2472
2476
} else if (" joint_constraints/angular_limit_upper" == p_name) {
2473
2477
angular_limit_upper = Math::deg_to_rad (real_t (p_value));
2474
- if (j. is_valid () ) {
2478
+ if (is_valid_slider ) {
2475
2479
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper);
2476
2480
}
2477
2481
2478
2482
} else if (" joint_constraints/angular_limit_lower" == p_name) {
2479
2483
angular_limit_lower = Math::deg_to_rad (real_t (p_value));
2480
- if (j. is_valid () ) {
2484
+ if (is_valid_slider ) {
2481
2485
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower);
2482
2486
}
2483
2487
2484
2488
} else if (" joint_constraints/angular_limit_softness" == p_name) {
2485
2489
angular_limit_softness = p_value;
2486
- if (j. is_valid () ) {
2490
+ if (is_valid_slider ) {
2487
2491
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
2488
2492
}
2489
2493
2490
2494
} else if (" joint_constraints/angular_limit_restitution" == p_name) {
2491
2495
angular_limit_restitution = p_value;
2492
- if (j. is_valid () ) {
2496
+ if (is_valid_slider ) {
2493
2497
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
2494
2498
}
2495
2499
2496
2500
} else if (" joint_constraints/angular_limit_damping" == p_name) {
2497
2501
angular_limit_damping = p_value;
2498
- if (j. is_valid () ) {
2502
+ if (is_valid_slider ) {
2499
2503
PhysicsServer3D::get_singleton ()->slider_joint_set_param (j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping);
2500
2504
}
2501
2505
@@ -2580,130 +2584,130 @@ bool PhysicalBone3D::SixDOFJointData::_set(const StringName &p_name, const Varia
2580
2584
}
2581
2585
2582
2586
String var_name = path.get_slicec (' /' , 2 );
2583
-
2587
+ bool is_valid_6dof = j. is_valid () && PhysicsServer3D::get_singleton ()-> joint_get_type (j) == PhysicsServer3D::JOINT_TYPE_6DOF;
2584
2588
if (" linear_limit_enabled" == var_name) {
2585
2589
axis_data[axis].linear_limit_enabled = p_value;
2586
- if (j. is_valid () ) {
2590
+ if (is_valid_6dof ) {
2587
2591
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_flag (j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled );
2588
2592
}
2589
2593
2590
2594
} else if (" linear_limit_upper" == var_name) {
2591
2595
axis_data[axis].linear_limit_upper = p_value;
2592
- if (j. is_valid () ) {
2596
+ if (is_valid_6dof ) {
2593
2597
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper );
2594
2598
}
2595
2599
2596
2600
} else if (" linear_limit_lower" == var_name) {
2597
2601
axis_data[axis].linear_limit_lower = p_value;
2598
- if (j. is_valid () ) {
2602
+ if (is_valid_6dof ) {
2599
2603
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower );
2600
2604
}
2601
2605
2602
2606
} else if (" linear_limit_softness" == var_name) {
2603
2607
axis_data[axis].linear_limit_softness = p_value;
2604
- if (j. is_valid () ) {
2608
+ if (is_valid_6dof ) {
2605
2609
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness );
2606
2610
}
2607
2611
2608
2612
} else if (" linear_spring_enabled" == var_name) {
2609
2613
axis_data[axis].linear_spring_enabled = p_value;
2610
- if (j. is_valid () ) {
2614
+ if (is_valid_6dof ) {
2611
2615
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_flag (j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled );
2612
2616
}
2613
2617
2614
2618
} else if (" linear_spring_stiffness" == var_name) {
2615
2619
axis_data[axis].linear_spring_stiffness = p_value;
2616
- if (j. is_valid () ) {
2620
+ if (is_valid_6dof ) {
2617
2621
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness );
2618
2622
}
2619
2623
2620
2624
} else if (" linear_spring_damping" == var_name) {
2621
2625
axis_data[axis].linear_spring_damping = p_value;
2622
- if (j. is_valid () ) {
2626
+ if (is_valid_6dof ) {
2623
2627
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping );
2624
2628
}
2625
2629
2626
2630
} else if (" linear_equilibrium_point" == var_name) {
2627
2631
axis_data[axis].linear_equilibrium_point = p_value;
2628
- if (j. is_valid () ) {
2632
+ if (is_valid_6dof ) {
2629
2633
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point );
2630
2634
}
2631
2635
2632
2636
} else if (" linear_restitution" == var_name) {
2633
2637
axis_data[axis].linear_restitution = p_value;
2634
- if (j. is_valid () ) {
2638
+ if (is_valid_6dof ) {
2635
2639
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution );
2636
2640
}
2637
2641
2638
2642
} else if (" linear_damping" == var_name) {
2639
2643
axis_data[axis].linear_damping = p_value;
2640
- if (j. is_valid () ) {
2644
+ if (is_valid_6dof ) {
2641
2645
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping );
2642
2646
}
2643
2647
2644
2648
} else if (" angular_limit_enabled" == var_name) {
2645
2649
axis_data[axis].angular_limit_enabled = p_value;
2646
- if (j. is_valid () ) {
2650
+ if (is_valid_6dof ) {
2647
2651
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_flag (j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled );
2648
2652
}
2649
2653
2650
2654
} else if (" angular_limit_upper" == var_name) {
2651
2655
axis_data[axis].angular_limit_upper = Math::deg_to_rad (real_t (p_value));
2652
- if (j. is_valid () ) {
2656
+ if (is_valid_6dof ) {
2653
2657
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper );
2654
2658
}
2655
2659
2656
2660
} else if (" angular_limit_lower" == var_name) {
2657
2661
axis_data[axis].angular_limit_lower = Math::deg_to_rad (real_t (p_value));
2658
- if (j. is_valid () ) {
2662
+ if (is_valid_6dof ) {
2659
2663
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower );
2660
2664
}
2661
2665
2662
2666
} else if (" angular_limit_softness" == var_name) {
2663
2667
axis_data[axis].angular_limit_softness = p_value;
2664
- if (j. is_valid () ) {
2668
+ if (is_valid_6dof ) {
2665
2669
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness );
2666
2670
}
2667
2671
2668
2672
} else if (" angular_restitution" == var_name) {
2669
2673
axis_data[axis].angular_restitution = p_value;
2670
- if (j. is_valid () ) {
2674
+ if (is_valid_6dof ) {
2671
2675
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution );
2672
2676
}
2673
2677
2674
2678
} else if (" angular_damping" == var_name) {
2675
2679
axis_data[axis].angular_damping = p_value;
2676
- if (j. is_valid () ) {
2680
+ if (is_valid_6dof ) {
2677
2681
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping );
2678
2682
}
2679
2683
2680
2684
} else if (" erp" == var_name) {
2681
2685
axis_data[axis].erp = p_value;
2682
- if (j. is_valid () ) {
2686
+ if (is_valid_6dof ) {
2683
2687
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp );
2684
2688
}
2685
2689
2686
2690
} else if (" angular_spring_enabled" == var_name) {
2687
2691
axis_data[axis].angular_spring_enabled = p_value;
2688
- if (j. is_valid () ) {
2692
+ if (is_valid_6dof ) {
2689
2693
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_flag (j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled );
2690
2694
}
2691
2695
2692
2696
} else if (" angular_spring_stiffness" == var_name) {
2693
2697
axis_data[axis].angular_spring_stiffness = p_value;
2694
- if (j. is_valid () ) {
2698
+ if (is_valid_6dof ) {
2695
2699
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness );
2696
2700
}
2697
2701
2698
2702
} else if (" angular_spring_damping" == var_name) {
2699
2703
axis_data[axis].angular_spring_damping = p_value;
2700
- if (j. is_valid () ) {
2704
+ if (is_valid_6dof ) {
2701
2705
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping );
2702
2706
}
2703
2707
2704
2708
} else if (" angular_equilibrium_point" == var_name) {
2705
2709
axis_data[axis].angular_equilibrium_point = p_value;
2706
- if (j. is_valid () ) {
2710
+ if (is_valid_6dof ) {
2707
2711
PhysicsServer3D::get_singleton ()->generic_6dof_joint_set_param (j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point );
2708
2712
}
2709
2713
0 commit comments