summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/baked_light_instance.cpp10
-rw-r--r--scene/3d/baked_light_instance.h2
-rw-r--r--scene/3d/immediate_geometry.cpp10
-rw-r--r--scene/3d/immediate_geometry.h6
4 files changed, 23 insertions, 5 deletions
diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp
index fafa62866f..ca3a309568 100644
--- a/scene/3d/baked_light_instance.cpp
+++ b/scene/3d/baked_light_instance.cpp
@@ -60,6 +60,8 @@ void BakedLightInstance::set_baked_light(const Ref<BakedLight>& p_baked_light) {
// VS::get_singleton()->instance_geometry_set_baked_light(E->get()->get_instance(),baked_light.is_valid()?get_instance():RID());
// }
}
+
+ update_configuration_warning();
}
Ref<BakedLight> BakedLightInstance::get_baked_light() const{
@@ -77,6 +79,14 @@ DVector<Face3> BakedLightInstance::get_faces(uint32_t p_usage_flags) const {
}
+String BakedLightInstance::get_configuration_warning() const {
+ if (get_baked_light().is_null()) {
+ return TTR("BakedLightInstance does not contain a BakedLight resource.");
+ }
+ return String();
+}
+
+
void BakedLightInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_baked_light","baked_light"),&BakedLightInstance::set_baked_light);
diff --git a/scene/3d/baked_light_instance.h b/scene/3d/baked_light_instance.h
index 92c2d50986..002e55df1d 100644
--- a/scene/3d/baked_light_instance.h
+++ b/scene/3d/baked_light_instance.h
@@ -55,6 +55,8 @@ public:
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ String get_configuration_warning() const;
+
BakedLightInstance();
};
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index 4964582be4..c9319904bd 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -102,7 +102,7 @@ DVector<Face3> ImmediateGeometry::get_faces(uint32_t p_usage_flags) const {
-void ImmediateGeometry::add_sphere(int p_lats,int p_lons,float p_radius) {
+void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) {
for(int i = 1; i <= p_lats; i++) {
double lat0 = Math_PI * (-0.5 + (double) (i - 1) / p_lats);
@@ -132,6 +132,10 @@ void ImmediateGeometry::add_sphere(int p_lats,int p_lons,float p_radius) {
};
#define ADD_POINT(m_idx)\
+ if (p_add_uv) {\
+ set_uv(Vector2(Math::atan2(v[m_idx].x,v[m_idx].z)/Math_PI * 0.5+0.5,v[m_idx].y*0.5+0.5));\
+ set_tangent(Plane(Vector3(-v[m_idx].z,v[m_idx].y,v[m_idx].x),1)); \
+ }\
set_normal(v[m_idx]);\
add_vertex(v[m_idx]*p_radius);
@@ -149,14 +153,14 @@ void ImmediateGeometry::add_sphere(int p_lats,int p_lons,float p_radius) {
void ImmediateGeometry::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("begin","primitive","texture:Texture"),&ImmediateGeometry::begin);
+ ObjectTypeDB::bind_method(_MD("begin","primitive","texture:Texture"),&ImmediateGeometry::begin,DEFVAL(Ref<Texture>()));
ObjectTypeDB::bind_method(_MD("set_normal","normal"),&ImmediateGeometry::set_normal);
ObjectTypeDB::bind_method(_MD("set_tangent","tangent"),&ImmediateGeometry::set_tangent);
ObjectTypeDB::bind_method(_MD("set_color","color"),&ImmediateGeometry::set_color);
ObjectTypeDB::bind_method(_MD("set_uv","uv"),&ImmediateGeometry::set_uv);
ObjectTypeDB::bind_method(_MD("set_uv2","uv"),&ImmediateGeometry::set_uv2);
ObjectTypeDB::bind_method(_MD("add_vertex","pos"),&ImmediateGeometry::add_vertex);
- ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius"),&ImmediateGeometry::add_sphere);
+ ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius","add_uv"),&ImmediateGeometry::add_sphere,DEFVAL(true));
ObjectTypeDB::bind_method(_MD("end"),&ImmediateGeometry::end);
ObjectTypeDB::bind_method(_MD("clear"),&ImmediateGeometry::clear);
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h
index 28b5735ca8..fc7f4de634 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry.h
@@ -38,6 +38,8 @@ class ImmediateGeometry : public GeometryInstance {
RID im;
+ //a list of texures drawn need to be kept, to avoid references
+ // in VisualServer from becoming invalid if the texture is no longer used
List<Ref<Texture> > cached_textures;
bool empty;
AABB aabb;
@@ -47,7 +49,7 @@ protected:
public:
- void begin(Mesh::PrimitiveType p_primitive,const Ref<Texture>& p_texture);
+ void begin(Mesh::PrimitiveType p_primitive,const Ref<Texture>& p_texture=Ref<Texture>());
void set_normal(const Vector3& p_normal);
void set_tangent(const Plane& p_tangent);
void set_color(const Color& p_color);
@@ -60,7 +62,7 @@ public:
void clear();
- void add_sphere(int p_lats,int p_lons,float p_radius);
+ void add_sphere(int p_lats,int p_lons,float p_radius,bool p_add_uv=true);