@@ -7,7 +7,8 @@ namespace Editor;
77partial class ModelDropObject : BaseDropObject
88{
99 Model model ;
10- string archetype ;
10+ bool physicsArchetype ;
11+ bool physics ;
1112
1213 protected override async Task Initialize ( string dragData , CancellationToken token )
1314 {
@@ -19,27 +20,33 @@ protected override async Task Initialize( string dragData, CancellationToken tok
1920 if ( token . IsCancellationRequested )
2021 return ;
2122
22- archetype = asset . FindStringEditInfo ( "model_archetype_id" ) ;
23+ var archetype = asset . FindStringEditInfo ( "model_archetype_id" ) ;
2324
2425 PackageStatus = "Loading Model" ;
2526 model = await Model . LoadAsync ( asset . Path ) ;
2627 PackageStatus = null ;
2728
2829 Bounds = model . Bounds ;
2930 PivotPosition = Bounds . ClosestPoint ( Vector3 . Down * 10000 ) ;
31+ physics = ( model . Physics ? . Parts . Count ?? 0 ) > 0 ;
32+ if ( physics && model . Physics . Parts . Any ( p => p . Meshes . Any ( ) ) ) // can't do rigid body with meshes
33+ physics = false ;
34+ physicsArchetype = archetype == "physics_prop_model" || archetype == "jointed_physics_model" || archetype == "breakable_prop_model" ;
3035 }
3136
3237 public override void OnUpdate ( )
3338 {
3439 using var scope = Gizmo . Scope ( "DropObject" , traceTransform ) ;
3540
36- Gizmo . Draw . Color = Color . White . WithAlpha ( 0.3f ) ;
37- Gizmo . Draw . LineBBox ( Bounds ) ;
38-
39- Gizmo . Draw . Color = Color . White ;
40-
4141 if ( model is not null )
4242 {
43+ if ( physics && physicsArchetype != Gizmo . IsShiftPressed )
44+ Gizmo . Draw . Color = Theme . Blue . WithAlpha ( 0.6f ) ;
45+ else
46+ Gizmo . Draw . Color = Color . White . WithAlpha ( 0.3f ) ;
47+ Gizmo . Draw . LineBBox ( Bounds ) ;
48+
49+ Gizmo . Draw . Color = Color . White ;
4350 var so = Gizmo . Draw . Model ( model ) ;
4451 if ( so . IsValid ( ) )
4552 {
@@ -58,8 +65,6 @@ public override void OnUpdate()
5865
5966 private bool HasPropData ( )
6067 {
61- if ( archetype == "physics_prop_model" || archetype == "jointed_physics_model" || archetype == "breakable_prop_model" )
62- return true ;
6368 if ( model . Data . Explosive )
6469 return true ;
6570 if ( model . Data . Flammable )
@@ -86,12 +91,12 @@ public override async Task OnDrop()
8691 GameObject . Name = model . ResourceName ;
8792 GameObject . WorldTransform = traceTransform ;
8893
89- bool physics = ( model . Physics ? . Parts . Count ?? 0 ) > 0 ;
90- if ( physics && HasPropData ( ) )
94+ var rigidbody = physics && physicsArchetype != Gizmo . IsShiftPressed ;
95+ if ( rigidbody || HasPropData ( ) )
9196 {
9297 var prop = GameObject . Components . Create < Prop > ( ) ;
9398 prop . Model = model ;
94- prop . IsStatic = archetype == "" || archetype == "default" || archetype == "static_prop_model" || archetype == "animated_model" ;
99+ prop . IsStatic = ! rigidbody ;
95100 }
96101 else if ( model . BoneCount > 0 )
97102 {
@@ -102,7 +107,7 @@ public override async Task OnDrop()
102107 {
103108 var renderer = GameObject . Components . Create < ModelRenderer > ( ) ;
104109 renderer . Model = model ;
105- if ( physics )
110+ if ( ( model . Physics ? . Parts . Count ?? 0 ) > 0 )
106111 {
107112 var collider = GameObject . Components . Create < ModelCollider > ( ) ;
108113 collider . Model = model ;
0 commit comments