mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 15:00:09 +01:00
Fix hack to draw shapes in 3D physics tests
Using Shape::get_debug_mesh instead of the previous hack to draw a mesh instance based on a collision shape.
This commit is contained in:
@@ -46,29 +46,20 @@ func add_sphere(pos, radius, color):
|
||||
|
||||
|
||||
func add_shape(shape, transform, color):
|
||||
var body = StaticBody.new()
|
||||
body.collision_layer = 0
|
||||
body.collision_mask = 0
|
||||
var debug_mesh = shape.get_debug_mesh()
|
||||
|
||||
var collision = CollisionShape.new()
|
||||
collision.transform = transform
|
||||
collision.shape = shape
|
||||
var mesh_instance = MeshInstance.new()
|
||||
mesh_instance.transform = transform
|
||||
mesh_instance.mesh = debug_mesh
|
||||
|
||||
body.add_child(collision)
|
||||
|
||||
add_child(body)
|
||||
_drawn_nodes.push_back(body)
|
||||
|
||||
call_deferred("initialize_shape_material", body, color)
|
||||
|
||||
|
||||
func initialize_shape_material(body, color):
|
||||
var mesh_instance = body.get_child(1)
|
||||
var material = SpatialMaterial.new()
|
||||
material.flags_unshaded = true
|
||||
material.albedo_color = color
|
||||
mesh_instance.material_override = material
|
||||
|
||||
add_child(mesh_instance)
|
||||
_drawn_nodes.push_back(mesh_instance)
|
||||
|
||||
|
||||
func clear_drawn_nodes():
|
||||
for node in _drawn_nodes:
|
||||
|
||||
Reference in New Issue
Block a user