summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-02-15 08:29:46 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-02-15 08:34:02 -0300
commitda11d6d9e868db674cb18ced0544c84e3356be8d (patch)
treecfc9ce1235e34c0fee160e00c340a1163474a024 /scene
parentd7fd86d51aadda665667c88dca657993f0de14d7 (diff)
Many fixes to make exported scenes work better, still buggy.
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/canvas_item.cpp4
-rw-r--r--scene/2d/collision_object_2d.cpp2
-rw-r--r--scene/3d/collision_object.cpp1
-rw-r--r--scene/3d/gi_probe.cpp47
-rw-r--r--scene/resources/mesh.cpp4
-rw-r--r--scene/resources/packed_scene.cpp4
-rw-r--r--scene/resources/texture.cpp6
-rw-r--r--scene/resources/texture.h4
8 files changed, 62 insertions, 10 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 3574a39940..4f7acf7f97 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -747,12 +747,12 @@ float CanvasItem::draw_char(const Ref<Font>& p_font,const Point2& p_pos, const S
void CanvasItem::_notify_transform(CanvasItem *p_node) {
- if (p_node->xform_change.in_list() && p_node->global_invalid)
+ if (/*p_node->xform_change.in_list() &&*/ p_node->global_invalid)
return; //nothing to do
p_node->global_invalid=true;
- if (notify_transform && !p_node->xform_change.in_list()) {
+ if (p_node->notify_transform && !p_node->xform_change.in_list()) {
if (!p_node->block_transform_notify) {
if (p_node->is_inside_tree())
get_tree()->xform_change_list.add(&p_node->xform_change);
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 7b935e0d59..f9e1cc0bd7 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -348,6 +348,8 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
rid=p_rid;
area=p_area;
pickable=true;
+ set_notify_transform(true);
+
if (p_area) {
Physics2DServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID());
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 09fe7cd2fc..32e60f0d57 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -334,6 +334,7 @@ CollisionObject::CollisionObject(RID p_rid, bool p_area) {
area=p_area;
capture_input_on_drag=false;
ray_pickable=true;
+ set_notify_transform(true);
if (p_area) {
PhysicsServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID());
} else {
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 4ce714818f..1d40202318 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -527,10 +527,16 @@ void GIProbe::_plot_face(int p_idx, int p_level,int p_x,int p_y,int p_z, const V
Vector3 c;
Vector3 inters;
Geometry::get_closest_points_between_segments(p_vtx[j],p_vtx[(j+1)%3],ray_from,ray_to,inters,c);
- float d=c.distance_to(intersection);
- if (j==0 || d<closest_dist) {
- closest_dist=d;
+ if (c==inters) {
+ closest_dist=0;
intersection=inters;
+
+ } else {
+ float d=c.distance_to(intersection);
+ if (j==0 || d<closest_dist) {
+ closest_dist=d;
+ intersection=inters;
+ }
}
}
}
@@ -856,6 +862,10 @@ Vector<Color> GIProbe::_get_bake_texture(Image &p_image,const Color& p_color) {
return ret;
}
+ if (p_image.is_compressed()) {
+ print_line("DECOMPRESSING!!!!");
+ p_image.decompress();
+ }
p_image.convert(Image::FORMAT_RGBA8);
p_image.resize(bake_texture_size,bake_texture_size,Image::INTERPOLATE_CUBIC);
@@ -892,13 +902,14 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
if (mat.is_valid()) {
-
- Ref<ImageTexture> albedo_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_ALBEDO);
+ Ref<Texture> albedo_tex = mat->get_texture(FixedSpatialMaterial::TEXTURE_ALBEDO);
Image img_albedo;
if (albedo_tex.is_valid()) {
img_albedo = albedo_tex->get_data();
+ } else {
+
}
mc.albedo=_get_bake_texture(img_albedo,mat->get_albedo());
@@ -950,6 +961,7 @@ void GIProbe::_plot_mesh(const Transform& p_xform, Ref<Mesh>& p_mesh, Baker *p_b
src_material=p_materials[i];
} else {
src_material=p_mesh->surface_get_material(i);
+
}
Baker::MaterialCache material = _get_material_cache(src_material,p_baker);
@@ -1056,6 +1068,31 @@ void GIProbe::_find_meshes(Node *p_at_node,Baker *p_baker){
}
}
+ if (p_at_node->cast_to<Spatial>()) {
+
+ Spatial *s = p_at_node->cast_to<Spatial>();
+ Array meshes = p_at_node->call("get_meshes");
+ for(int i=0;i<meshes.size();i+=2) {
+
+ Transform mxf = meshes[i];
+ Ref<Mesh> mesh = meshes[i+1];
+ if (!mesh.is_valid())
+ continue;
+
+ Rect3 aabb = mesh->get_aabb();
+
+ Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
+
+ if (Rect3(-extents,extents*2).intersects(xf.xform(aabb))) {
+ Baker::PlotMesh pm;
+ pm.local_xform=xf;
+ pm.mesh=mesh;
+ p_baker->mesh_list.push_back(pm);
+
+ }
+ }
+ }
+
for(int i=0;i<p_at_node->get_child_count();i++) {
Node *child = p_at_node->get_child(i);
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 03d516329a..9990a6e796 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -128,8 +128,8 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
if (d.has("arrays")) {
//old format
- ERR_FAIL_COND_V(!d.has("blend_shape_arrays"),false);
- add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["blend_shape_arrays"]);
+ ERR_FAIL_COND_V(!d.has("morph_arrays"),false);
+ add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"]);
} else if (d.has("array_data")) {
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index ce755d90db..17688c366a 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -177,6 +177,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
node = obj->cast_to<Node>();
+ } else {
+ print_line("wtf class is disabled for: "+itos(n.type));
+ print_line("name: "+String(snames[n.type]));
}
@@ -196,6 +199,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
ERR_FAIL_INDEX_V( nprops[j].name, sname_count, NULL );
ERR_FAIL_INDEX_V( nprops[j].value, prop_count, NULL );
+
if (snames[ nprops[j].name ]==CoreStringNames::get_singleton()->_script) {
//work around to avoid old script variables from disappearing, should be the proper fix to:
//https://github.com/godotengine/godot/issues/2958
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 5e67a9e5b2..e3a856ad4f 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -754,6 +754,12 @@ bool StreamTexture::has_alpha() const {
return false;
}
+
+Image StreamTexture::get_data() const {
+
+ return VS::get_singleton()->texture_get_data(texture);
+}
+
void StreamTexture::set_flags(uint32_t p_flags){
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index f684aeb658..cae77ad5cf 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -76,7 +76,7 @@ public:
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const;
-
+ virtual Image get_data() const { return Image(); }
Texture();
};
@@ -224,6 +224,8 @@ public:
virtual bool has_alpha() const;
virtual void set_flags(uint32_t p_flags);
+ virtual Image get_data() const;
+
StreamTexture();
~StreamTexture();