summaryrefslogtreecommitdiff
path: root/scene/3d/ray_cast.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/ray_cast.cpp')
-rw-r--r--scene/3d/ray_cast.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index fbe3cd7a3e..be1426f13c 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -80,7 +80,7 @@ bool RayCast::is_colliding() const {
}
Object *RayCast::get_collider() const {
- if (against == 0)
+ if (against.is_null())
return NULL;
return ObjectDB::get_instance(against);
@@ -186,7 +186,7 @@ void RayCast::_notification(int p_what) {
_update_raycast_state();
if (prev_collision_state != collided && get_tree()->is_debugging_collisions_hint()) {
if (debug_material.is_valid()) {
- Ref<SpatialMaterial> line_material = static_cast<Ref<SpatialMaterial> >(debug_material);
+ Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D> >(debug_material);
line_material->set_albedo(collided ? Color(1.0, 0, 0) : Color(1.0, 0.8, 0.6));
}
}
@@ -219,7 +219,7 @@ void RayCast::_update_raycast_state() {
against_shape = rr.shape;
} else {
collided = false;
- against = 0;
+ against = ObjectID();
against_shape = 0;
}
}
@@ -333,11 +333,10 @@ void RayCast::_bind_methods() {
void RayCast::_create_debug_shape() {
if (!debug_material.is_valid()) {
- debug_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
+ debug_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
- Ref<SpatialMaterial> line_material = static_cast<Ref<SpatialMaterial> >(debug_material);
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_line_width(3.0);
+ Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D> >(debug_material);
+ line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
line_material->set_albedo(Color(1.0, 0.8, 0.6));
}
@@ -363,8 +362,7 @@ void RayCast::_update_debug_shape() {
return;
Ref<ArrayMesh> mesh = mi->get_mesh();
- if (mesh->get_surface_count() > 0)
- mesh->surface_remove(0);
+ mesh->clear_surfaces();
Array a;
a.resize(Mesh::ARRAY_MAX);
@@ -395,7 +393,7 @@ void RayCast::_clear_debug_shape() {
RayCast::RayCast() {
enabled = false;
- against = 0;
+
collided = false;
against_shape = 0;
collision_mask = 1;