summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/baked_light_instance.cpp2
-rw-r--r--scene/3d/camera.cpp38
-rw-r--r--scene/3d/camera.h16
-rw-r--r--scene/3d/character_camera.cpp2
-rw-r--r--scene/3d/light.cpp36
-rw-r--r--scene/3d/light.h24
-rw-r--r--scene/3d/mesh_instance.cpp8
-rw-r--r--scene/3d/mesh_instance.h6
-rw-r--r--scene/3d/navigation.cpp10
-rw-r--r--scene/3d/particles.cpp20
-rw-r--r--scene/3d/particles.h38
-rw-r--r--scene/3d/portal.cpp28
-rw-r--r--scene/3d/portal.h10
-rw-r--r--scene/3d/room_instance.cpp2
-rw-r--r--scene/3d/skeleton.cpp110
-rw-r--r--scene/3d/skeleton.h38
-rw-r--r--scene/3d/spatial.cpp34
-rw-r--r--scene/3d/spatial.h14
-rw-r--r--scene/3d/spatial_sample_player.h2
-rw-r--r--scene/3d/test_cube.h4
-rw-r--r--scene/3d/visual_instance.cpp42
-rw-r--r--scene/3d/visual_instance.h16
22 files changed, 277 insertions, 223 deletions
diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp
index 1ae7866f0b..4487415030 100644
--- a/scene/3d/baked_light_instance.cpp
+++ b/scene/3d/baked_light_instance.cpp
@@ -13,7 +13,7 @@ RID BakedLightInstance::get_baked_light_instance() const {
void BakedLightInstance::set_baked_light(const Ref<BakedLight>& p_baked_light) {
- baked_light=p_baked_light;
+ baked_light=p_baked_light;
RID base_rid;
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 01163e40e8..e76c0938fb 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -56,8 +56,8 @@ void Camera::_update_camera_mode() {
} break;
case PROJECTION_ORTHOGONAL: {
set_orthogonal(size,near,far);
- } break;
-
+ } break;
+
}
}
@@ -81,7 +81,7 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) {
else if (p_name=="near")
near=p_value;
else if (p_name=="far")
- far=p_value;
+ far=p_value;
else if (p_name=="keep_aspect")
set_keep_aspect_mode(KeepAspect(int(p_value)));
else if (p_name=="vaspect")
@@ -102,7 +102,7 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) {
set_environment(p_value);
} else
return false;
-
+
_update_camera_mode();
if (changed_all)
_change_notify();
@@ -147,21 +147,21 @@ bool Camera::_get(const StringName& p_name,Variant &r_ret) const {
void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::INT, "projection", PROPERTY_HINT_ENUM, "Perspective,Orthogonal") );
-
+
switch(mode) {
-
+
case PROJECTION_PERSPECTIVE: {
-
+
p_list->push_back( PropertyInfo( Variant::REAL, "fov" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_NOEDITOR) );
if (keep_aspect==KEEP_WIDTH)
p_list->push_back( PropertyInfo( Variant::REAL, "fovx" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_EDITOR) );
else
p_list->push_back( PropertyInfo( Variant::REAL, "fovy" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_EDITOR) );
-
+
} break;
case PROJECTION_ORTHOGONAL: {
-
+
p_list->push_back( PropertyInfo( Variant::REAL, "size" , PROPERTY_HINT_RANGE, "1,16384,0.01",PROPERTY_USAGE_NOEDITOR ) );
if (keep_aspect==KEEP_WIDTH)
p_list->push_back( PropertyInfo( Variant::REAL, "sizex" , PROPERTY_HINT_RANGE, "0.1,16384,0.01",PROPERTY_USAGE_EDITOR) );
@@ -169,9 +169,9 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::REAL, "sizey" , PROPERTY_HINT_RANGE, "0.1,16384,0.01",PROPERTY_USAGE_EDITOR) );
} break;
-
+
}
-
+
p_list->push_back( PropertyInfo( Variant::REAL, "near" , PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01") );
p_list->push_back( PropertyInfo( Variant::REAL, "far" , PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01") );
p_list->push_back( PropertyInfo( Variant::INT, "keep_aspect",PROPERTY_HINT_ENUM,"Keep Width,Keep Height") );
@@ -209,7 +209,7 @@ void Camera::_update_camera() {
void Camera::_notification(int p_what) {
switch(p_what) {
-
+
case NOTIFICATION_ENTER_WORLD: {
@@ -218,13 +218,13 @@ void Camera::_notification(int p_what) {
make_current();
- } break;
+ } break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
+
_request_camera_update();
} break;
case NOTIFICATION_EXIT_WORLD: {
-
+
if (!get_tree()->is_node_being_edited(this)) {
if (is_current()) {
clear_current();
@@ -250,7 +250,7 @@ void Camera::_notification(int p_what) {
}
} break;
-
+
}
}
@@ -270,7 +270,7 @@ void Camera::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far
near=p_z_near;
far=p_z_far;
mode=PROJECTION_PERSPECTIVE;
-
+
VisualServer::get_singleton()->camera_set_perspective(camera,fov,near,far);
update_gizmo();
force_change=false;
@@ -281,12 +281,12 @@ void Camera::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
return;
size = p_size;
-
+
near=p_z_near;
far=p_z_far;
mode=PROJECTION_ORTHOGONAL;
force_change=false;
-
+
VisualServer::get_singleton()->camera_set_orthogonal(camera,size,near,far);
update_gizmo();
}
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 02ca6ffb9a..30c6928245 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -41,7 +41,7 @@ class Camera : public Spatial {
OBJ_TYPE( Camera, Spatial );
public:
enum Projection {
-
+
PROJECTION_PERSPECTIVE,
PROJECTION_ORTHOGONAL
};
@@ -57,14 +57,14 @@ private:
bool current;
Projection mode;
-
+
float fov;
float size;
float near,far;
float v_offset;
float h_offset;
KeepAspect keep_aspect;
-
+
RID camera;
RID scenario_id;
@@ -86,14 +86,14 @@ protected:
void _update_camera();
virtual void _request_camera_update();
void _update_camera_mode();
-
+
bool _set(const StringName& p_name, const Variant& p_value);
bool _get(const StringName& p_name,Variant &r_ret) const;
void _get_property_list( List<PropertyInfo> *p_list) const;
void _notification(int p_what);
-
+
static void _bind_methods();
-
+
public:
enum {
@@ -104,7 +104,7 @@ public:
void set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far);
void set_orthogonal(float p_size, float p_z_near, float p_z_far);
-
+
void make_current();
void clear_current();
bool is_current() const;
@@ -145,7 +145,7 @@ public:
float get_h_offset() const;
- Camera();
+ Camera();
~Camera();
};
diff --git a/scene/3d/character_camera.cpp b/scene/3d/character_camera.cpp
index 2b22026fe9..fc3dfcd645 100644
--- a/scene/3d/character_camera.cpp
+++ b/scene/3d/character_camera.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "character_camera.h"
-
+
#include "physics_body.h"
#if 0
void CharacterCamera::_set(const String& p_name, const Variant& p_value) {
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 18463742c6..227bb3a59d 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "light.h"
-
+
#include "globals.h"
#include "scene/resources/surface_tool.h"
@@ -86,7 +86,7 @@ void Light::set_project_shadows(bool p_enabled) {
_change_notify("shadow");
}
bool Light::has_project_shadows() const {
-
+
return shadows;
}
@@ -175,9 +175,9 @@ RES Light::_get_gizmo_geometry() const {
Ref< Mesh > mesh;
Ref<SurfaceTool> surftool( memnew( SurfaceTool ));
-
+
switch(type) {
-
+
case VisualServer::LIGHT_DIRECTIONAL: {
@@ -260,9 +260,9 @@ RES Light::_get_gizmo_geometry() const {
surftool->set_material(mat_light);
mesh=surftool->commit(mesh);
} break;
-
+
case VisualServer::LIGHT_SPOT: {
-
+
_make_sphere( 5,5,0.1, surftool );
surftool->set_material(mat_light);
mesh=surftool->commit(mesh);
@@ -273,14 +273,14 @@ RES Light::_get_gizmo_geometry() const {
float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
-
+
for(int i = 0; i < points; i++) {
-
+
float x0=Math::sin(i * Math_PI * 2 / points);
float y0=Math::cos(i * Math_PI * 2 / points);
float x1=Math::sin((i+1) * Math_PI * 2 / points);
float y1=Math::cos((i+1) * Math_PI * 2 / points);
-
+
Vector3 v1=Vector3(x0*size,y0*size,-len).normalized()*len;
Vector3 v2=Vector3(x1*size,y1*size,-len).normalized()*len;
@@ -288,7 +288,7 @@ RES Light::_get_gizmo_geometry() const {
Vector3 v4=Vector3(0,0,v1.z);
Vector3 n = Plane(v1,v2,v3).normal;
-
+
surftool->add_normal(n);
surftool->add_vertex(v1);
@@ -306,7 +306,7 @@ RES Light::_get_gizmo_geometry() const {
surftool->add_normal(n);
surftool->add_vertex(v4);
-
+
}
surftool->set_material(mat_area);
@@ -323,15 +323,15 @@ RES Light::_get_gizmo_geometry() const {
AABB Light::get_aabb() const {
if (type==VisualServer::LIGHT_DIRECTIONAL) {
-
- return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
-
+
+ return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
+
} else if (type==VisualServer::LIGHT_OMNI) {
-
+
return AABB( Vector3(-1,-1,-1) * vars[PARAM_RADIUS], Vector3(2, 2, 2 ) * vars[PARAM_RADIUS]);
-
+
} else if (type==VisualServer::LIGHT_SPOT) {
-
+
float len=vars[PARAM_RADIUS];
float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;
return AABB( Vector3( -size,-size,-len ), Vector3( size*2, size*2, len ) );
@@ -542,7 +542,7 @@ void Light::_bind_methods() {
BIND_CONSTANT( COLOR_DIFFUSE );
- BIND_CONSTANT( COLOR_SPECULAR );
+ BIND_CONSTANT( COLOR_SPECULAR );
BIND_CONSTANT( BAKE_MODE_DISABLED );
BIND_CONSTANT( BAKE_MODE_INDIRECT );
diff --git a/scene/3d/light.h b/scene/3d/light.h
index b74085b7a9..b25c6a44b5 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -43,7 +43,7 @@ class Light : public VisualInstance {
OBJ_CATEGORY("3D Light Nodes");
public:
-
+
enum Parameter {
PARAM_RADIUS=VisualServer::LIGHT_PARAM_RADIUS,
PARAM_ENERGY=VisualServer::LIGHT_PARAM_ENERGY,
@@ -57,10 +57,10 @@ public:
PARAM_SHADOW_BLUR_PASSES=VisualServer::LIGHT_PARAM_SHADOW_BLUR_PASSES,
PARAM_MAX=VisualServer::LIGHT_PARAM_MAX
};
-
-
+
+
enum LightColor {
-
+
COLOR_DIFFUSE=VisualServer::LIGHT_COLOR_DIFFUSE,
COLOR_SPECULAR=VisualServer::LIGHT_COLOR_SPECULAR
};
@@ -81,13 +81,13 @@ public:
OPERATOR_SUB
};
private:
-
-
+
+
Ref<Texture> projector;
float vars[PARAM_MAX];
Color colors[3];
-
-
+
+
BakeMode bake_mode;
VisualServer::LightType type;
bool shadows;
@@ -98,18 +98,18 @@ private:
void _update_visibility();
// bind helpers
-protected:
+protected:
RID light;
virtual bool _can_gizmo_scale() const;
virtual RES _get_gizmo_geometry() const;
-
+
static void _bind_methods();
void _notification(int p_what);
-
- Light(VisualServer::LightType p_type);
+
+ Light(VisualServer::LightType p_type);
public:
VS::LightType get_light_type() const { return type; }
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index 997d2dea7c..cfe273fa20 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -139,7 +139,7 @@ AABB MeshInstance::get_aabb() const {
if (!mesh.is_null())
return mesh->get_aabb();
-
+
return AABB();
}
@@ -150,7 +150,7 @@ DVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
if (mesh.is_null())
return DVector<Face3>();
-
+
return mesh->get_faces();
}
@@ -177,7 +177,7 @@ void MeshInstance::create_trimesh_collision() {
StaticBody* static_body = create_trimesh_collision_node()->cast_to<StaticBody>();
ERR_FAIL_COND(!static_body);
static_body->set_name( String(get_name()) + "_col" );
-
+
add_child(static_body);
if (get_owner())
static_body->set_owner( get_owner() );
@@ -233,7 +233,7 @@ void MeshInstance::_notification(int p_what) {
void MeshInstance::_bind_methods() {
-
+
ObjectTypeDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MeshInstance::set_mesh);
ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"),&MeshInstance::get_mesh);
ObjectTypeDB::bind_method(_MD("set_skeleton_path","skeleton_path:NodePath"),&MeshInstance::set_skeleton_path);
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index f26ef52000..7c605c2d6d 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -38,7 +38,7 @@
class MeshInstance : public GeometryInstance {
OBJ_TYPE( MeshInstance, GeometryInstance );
-
+
Ref<Mesh> mesh;
NodePath skeleton_path;
@@ -68,7 +68,7 @@ public:
void set_skeleton_path(const NodePath& p_skeleton);
NodePath get_skeleton_path();
-
+
Node* create_trimesh_collision_node();
void create_trimesh_collision();
@@ -78,7 +78,7 @@ public:
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- MeshInstance();
+ MeshInstance();
~MeshInstance();
};
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp
index ce28350be0..2b74d43ad2 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -64,7 +64,11 @@ void Navigation::_navmesh_link(int p_id) {
continue;
}
- p.center=center/plen;
+ p.center = center;
+ if( plen != 0 ) {
+ p.center /= plen;
+ }
+
//connect
@@ -455,7 +459,7 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3& p_start, const Vector
_clip_path(path,apex_poly,portal_right,right_poly);
- apex_point=portal_right;
+ apex_point=portal_right;
p=right_poly;
left_poly=p;
apex_poly=p;
@@ -721,5 +725,3 @@ Navigation::Navigation() {
last_id=1;
up=Vector3(0,1,0);
}
-
-
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 47662bcccb..3ac5d8ed7b 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -100,10 +100,10 @@ void Particles::set_amount(int p_amount) {
VisualServer::get_singleton()->particles_set_amount(particles,p_amount);
}
int Particles::get_amount() const {
-
+
return amount;
}
-
+
void Particles::set_emitting(bool p_emitting) {
emitting=p_emitting;
@@ -115,19 +115,19 @@ bool Particles::is_emitting() const {
return emitting;
}
-
+
void Particles::set_visibility_aabb(const AABB& p_aabb) {
visibility_aabb=p_aabb;
VisualServer::get_singleton()->particles_set_visibility_aabb(particles,p_aabb);
update_gizmo();
-
+
}
AABB Particles::get_visibility_aabb() const {
return visibility_aabb;
}
-
+
void Particles::set_emission_points(const DVector<Vector3>& p_points) {
@@ -179,7 +179,7 @@ Vector3 Particles::get_gravity_normal() const {
return gravity_normal;
}
-
+
void Particles::set_variable(Variable p_variable,float p_value) {
ERR_FAIL_INDEX(p_variable,VAR_MAX);
@@ -273,7 +273,7 @@ float Particles::get_emit_timeout() const {
Ref<Material> Particles::get_material() const {
return material;
-}
+}
void Particles::set_height_from_velocity(bool p_enable) {
@@ -507,11 +507,11 @@ Particles::Particles() {
set_amount(64);
set_emitting(true);
set_visibility_aabb(AABB( Vector3(-4,-4,-4), Vector3(8,8,8) ) );
-
+
for (int i=0;i<VAR_MAX;i++) {
set_randomness((Variable)i,0.0);
}
-
+
set_variable( VAR_LIFETIME, 5.0);
set_variable( VAR_SPREAD, 0.2);
set_variable( VAR_GRAVITY, 9.8);
@@ -523,7 +523,7 @@ Particles::Particles() {
set_variable( VAR_DAMPING, 0.0);
set_variable( VAR_INITIAL_SIZE, 1.0);
set_variable( VAR_FINAL_SIZE, 1.0);
- set_variable( VAR_INITIAL_ANGLE, 0.0);
+ set_variable( VAR_INITIAL_ANGLE, 0.0);
set_variable( VAR_HEIGHT, 1.0);
set_variable( VAR_HEIGHT_SPEED_SCALE, 0.0);
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index b9cae332e2..42d27c41d7 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -63,7 +63,7 @@ private:
OBJ_TYPE( Particles, GeometryInstance );
RID particles;
-
+
int amount;
bool emitting;
float emit_timeout;
@@ -71,14 +71,14 @@ private:
Vector3 gravity_normal;
Vector3 emission_half_extents;
bool using_points;
- float var[VAR_MAX];
- float var_random[VAR_MAX];
+ float var[VAR_MAX];
+ float var_random[VAR_MAX];
bool height_from_velocity;
Vector3 emission_base_velocity;
bool local_coordinates;
-
+
struct ColorPhase {
-
+
Color color;
float pos;
};
@@ -87,18 +87,18 @@ private:
virtual RES _get_gizmo_geometry() const;
int color_phase_count;
-
+
ColorPhase color_phase[4];
-
+
Ref<Material> material;
Timer* timer;
void setup_timer();
-protected:
-
+protected:
+
static void _bind_methods();
-
+
public:
@@ -107,13 +107,13 @@ public:
void set_amount(int p_amount);
int get_amount() const;
-
+
void set_emitting(bool p_emitting);
bool is_emitting() const;
-
+
void set_visibility_aabb(const AABB& p_aabb);
AABB get_visibility_aabb() const;
-
+
void set_emission_half_extents(const Vector3& p_half_extents);
Vector3 get_emission_half_extents() const;
@@ -125,25 +125,25 @@ public:
void set_gravity_normal(const Vector3& p_normal);
Vector3 get_gravity_normal() const;
-
+
void set_variable(Variable p_variable,float p_value);
float get_variable(Variable p_variable) const;
-
+
void set_randomness(Variable p_variable,float p_randomness);
float get_randomness(Variable p_variable) const;
void set_color_phases(int p_phases);
int get_color_phases() const;
-
+
void set_color_phase_pos(int p_phase, float p_pos);
float get_color_phase_pos(int p_phase) const;
-
+
void set_color_phase_color(int p_phase, const Color& p_color);
Color get_color_phase_color(int p_phase) const;
void set_height_from_velocity(bool p_enable);
bool has_height_from_velocity() const;
-
+
void set_material(const Ref<Material>& p_material);
Ref<Material> get_material() const;
@@ -156,7 +156,7 @@ public:
void start_emitting(float p_time);
- Particles();
+ Particles();
~Particles();
};
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index 84f94402d5..23bc64615d 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -40,7 +40,7 @@ bool Portal::_set(const StringName& p_name, const Variant& p_value) {
ERR_FAIL_COND_V(src_coords_size%2,false);
points.resize(src_coords_size/2);
for (int i=0;i<points.size();i++) {
-
+
points[i].x=src_coords[i*2+0];
points[i].y=src_coords[i*2+1];
set_shape(points);
@@ -65,13 +65,13 @@ bool Portal::_get(const StringName& p_name,Variant &r_ret) const {
Vector<Point2> points=get_shape();
DVector<float> dst_coords;
dst_coords.resize(points.size()*2);
-
+
for (int i=0;i<points.size();i++) {
-
+
dst_coords.set(i*2+0,points[i].x);
dst_coords.set(i*2+1,points[i].y);
}
-
+
r_ret= dst_coords;
} else if (p_name=="enabled") {
r_ret= is_enabled();
@@ -115,17 +115,17 @@ RES Portal::_get_gizmo_geometry() const {
Vector2 center;
for (int i=0;i<shape.size();i++) {
-
+
int n=(i+1)%shape.size();
Vector<Vector3> points;
surface_tool->add_vertex( Vector3( shape[i].x, shape[i].y,0 ));
surface_tool->add_vertex( Vector3( shape[n].x, shape[n].y,0 ));
center+=shape[i];
-
+
}
if (shape.size()>0) {
-
+
center/=shape.size();
Vector<Vector3> points;
surface_tool->add_vertex( Vector3( center.x, center.y,0 ));
@@ -139,7 +139,7 @@ RES Portal::_get_gizmo_geometry() const {
AABB Portal::get_aabb() const {
- return aabb;
+ return aabb;
}
DVector<Face3> Portal::get_faces(uint32_t p_usage_flags) const {
@@ -149,28 +149,28 @@ DVector<Face3> Portal::get_faces(uint32_t p_usage_flags) const {
Vector<Point2> shape = get_shape();
if (shape.size()==0)
return DVector<Face3>();
-
+
Vector2 center;
for (int i=0;i<shape.size();i++) {
-
+
center+=shape[i];
-
+
}
-
+
DVector<Face3> ret;
center/=shape.size();
for (int i=0;i<shape.size();i++) {
int n=(i+1)%shape.size();
-
+
Face3 f;
f.vertex[0]=Vector3( center.x, center.y, 0 );
f.vertex[1]=Vector3( shape[i].x, shape[i].y, 0 );
f.vertex[2]=Vector3( shape[n].x, shape[n].y, 0 );
ret.push_back(f);
}
-
+
return ret;
}
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 388eac4dd3..149a56900f 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -45,14 +45,14 @@
class Portal : public VisualInstance {
OBJ_TYPE(Portal, VisualInstance);
-
+
RID portal;
-
+
bool enabled;
float disable_distance;
Color disabled_color;
float connect_range;
-
+
AABB aabb;
virtual RES _get_gizmo_geometry() const;
@@ -62,9 +62,9 @@ protected:
bool _set(const StringName& p_name, const Variant& p_value);
bool _get(const StringName& p_name,Variant &r_ret) const;
void _get_property_list( List<PropertyInfo> *p_list) const;
-
+
static void _bind_methods();
-
+
public:
virtual AABB get_aabb() const;
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index e358da136b..9e6867d2a2 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -29,7 +29,7 @@
#include "room_instance.h"
#include "servers/visual_server.h"
-
+
#include "geometry.h"
#include "globals.h"
#include "scene/resources/surface_tool.h"
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index 64133f67b5..d0b739e17f 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "skeleton.h"
-
+
#include "message_queue.h"
#include "scene/resources/surface_tool.h"
@@ -40,19 +40,19 @@ bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {
if (!path.begins_with("bones/"))
return false;
-
+
int which=path.get_slicec('/',1).to_int();
String what=path.get_slicec('/',2);
if (which==bones.size() && what=="name") {
-
+
add_bone(p_value);
return true;
}
-
+
ERR_FAIL_INDEX_V( which, bones.size(), false );
-
+
if (what=="parent")
set_bone_parent(which, p_value );
else if (what=="rest")
@@ -63,11 +63,11 @@ bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {
set_bone_pose(which, p_value);
else if (what=="bound_childs") {
Array children=p_value;
-
+
bones[which].nodes_bound.clear();
-
+
for (int i=0;i<children.size();i++) {
-
+
NodePath path=children[i];
ERR_CONTINUE( path.operator String()=="" );
Node *node = get_node(path);
@@ -87,12 +87,12 @@ bool Skeleton::_get(const StringName& p_name,Variant &r_ret) const {
if (!path.begins_with("bones/"))
return false;
-
+
int which=path.get_slicec('/',1).to_int();
String what=path.get_slicec('/',2);
-
+
ERR_FAIL_INDEX_V( which, bones.size(), false );
-
+
if (what=="name")
r_ret=get_bone_name(which);
else if (what=="parent")
@@ -105,29 +105,29 @@ bool Skeleton::_get(const StringName& p_name,Variant &r_ret) const {
r_ret=get_bone_pose(which);
else if (what=="bound_childs") {
Array children;
-
+
for (const List<uint32_t>::Element *E=bones[which].nodes_bound.front();E;E=E->next()) {
-
+
Object *obj=ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
Node *node=obj->cast_to<Node>();
ERR_CONTINUE(!node);
NodePath path=get_path_to(node);
children.push_back(path);
-
+
}
-
+
r_ret=children;
} else
return false;
-
+
return true;
}
void Skeleton::_get_property_list( List<PropertyInfo>* p_list ) const {
for (int i=0;i<bones.size();i++) {
-
+
String prep="bones/"+itos(i)+"/";
p_list->push_back( PropertyInfo( Variant::STRING, prep+"name" ) );
p_list->push_back( PropertyInfo( Variant::INT, prep+"parent" , PROPERTY_HINT_RANGE,"-1,"+itos(i-1)+",1") );
@@ -141,18 +141,18 @@ void Skeleton::_get_property_list( List<PropertyInfo>* p_list ) const {
void Skeleton::_notification(int p_what) {
switch(p_what) {
-
+
case NOTIFICATION_ENTER_WORLD: {
-
+
if (dirty) {
-
+
dirty=false;
_make_dirty(); // property make it dirty
}
-
+
} break;
case NOTIFICATION_EXIT_WORLD: {
-
+
} break;
case NOTIFICATION_UPDATE_SKELETON: {
@@ -178,15 +178,15 @@ void Skeleton::_notification(int p_what) {
Bone &b=bonesptr[i];
b.rest_global_inverse.affine_invert();
}
-
+
rest_global_inverse_dirty=false;
}
-
+
for (int i=0;i<len;i++) {
-
+
Bone &b=bonesptr[i];
-
+
if (b.disable_rest) {
if (b.enabled) {
@@ -241,7 +241,7 @@ void Skeleton::_notification(int p_what) {
}
}
}
-
+
vs->skeleton_bone_set_transform( skeleton, i, b.pose_global * b.rest_global_inverse );
for(List<uint32_t>::Element *E=b.nodes_bound.front();E;E=E->next()) {
@@ -255,7 +255,7 @@ void Skeleton::_notification(int p_what) {
}
dirty=false;
- } break;
+ } break;
}
}
@@ -298,16 +298,16 @@ RID Skeleton::get_skeleton() const {
void Skeleton::add_bone(const String& p_name) {
ERR_FAIL_COND( p_name=="" || p_name.find(":")!=-1 || p_name.find("/")!=-1 );
-
+
for (int i=0;i<bones.size();i++) {
-
+
ERR_FAIL_COND( bones[i].name=="p_name");
}
Bone b;
b.name=p_name;
bones.push_back(b);
-
+
rest_global_inverse_dirty=true;
_make_dirty();
update_gizmo();
@@ -315,11 +315,11 @@ void Skeleton::add_bone(const String& p_name) {
int Skeleton::find_bone(String p_name) const {
for (int i=0;i<bones.size();i++) {
-
+
if (bones[i].name==p_name)
return i;
}
-
+
return -1;
}
String Skeleton::get_bone_name(int p_bone) const {
@@ -338,7 +338,7 @@ void Skeleton::set_bone_parent(int p_bone, int p_parent) {
ERR_FAIL_INDEX( p_bone, bones.size() );
ERR_FAIL_COND( p_parent!=-1 && (p_parent<0 || p_parent>=p_bone));
-
+
bones[p_bone].parent=p_parent;
rest_global_inverse_dirty=true;
_make_dirty();
@@ -378,14 +378,14 @@ bool Skeleton::is_bone_rest_disabled(int p_bone) const {
int Skeleton::get_bone_parent(int p_bone) const {
ERR_FAIL_INDEX_V( p_bone, bones.size(), -1 );
-
+
return bones[p_bone].parent;
}
void Skeleton::set_bone_rest(int p_bone, const Transform& p_rest) {
ERR_FAIL_INDEX( p_bone, bones.size() );
-
+
bones[p_bone].rest=p_rest;
rest_global_inverse_dirty=true;
_make_dirty();
@@ -394,7 +394,7 @@ void Skeleton::set_bone_rest(int p_bone, const Transform& p_rest) {
Transform Skeleton::get_bone_rest(int p_bone) const {
ERR_FAIL_INDEX_V( p_bone, bones.size(), Transform() );
-
+
return bones[p_bone].rest;
}
@@ -402,7 +402,7 @@ Transform Skeleton::get_bone_rest(int p_bone) const {
void Skeleton::set_bone_enabled(int p_bone, bool p_enabled) {
ERR_FAIL_INDEX( p_bone, bones.size() );
-
+
bones[p_bone].enabled=p_enabled;
rest_global_inverse_dirty=true;
_make_dirty();
@@ -418,23 +418,23 @@ void Skeleton::bind_child_node_to_bone(int p_bone,Node *p_node) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_INDEX( p_bone, bones.size() );
-
+
uint32_t id=p_node->get_instance_ID();
-
+
for (List<uint32_t>::Element *E=bones[p_bone].nodes_bound.front();E;E=E->next()) {
-
+
if (E->get()==id)
return; // already here
}
-
+
bones[p_bone].nodes_bound.push_back(id);
-
+
}
void Skeleton::unbind_child_node_from_bone(int p_bone,Node *p_node) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_INDEX( p_bone, bones.size() );
-
+
uint32_t id=p_node->get_instance_ID();
bones[p_bone].nodes_bound.erase(id);
@@ -442,9 +442,9 @@ void Skeleton::unbind_child_node_from_bone(int p_bone,Node *p_node) {
void Skeleton::get_bound_child_nodes_to_bone(int p_bone,List<Node*> *p_bound) const {
ERR_FAIL_INDEX( p_bone, bones.size() );
-
+
for (const List<uint32_t>::Element *E=bones[p_bone].nodes_bound.front();E;E=E->next()) {
-
+
Object *obj=ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
p_bound->push_back(obj->cast_to<Node>());
@@ -465,7 +465,7 @@ void Skeleton::set_bone_pose(int p_bone, const Transform& p_pose) {
ERR_FAIL_INDEX( p_bone, bones.size() );
ERR_FAIL_COND( !is_inside_tree() );
-
+
bones[p_bone].pose=p_pose;
_make_dirty();
@@ -501,7 +501,7 @@ void Skeleton::_make_dirty() {
if (dirty)
return;
-
+
if (!is_inside_tree()) {
dirty=true;
return;
@@ -538,13 +538,13 @@ RES Skeleton::_get_gizmo_geometry() const {
int len=bones.size();
for (int i=0;i<len;i++) {
-
+
const Bone &b=bonesptr[i];
-
+
Transform t;
if (b.parent<0)
continue;
-
+
Vector3 v1=(bonesptr[b.parent].pose_global * bonesptr[b.parent].rest_global_inverse).xform(bonesptr[b.parent].rest_global_inverse.affine_inverse().origin);
Vector3 v2=(b.pose_global * b.rest_global_inverse).xform(b.rest_global_inverse.affine_inverse().origin);
@@ -576,10 +576,10 @@ void Skeleton::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_bone","name"),&Skeleton::add_bone);
ObjectTypeDB::bind_method(_MD("find_bone","name"),&Skeleton::find_bone);
ObjectTypeDB::bind_method(_MD("get_bone_name","bone_idx"),&Skeleton::get_bone_name);
-
+
ObjectTypeDB::bind_method(_MD("get_bone_parent","bone_idx"),&Skeleton::get_bone_parent);
ObjectTypeDB::bind_method(_MD("set_bone_parent","bone_idx","parent_idx"),&Skeleton::set_bone_parent);
-
+
ObjectTypeDB::bind_method(_MD("get_bone_count"),&Skeleton::get_bone_count);
ObjectTypeDB::bind_method(_MD("unparent_bone_and_rest","bone_idx"),&Skeleton::unparent_bone_and_rest);
@@ -593,9 +593,9 @@ void Skeleton::_bind_methods() {
ObjectTypeDB::bind_method(_MD("bind_child_node_to_bone","bone_idx","node:Node"),&Skeleton::bind_child_node_to_bone);
ObjectTypeDB::bind_method(_MD("unbind_child_node_from_bone","bone_idx","node:Node"),&Skeleton::unbind_child_node_from_bone);
ObjectTypeDB::bind_method(_MD("get_bound_child_nodes_to_bone","bone_idx"),&Skeleton::_get_bound_child_nodes_to_bone);
-
+
ObjectTypeDB::bind_method(_MD("clear_bones"),&Skeleton::clear_bones);
-
+
ObjectTypeDB::bind_method(_MD("get_bone_pose","bone_idx"),&Skeleton::get_bone_pose);
ObjectTypeDB::bind_method(_MD("set_bone_pose","bone_idx","pose"),&Skeleton::set_bone_pose);
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index 033f212a58..bfdb1d1499 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -49,36 +49,36 @@ class Skeleton : public Spatial {
bool disable_rest;
Transform rest;
Transform rest_global_inverse;
-
+
Transform pose;
Transform pose_global;
bool custom_pose_enable;
Transform custom_pose;
-
+
List<uint32_t> nodes_bound;
-
+
Bone() { parent=-1; enabled=true; custom_pose_enable=false; disable_rest=false; }
};
bool rest_global_inverse_dirty;
Vector<Bone> bones;
-
+
RID skeleton;
-
+
void _make_dirty();
bool dirty;
-
+
//bind helpers
Array _get_bound_child_nodes_to_bone(int p_bone) const {
-
+
Array bound;
List<Node*> childs;
get_bound_child_nodes_to_bone(p_bone,&childs);
-
+
for (int i=0;i<childs.size();i++) {
-
+
bound.push_back( childs[i] );
}
return bound;
@@ -93,11 +93,11 @@ protected:
void _get_property_list( List<PropertyInfo>* p_list ) const;
void _notification(int p_what);
static void _bind_methods();
-
+
public:
enum {
-
+
NOTIFICATION_UPDATE_SKELETON=50
};
@@ -108,7 +108,7 @@ public:
void add_bone(const String&p_name);
int find_bone(String p_name) const;
String get_bone_name(int p_bone) const;
-
+
void set_bone_parent(int p_bone, int p_parent);
int get_bone_parent(int p_bone) const;
@@ -118,7 +118,7 @@ public:
bool is_bone_rest_disabled(int p_bone) const;
int get_bone_count() const;
-
+
void set_bone_rest(int p_bone, const Transform& p_rest);
Transform get_bone_rest(int p_bone) const;
Transform get_bone_transform(int p_bone) const;
@@ -128,15 +128,15 @@ public:
void set_bone_enabled(int p_bone, bool p_enabled);
bool is_bone_enabled(int p_bone) const;
-
+
void bind_child_node_to_bone(int p_bone,Node *p_node);
void unbind_child_node_from_bone(int p_bone,Node *p_node);
void get_bound_child_nodes_to_bone(int p_bone,List<Node*> *p_bound) const;
-
+
void clear_bones();
-
+
// posing api
-
+
void set_bone_pose(int p_bone, const Transform& p_pose);
Transform get_bone_pose(int p_bone) const;
@@ -144,8 +144,8 @@ public:
Transform get_bone_custom_pose(int p_bone) const;
void localize_rests(); // used for loaders and tools
-
- Skeleton();
+
+ Skeleton();
~Skeleton();
};
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 0c1e1e2d1c..c2d318e8a7 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "spatial.h"
-
+
#include "scene/main/viewport.h"
#include "message_queue.h"
#include "scene/scene_string_names.h"
@@ -99,14 +99,14 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
// return; //already dirty
data.children_lock++;
-
+
for (List<Spatial*>::Element *E=data.children.front();E;E=E->next()) {
-
+
if (E->get()->data.toplevel_active)
continue; //don't propagate to a toplevel
E->get()->_propagate_transform_changed(p_origin);
}
-
+
if (!data.ignore_notification && !xform_change.in_list()) {
@@ -211,14 +211,14 @@ void Spatial::_notification(int p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
-
+
#ifdef TOOLS_ENABLED
if (data.gizmo.is_valid()) {
data.gizmo->transform();
}
#endif
} break;
-
+
default: {}
}
}
@@ -257,7 +257,7 @@ Transform Spatial::get_transform() const {
_update_local_transform();
}
-
+
return data.local_transform;
}
Transform Spatial::get_global_transform() const {
@@ -272,16 +272,16 @@ Transform Spatial::get_global_transform() const {
}
if (data.parent && !data.toplevel_active) {
-
+
data.global_transform=data.parent->get_global_transform() * data.local_transform;
} else {
-
+
data.global_transform=data.local_transform;
}
-
+
data.dirty&=~DIRTY_GLOBAL;
}
-
+
return data.global_transform;
}
#if 0
@@ -290,7 +290,7 @@ void Spatial::add_child_notify(Node *p_child) {
Spatial *s=p_child->cast_to<Spatial>();
if (!s)
return;
-
+
ERR_FAIL_COND(data.children_lock>0);
s->data.dirty=DIRTY_GLOBAL; // don't allow global transform to be valid
@@ -305,12 +305,12 @@ void Spatial::remove_child_notify(Node *p_child) {
Spatial *s=p_child->cast_to<Spatial>();
if (!s)
return;
-
+
ERR_FAIL_COND(data.children_lock>0);
-
+
if (s->data.C)
data.children.erase(s->data.C);
- s->data.parent=NULL;
+ s->data.parent=NULL;
s->data.C=NULL;
*/
}
@@ -595,11 +595,11 @@ bool Spatial::is_hidden() const{
}
void Spatial::set_hidden(bool p_hidden) {
-
+
if (data.visible != p_hidden) {
return;
}
-
+
_set_visible_(!p_hidden);
}
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index 23f1c6d103..50123b2d81 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -57,7 +57,7 @@ class Spatial : public Node {
OBJ_TYPE( Spatial, Node );
OBJ_CATEGORY("3D");
-
+
enum TransformDirty {
DIRTY_NONE=0,
DIRTY_VECTORS=1,
@@ -68,7 +68,7 @@ class Spatial : public Node {
mutable SelfList<Node> xform_change;
struct Data {
-
+
mutable Transform global_transform;
@@ -84,12 +84,12 @@ class Spatial : public Node {
bool toplevel_active;
bool toplevel;
bool inside_world;
-
+
int children_lock;
Spatial *parent;
List<Spatial*> children;
List<Spatial*>::Element *C;
-
+
bool ignore_notification;
bool notify_local_transform;
@@ -130,7 +130,7 @@ protected:
public:
enum {
-
+
NOTIFICATION_TRANSFORM_CHANGED=SceneTree::NOTIFICATION_TRANSFORM_CHANGED,
NOTIFICATION_ENTER_WORLD=41,
NOTIFICATION_EXIT_WORLD=42,
@@ -153,7 +153,7 @@ public:
void set_transform(const Transform& p_transform);
void set_global_transform(const Transform& p_transform);
-
+
Transform get_transform() const;
Transform get_global_transform() const;
@@ -198,7 +198,7 @@ public:
Transform get_import_transform() const;
#endif
- Spatial();
+ Spatial();
~Spatial();
};
diff --git a/scene/3d/spatial_sample_player.h b/scene/3d/spatial_sample_player.h
index 9b3220458e..037cdc906a 100644
--- a/scene/3d/spatial_sample_player.h
+++ b/scene/3d/spatial_sample_player.h
@@ -47,7 +47,7 @@ public:
typedef int VoiceID;
-private:
+private:
Ref<SampleLibrary> library;
int polyphony;
diff --git a/scene/3d/test_cube.h b/scene/3d/test_cube.h
index 21f2b3c794..332276ab89 100644
--- a/scene/3d/test_cube.h
+++ b/scene/3d/test_cube.h
@@ -42,14 +42,14 @@ class TestCube : public GeometryInstance {
OBJ_TYPE( TestCube, GeometryInstance );
RID instance;
-
+
public:
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- TestCube();
+ TestCube();
~TestCube();
};
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 723b0a9af5..b15226cce3 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -267,6 +267,15 @@ void GeometryInstance::_update_visibility() {
void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
ERR_FAIL_INDEX(p_flag,FLAG_MAX);
+ if (p_flag==FLAG_CAST_SHADOW) {
+ if (p_value == true) {
+ set_cast_shadows_setting(SHADOW_CASTING_SETTING_ON);
+ }
+ else {
+ set_cast_shadows_setting(SHADOW_CASTING_SETTING_OFF);
+ }
+ }
+
if (flags[p_flag]==p_value)
return;
@@ -294,10 +303,32 @@ void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
bool GeometryInstance::get_flag(Flags p_flag) const{
ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+
+ if (p_flag == FLAG_CAST_SHADOW) {
+ if (shadow_casting_setting == SHADOW_CASTING_SETTING_OFF) {
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
return flags[p_flag];
}
+void GeometryInstance::set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting) {
+
+ shadow_casting_setting = p_shadow_casting_setting;
+
+ VS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (VS::ShadowCastingSetting)p_shadow_casting_setting);
+}
+
+GeometryInstance::ShadowCastingSetting GeometryInstance::get_cast_shadows_setting() const {
+
+ return shadow_casting_setting;
+}
+
void GeometryInstance::set_baked_light_texture_id(int p_id) {
baked_light_texture_id=p_id;
@@ -330,6 +361,9 @@ void GeometryInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_flag","flag","value"), &GeometryInstance::set_flag);
ObjectTypeDB::bind_method(_MD("get_flag","flag"), &GeometryInstance::get_flag);
+ ObjectTypeDB::bind_method(_MD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance::set_cast_shadows_setting);
+ ObjectTypeDB::bind_method(_MD("get_cast_shadows_setting"), &GeometryInstance::get_cast_shadows_setting);
+
ObjectTypeDB::bind_method(_MD("set_draw_range_begin","mode"), &GeometryInstance::set_draw_range_begin);
ObjectTypeDB::bind_method(_MD("get_draw_range_begin"), &GeometryInstance::get_draw_range_begin);
@@ -346,7 +380,7 @@ void GeometryInstance::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE);
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "geometry/material_override",PROPERTY_HINT_RESOURCE_TYPE,"Material"), _SCS("set_material_override"), _SCS("get_material_override"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/cast_shadow"), _SCS("set_flag"), _SCS("get_flag"),FLAG_CAST_SHADOW);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry/cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), _SCS("set_cast_shadows_setting"), _SCS("get_cast_shadows_setting"));
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/receive_shadows"), _SCS("set_flag"), _SCS("get_flag"),FLAG_RECEIVE_SHADOWS);
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_begin",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_begin"), _SCS("get_draw_range_begin"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_end",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_end"), _SCS("get_draw_range_end"));
@@ -369,6 +403,11 @@ void GeometryInstance::_bind_methods() {
BIND_CONSTANT(FLAG_VISIBLE_IN_ALL_ROOMS );
BIND_CONSTANT(FLAG_MAX );
+ BIND_CONSTANT(SHADOW_CASTING_SETTING_OFF);
+ BIND_CONSTANT(SHADOW_CASTING_SETTING_ON);
+ BIND_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);
+ BIND_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
+
}
GeometryInstance::GeometryInstance() {
@@ -381,6 +420,7 @@ GeometryInstance::GeometryInstance() {
flags[FLAG_VISIBLE]=true;
flags[FLAG_CAST_SHADOW]=true;
flags[FLAG_RECEIVE_SHADOWS]=true;
+ shadow_casting_setting=SHADOW_CASTING_SETTING_ON;
baked_light_instance=NULL;
baked_light_texture_id=0;
extra_cull_margin=0;
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index e49f4fb82f..e286d5fa88 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -65,7 +65,7 @@ public:
RID get_instance() const;
virtual AABB get_aabb() const=0;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const=0;
-
+
virtual AABB get_transformed_aabb() const; // helper
void set_base(const RID& p_base);
@@ -74,7 +74,7 @@ public:
uint32_t get_layer_mask() const;
- VisualInstance();
+ VisualInstance();
~VisualInstance();
};
@@ -98,10 +98,17 @@ public:
FLAG_MAX=VS::INSTANCE_FLAG_MAX,
};
+ enum ShadowCastingSetting {
+ SHADOW_CASTING_SETTING_OFF=VS::SHADOW_CASTING_SETTING_OFF,
+ SHADOW_CASTING_SETTING_ON = VS::SHADOW_CASTING_SETTING_ON,
+ SHADOW_CASTING_SETTING_DOUBLE_SIDED=VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED,
+ SHADOW_CASTING_SETTING_SHADOWS_ONLY=VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY
+ };
private:
bool flags[FLAG_MAX];
+ ShadowCastingSetting shadow_casting_setting;
Ref<Material> material_override;
float draw_begin;
float draw_end;
@@ -121,6 +128,9 @@ public:
void set_flag(Flags p_flag,bool p_value);
bool get_flag(Flags p_flag) const;
+ void set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting);
+ ShadowCastingSetting get_cast_shadows_setting() const;
+
void set_draw_range_begin(float p_dist);
float get_draw_range_begin() const;
@@ -140,5 +150,7 @@ public:
};
VARIANT_ENUM_CAST( GeometryInstance::Flags );
+VARIANT_ENUM_CAST( GeometryInstance::ShadowCastingSetting );
+
#endif