summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/class_db.cpp2
-rw-r--r--core/io/resource_format_binary.cpp49
-rw-r--r--core/io/resource_format_binary.h2
-rw-r--r--core/io/resource_import.cpp6
-rw-r--r--core/io/resource_loader.cpp8
-rw-r--r--core/math/geometry.h28
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp6
-rw-r--r--modules/gridmap/config.py3
-rw-r--r--modules/gridmap/grid_map.cpp535
-rw-r--r--modules/gridmap/grid_map.h22
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp92
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h9
-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
-rw-r--r--servers/physics_2d/space_2d_sw.cpp6
-rw-r--r--servers/visual_server.cpp2
22 files changed, 238 insertions, 604 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 2eff8c07c7..76c2f0633a 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -1256,7 +1256,7 @@ void ClassDB::get_extensions_for_type(const StringName& p_class,List<String> *p_
while((K=resource_base_extensions.next(K))) {
StringName cmp = resource_base_extensions[*K];
- if (is_parent_class(cmp,p_class))
+ if (is_parent_class(p_class,cmp))
p_extensions->push_back(*K);
}
}
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index c75e476764..2c02dbcc9b 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -98,6 +98,27 @@ void ResourceInteractiveLoaderBinary::_advance_padding(uint32_t p_len) {
}
+
+StringName ResourceInteractiveLoaderBinary::_get_string() {
+
+ uint32_t id = f->get_32();
+ if (id&0x80000000) {
+ uint32_t len = id&0x7FFFFFFF;
+ if (len>str_buf.size()) {
+ str_buf.resize(len);
+ }
+ if (len==0)
+ return StringName();
+ f->get_buffer((uint8_t*)&str_buf[0],len);
+ String s;
+ s.parse_utf8(&str_buf[0]);
+ return s;
+ }
+
+ return string_map[id];
+
+}
+
Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
@@ -272,8 +293,8 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
Image::Format fmt=Image::Format(format&format_version_mask); //if format changes, we can add a compatibility bit on top
-
uint32_t datalen = f->get_32();
+ print_line("image format: "+String(Image::get_format_name(fmt))+" datalen "+itos(datalen));
PoolVector<uint8_t> imgdata;
imgdata.resize(datalen);
@@ -282,6 +303,14 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
_advance_padding(datalen);
w=PoolVector<uint8_t>::Write();
+#ifdef TOOLS_ENABLED
+//compatibility
+ int correct_size = Image::get_image_data_size(width,height,fmt,mipmaps?-1:0);
+ if (correct_size < datalen) {
+ WARN_PRINT("Image data was too large, shrinking for compatibility")
+ imgdata.resize(correct_size);
+ }
+#endif
r_v=Image(width,height,mipmaps,fmt,imgdata);
} else {
@@ -323,10 +352,10 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) {
for(int i=0;i<name_count;i++)
- names.push_back(string_map[f->get_32()]);
+ names.push_back(_get_string());
for(uint32_t i=0;i<subname_count;i++)
- subnames.push_back(string_map[f->get_32()]);
- property=string_map[f->get_32()];
+ subnames.push_back(_get_string());
+ property=_get_string();
NodePath np = NodePath(names,subnames,absolute,property);
//print_line("got path: "+String(np));
@@ -641,6 +670,8 @@ Error ResourceInteractiveLoaderBinary::poll(){
if (s<external_resources.size()) {
String path = external_resources[s].path;
+
+ print_line("load external res: "+path);
if (remaps.has(path)) {
path=remaps[path];
}
@@ -711,6 +742,8 @@ Error ResourceInteractiveLoaderBinary::poll(){
String t = get_unicode_string();
+// print_line("loading resource of type "+t+" path is "+path);
+
Object *obj = ClassDB::instance(t);
if (!obj) {
error=ERR_FILE_CORRUPT;
@@ -737,8 +770,8 @@ Error ResourceInteractiveLoaderBinary::poll(){
for(int i=0;i<pc;i++) {
- uint32_t name_idx = f->get_32();
- if (name_idx>=(uint32_t)string_map.size()) {
+ StringName name = _get_string();
+ if (name==StringName()) {
error=ERR_FILE_CORRUPT;
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
@@ -749,7 +782,7 @@ Error ResourceInteractiveLoaderBinary::poll(){
if (error)
return error;
- res->set(string_map[name_idx],value);
+ res->set(name,value);
}
#ifdef TOOLS_ENABLED
res->set_edited(false);
@@ -2143,6 +2176,8 @@ void ResourceFormatSaverBinary::get_recognized_extensions(const RES& p_resource,
String base = p_resource->get_base_extension().to_lower();
p_extensions->push_back(base);
+ if (base!="res")
+ p_extensions->push_back("res");
}
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index 1dac51cc5c..1fab6144d5 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -54,6 +54,8 @@ class ResourceInteractiveLoaderBinary : public ResourceInteractiveLoader {
//Map<int,StringName> string_map;
Vector<StringName> string_map;
+ StringName _get_string();
+
struct ExtResoucre {
String path;
String type;
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
index 556dff3125..892c2988dc 100644
--- a/core/io/resource_import.cpp
+++ b/core/io/resource_import.cpp
@@ -81,8 +81,10 @@ RES ResourceFormatImporter::load(const String &p_path,const String& p_original_p
RES res = ResourceLoader::load(pat.path,pat.type,false,r_error);
#ifdef TOOLS_ENABLED
- res->set_import_last_modified_time( res->get_last_modified_time() ); //pass this, if used
- res->set_import_path(pat.path);
+ if (res.is_valid()) {
+ res->set_import_last_modified_time( res->get_last_modified_time() ); //pass this, if used
+ res->set_import_path(pat.path);
+ }
#endif
return res;
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 3199f05ff8..b6d28bccfa 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -61,6 +61,7 @@ bool ResourceFormatLoader::recognize_path(const String& p_path,const String& p_f
for (List<String>::Element *E=extensions.front();E;E=E->next()) {
+
if (E->get().nocasecmp_to(extension)==0)
return true;
}
@@ -191,12 +192,15 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p
for (int i=0;i<loader_count;i++) {
- if (!loader[i]->recognize_path(local_path,p_type_hint))
+ if (!loader[i]->recognize_path(local_path,p_type_hint)) {
+ print_line("path not recognized");
continue;
+ }
found=true;
RES res = loader[i]->load(local_path,local_path,r_error);
- if (res.is_null())
+ if (res.is_null()) {
continue;
+ }
if (!p_no_cache)
res->set_path(local_path);
#ifdef TOOLS_ENABLED
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 13cbbdce6f..1dd7df038d 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -109,6 +109,7 @@ public:
static void get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2,Vector3& c1, Vector3& c2)
{
+#if 0
//do the function 'd' as defined by pb. I think is is dot product of some sort
#define d_of(m,n,o,p) ( (m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z) )
@@ -123,6 +124,33 @@ public:
if (mub > 1) mub = 1;
c1 = p1.linear_interpolate(p2,mua);
c2 = q1.linear_interpolate(q2,mub);
+#endif
+
+ Vector3 u = p2 - p1;
+ Vector3 v = q2 - q1;
+ Vector3 w = p1 - q1;
+ float a = u.dot(u);
+ float b = u.dot(v);
+ float c = v.dot(v); // always >= 0
+ float d = u.dot(w);
+ float e = v.dot(w);
+ float D = a*c - b*b; // always >= 0
+ float sc, tc;
+
+ // compute the line parameters of the two closest points
+ if (D < CMP_EPSILON) { // the lines are almost parallel
+ sc = 0.0;
+ tc = (b>c ? d/b : e/c); // use the largest denominator
+ }
+ else {
+ sc = (b*e - c*d) / D;
+ tc = (a*e - b*d) / D;
+ }
+
+ c1 = w + sc * u;
+ c2 = w + tc * v;
+ // get the difference of the two closest points
+ //Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc)
}
static real_t get_closest_distance_between_segments( const Vector3& p_from_a,const Vector3& p_to_a, const Vector3& p_from_b,const Vector3& p_to_b) {
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index b504ef819f..a0d486661b 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -1386,6 +1386,7 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
int amount = MAX(multi_mesh->size,multi_mesh->visible_instances);
+
if (s->index_array_len>0) {
glDrawElementsInstanced(gl_primitive[s->primitive],s->index_array_len, (s->array_len>=(1<<16))?GL_UNSIGNED_INT:GL_UNSIGNED_SHORT,0,amount);
@@ -1746,6 +1747,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
RasterizerStorageGLES3::Material* prev_material=NULL;
RasterizerStorageGLES3::Geometry* prev_geometry=NULL;
+ RasterizerStorageGLES3::GeometryOwner* prev_owner=NULL;
VS::InstanceType prev_base_type = VS::INSTANCE_MAX;
int current_blend_mode=-1;
@@ -1765,6 +1767,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
RasterizerStorageGLES3::Material* material= e->material;
RID skeleton = e->instance->skeleton;
+
bool rebind=first;
int shading = (e->sort_key>>RenderList::SORT_KEY_SHADING_SHIFT)&RenderList::SORT_KEY_SHADING_MASK;
@@ -1934,7 +1937,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
}
- if (prev_base_type != e->instance->base_type || prev_geometry!=e->geometry) {
+ if (e->owner != prev_owner || prev_base_type != e->instance->base_type || prev_geometry!=e->geometry) {
_setup_geometry(e);
storage->info.render_surface_switch_count++;
@@ -1952,6 +1955,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
prev_material=material;
prev_base_type=e->instance->base_type;
prev_geometry=e->geometry;
+ prev_owner=e->owner;
prev_shading=shading;
prev_skeleton=skeleton;
first=false;
diff --git a/modules/gridmap/config.py b/modules/gridmap/config.py
index 1ab13c4aeb..5698a37295 100644
--- a/modules/gridmap/config.py
+++ b/modules/gridmap/config.py
@@ -1,8 +1,7 @@
def can_build(platform):
- # FIXME: Disabled temporary for gles3 implementation
- return False
+ return True
def configure(env):
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 1e6bd11154..d4fb174bfe 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -31,7 +31,7 @@
#include "scene/resources/surface_tool.h"
#include "message_queue.h"
#include "scene/3d/light.h"
-#include "scene/3d/baked_light_instance.h"
+
#include "io/marshalls.h"
#include "scene/scene_string_names.h"
#include "os/os.h"
@@ -41,25 +41,21 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) {
String name=p_name;
- if (name=="theme/theme") {
+ if (name=="theme") {
set_theme(p_value);
- } else if (name=="cell/size") {
+ } else if (name=="cell_size") {
set_cell_size(p_value);
- } else if (name=="cell/octant_size") {
+ } else if (name=="cell_octant_size") {
set_octant_size(p_value);
- } else if (name=="cell/center_x") {
+ } else if (name=="cell_center_x") {
set_center_x(p_value);
- } else if (name=="cell/center_y") {
+ } else if (name=="cell_center_y") {
set_center_y(p_value);
- } else if (name=="cell/center_z") {
+ } else if (name=="cell_center_z") {
set_center_z(p_value);
- } else if (name=="cell/scale") {
+ } else if (name=="cell_scale") {
set_cell_scale(p_value);
- } else if (name=="lighting/bake") {
- set_use_baked_light(p_value);
- } else if (name=="theme/bake") {
- set_bake(p_value);
/* } else if (name=="cells") {
PoolVector<int> cells = p_value;
int amount=cells.size();
@@ -81,9 +77,6 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) {
Dictionary d = p_value;
- Dictionary baked;
- if (d.has("baked"))
- baked=d["baked"];
if (d.has("cells")) {
PoolVector<int> cells = d["cells"];
@@ -101,33 +94,7 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) {
}
}
- baked_lock=baked.size()!=0;
_recreate_octant_data();
- baked_lock=false;
- if (!baked.empty()) {
- List<Variant> kl;
- baked.get_key_list(&kl);
- for (List<Variant>::Element *E=kl.front();E;E=E->next()) {
-
- Plane ikv = E->get();
- Ref<Mesh> b=baked[ikv];
- ERR_CONTINUE(!b.is_valid());
- OctantKey ok;
- ok.x=ikv.normal.x;
- ok.y=ikv.normal.y;
- ok.z=ikv.normal.z;
- ok.area=ikv.d;
-
- ERR_CONTINUE(!octant_map.has(ok));
-
- Octant &g = *octant_map[ok];
-
- g.baked=b;
- g.bake_instance=VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(g.bake_instance,g.baked->get_rid());
- VS::get_singleton()->instance_geometry_set_baked_light(g.bake_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID());
- }
- }
} else if (name.begins_with("areas/")) {
@@ -161,24 +128,20 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const {
String name=p_name;
- if (name=="theme/theme") {
+ if (name=="theme") {
r_ret= get_theme();
- } else if (name=="cell/size") {
+ } else if (name=="cell_size") {
r_ret= get_cell_size();
- } else if (name=="cell/octant_size") {
+ } else if (name=="cell_octant_size") {
r_ret= get_octant_size();
- } else if (name=="cell/center_x") {
+ } else if (name=="cell_center_x") {
r_ret= get_center_x();
- } else if (name=="cell/center_y") {
+ } else if (name=="cell_center_y") {
r_ret= get_center_y();
- } else if (name=="cell/center_z") {
+ } else if (name=="cell_center_z") {
r_ret= get_center_z();
- } else if (name=="cell/scale") {
+ } else if (name=="cell_scale") {
r_ret= cell_scale;
- } else if (name=="lighting/bake") {
- r_ret=is_using_baked_light();
- } else if (name=="theme/bake") {
- r_ret= bake;
} else if (name=="data") {
Dictionary d;
@@ -197,23 +160,8 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const {
d["cells"]=cells;
- Dictionary baked;
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
-
- Octant &g=*E->get();
-
- if (g.baked.is_valid()) {
-
- baked[Plane(E->key().x,E->key().y,E->key().z,E->key().area)]=g.baked;
- }
- }
-
- if (baked.size()) {
- d["baked"]=baked;
- }
-
r_ret= d;
} else if (name.begins_with("areas/")) {
int which = name.get_slicec('/',1).to_int();
@@ -237,15 +185,14 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const {
void GridMap::_get_property_list( List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo( Variant::OBJECT, "theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "theme/bake"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "lighting/bake"));
- p_list->push_back( PropertyInfo( Variant::REAL, "cell/size",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
- p_list->push_back( PropertyInfo( Variant::INT, "cell/octant_size",PROPERTY_HINT_RANGE,"1,1024,1") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_x") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_y") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "cell/center_z") );
- p_list->push_back( PropertyInfo( Variant::REAL, "cell/scale") );
+ p_list->push_back( PropertyInfo( Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"));
+ p_list->push_back( PropertyInfo( Variant::NIL, "Cell", PROPERTY_HINT_NONE,"cell_",PROPERTY_USAGE_GROUP));
+ p_list->push_back( PropertyInfo( Variant::REAL, "cell_size",PROPERTY_HINT_RANGE,"0.01,16384,0.01") );
+ p_list->push_back( PropertyInfo( Variant::INT, "cell_octant_size",PROPERTY_HINT_RANGE,"1,1024,1") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_x") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_y") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "cell_center_z") );
+ p_list->push_back( PropertyInfo( Variant::REAL, "cell_scale") );
p_list->push_back( PropertyInfo( Variant::DICTIONARY, "data", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE) );
@@ -380,17 +327,6 @@ void GridMap::set_cell_item(int p_x,int p_y,int p_z, int p_item,int p_rot){
g.items.erase(prev_item);
}
-
- if (g.items.empty() || !baked_lock) {
- //unbake just in case
- if (g.baked.is_valid()) {
- VS::get_singleton()->free(g.bake_instance);
- g.bake_instance=RID();
- g.baked=Ref<Mesh>();
- }
-
-
- }
if (g.items.empty()) {
PhysicsServer::get_singleton()->free(g.static_body);
@@ -454,24 +390,12 @@ void GridMap::set_cell_item(int p_x,int p_y,int p_z, int p_item,int p_rot){
ii.navmesh=theme->get_item_navmesh(p_item);
}
ii.multimesh = Ref<MultiMesh>( memnew( MultiMesh ) );
+ ii.multimesh->set_color_format(MultiMesh::COLOR_NONE);
+ ii.multimesh->set_transform_format(MultiMesh::TRANSFORM_3D);
ii.multimesh->set_mesh(ii.mesh);
ii.multimesh_instance = VS::get_singleton()->instance_create();
VS::get_singleton()->instance_set_base(ii.multimesh_instance,ii.multimesh->get_rid());
- VS::get_singleton()->instance_geometry_set_baked_light(ii.multimesh_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID());
-
- if (!baked_lock) {
- //unbake just in case
- if (g.bake_instance.is_valid())
- VS::get_singleton()->free(g.bake_instance);
- g.baked=Ref<Mesh>();
- if (is_inside_world()) {
- VS::get_singleton()->instance_set_scenario(ii.multimesh_instance,get_world()->get_scenario());
- if (ok.area) {
- VS::get_singleton()->instance_set_room( ii.multimesh_instance,area_map[ok.area]->instance);
- }
- }
- }
g.items[p_item]=ii;
}
@@ -585,27 +509,14 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
VS::get_singleton()->instance_set_room(g.collision_debug_instance,area_map[p_key.area]->instance);
}
}
- if (g.baked.is_valid()) {
+ for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
- Transform xf = get_global_transform();
- xf.translate(_octant_get_offset(p_key));
+ VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance,get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
+ //print_line("INSTANCEPOS: "+get_global_transform());
- VS::get_singleton()->instance_set_transform(g.bake_instance,xf);
- VS::get_singleton()->instance_set_scenario(g.bake_instance,get_world()->get_scenario());
if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(g.bake_instance,area_map[p_key.area]->instance);
-
- }
- } else {
- for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
-
- VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance,get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
- //print_line("INSTANCEPOS: "+get_global_transform());
-
- if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(E->get().multimesh_instance,area_map[p_key.area]->instance);
- }
+ VS::get_singleton()->instance_set_room(E->get().multimesh_instance,area_map[p_key.area]->instance);
}
}
}
@@ -621,17 +532,10 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
VS::get_singleton()->instance_set_transform(g.collision_debug_instance,get_global_transform());
}
- if (g.baked.is_valid()) {
-
- Transform xf = get_global_transform();
- xf.origin+=_octant_get_offset(p_key);
- VS::get_singleton()->instance_set_transform(g.bake_instance,xf);
- } else {
- for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
+ for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
- VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
- //print_line("UPDATEPOS: "+get_global_transform());
- }
+ VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
+ //print_line("UPDATEPOS: "+get_global_transform());
}
}
@@ -711,7 +615,7 @@ void GridMap::_octant_update(const OctantKey &p_key) {
ii.multimesh->set_instance_transform(idx,xform);
//ii.multimesh->set_instance_transform(idx,Transform() );
- ii.multimesh->set_instance_color(idx,Color(1,1,1,1));
+ //ii.multimesh->set_instance_color(idx,Color(1,1,1,1));
//print_line("MMINST: "+xform);
@@ -748,7 +652,7 @@ void GridMap::_octant_update(const OctantKey &p_key) {
idx++;
}
- ii.multimesh->set_aabb(aabb);
+ //ii.multimesh->set_aabb(aabb);
}
@@ -760,7 +664,7 @@ void GridMap::_octant_update(const OctantKey &p_key) {
arr.resize(VS::ARRAY_MAX);
arr[VS::ARRAY_VERTEX]=col_debug;
- VS::get_singleton()->mesh_add_surface(g.collision_debug,VS::PRIMITIVE_LINES,arr);
+ VS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug,VS::PRIMITIVE_LINES,arr);
SceneTree *st=SceneTree::get_singleton();
if (st) {
VS::get_singleton()->mesh_surface_set_material( g.collision_debug, 0,st->get_debug_collision_material()->get_rid() );
@@ -780,13 +684,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
PhysicsServer::get_singleton()->body_set_space(g.static_body,RID());
- if (g.baked.is_valid()) {
-
- VS::get_singleton()->instance_set_room(g.bake_instance,RID());
- VS::get_singleton()->instance_set_scenario(g.bake_instance,RID());
-
- }
-
if (g.collision_debug_instance.is_valid()) {
VS::get_singleton()->instance_set_room(g.collision_debug_instance,RID());
@@ -802,194 +699,6 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
}
-void GridMap::_octant_clear_baked(const OctantKey &p_key) {
-
-
- ERR_FAIL_COND(!octant_map.has(p_key));
- Octant&g = *octant_map[p_key];
-
- if (!g.baked.is_valid())
- return;
-
- VS::get_singleton()->free(g.bake_instance);
- g.bake_instance=RID();
- g.baked=Ref<Mesh>();
-
- if (is_inside_tree())
- _octant_enter_world(p_key);
- g.dirty=true;
- _queue_dirty_map();
-}
-
-void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tmesh,const Vector<BakeLight> &p_lights,List<Vector3> *p_prebake) {
-
-
- ERR_FAIL_COND(!octant_map.has(p_key));
- Octant&g = *octant_map[p_key];
-
- Ref<TriangleMesh> tm=p_tmesh;
- if (!p_prebake && is_inside_world())
- _octant_exit_world(p_key);
-
- Map< Ref<Material>, Ref<SurfaceTool> > surfaces;
- Vector3 ofs(cell_size*0.5*int(center_x),cell_size*0.5*int(center_y),cell_size*0.5*int(center_z));
- Vector3 octant_ofs=_octant_get_offset(p_key);
-
- for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) {
-
- Octant::ItemInstances &ii=E->get();
-
- if (ii.mesh.is_null())
- continue;
-
- for(Set<IndexKey>::Element *F=ii.cells.front();F;F=F->next()) {
-
- IndexKey ik=F->get();
- Map<IndexKey,Cell>::Element *C=cell_map.find(ik);
- ERR_CONTINUE(!C);
- Vector3 cellpos = Vector3(ik.x,ik.y,ik.z );
-
- Transform xform;
- xform.basis.set_orthogonal_index(C->get().rot);
- xform.set_origin( cellpos*cell_size+ofs);
- if (!p_prebake)
- xform.origin-=octant_ofs;
-
-
- for(int i=0;i<ii.mesh->get_surface_count();i++) {
-
- if (p_prebake) {
-
- if (ii.mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
- continue;
- Array a = ii.mesh->surface_get_arrays(i);
- PoolVector<Vector3> av=a[VS::ARRAY_VERTEX];
- int avs = av.size();
- PoolVector<Vector3>::Read vr = av.read();
-
- PoolVector<int> ai=a[VS::ARRAY_INDEX];
- int ais=ai.size();
- if (ais) {
-
- PoolVector<int>::Read ir=ai.read();
- for(int j=0;j<ais;j++) {
-
- p_prebake->push_back(xform.xform(vr[ir[j]]));
- //print_line("V SET: "+xform.xform(vr[ir[j]]));
- }
-
- } else {
-
- for(int j=0;j<avs;j++) {
-
- p_prebake->push_back(xform.xform(vr[j]));
- }
- }
-
- } else {
-
- Ref<Material> m = ii.mesh->surface_get_material(i);
-
- Map< Ref<Material>, Ref<SurfaceTool> >::Element *S=surfaces.find(m);
-
- if (!S) {
-
- S=surfaces.insert(m,Ref<SurfaceTool>( memnew( SurfaceTool )));
- }
-
- Ref<SurfaceTool> st = S->get();
- List<SurfaceTool::Vertex>::Element *V=st->get_vertex_array().back();
- st->append_from(ii.mesh,i,xform);
- st->set_material(m);
-
-
- if (tm.is_valid()) {
-
- if (V)
- V=V->next();
- else
- V=st->get_vertex_array().front();
- int lc = p_lights.size();
- const BakeLight* bl = p_lights.ptr();
- float ofs = cell_size*0.02;
-
-
- for(;V;V=V->next()) {
-
- SurfaceTool::Vertex &v=V->get();
-
- Vector3 vertex = v.vertex + octant_ofs;
- //print_line("V GET: "+vertex);
- Vector3 normal = tm->get_area_normal( Rect3( Vector3(-ofs,-ofs,-ofs)+vertex,Vector3(ofs,ofs,ofs)*2.0));
- if (normal==Vector3()) {
- print_line("couldn't find for vertex: "+vertex);
- }
- ERR_CONTINUE( normal== Vector3());
-
- float max_l=1.0;
- float max_dist=1.0;
-
- if (lc) {
-
- for(int j=0;j<lc;j++) {
- const BakeLight &l=bl[j];
- switch(l.type) {
- case VS::LIGHT_DIRECTIONAL: {
-
- Vector3 ray_from=vertex + normal *ofs;
- Vector3 ray_to=l.dir*5000;
- Vector3 n;
- Vector3 p;
- if (tm->intersect_segment(ray_from,ray_to,p,n)) {
-
- float dist = 1.0-l.param[VS::LIGHT_PARAM_SHADOW_DARKENING];
- if (dist<=max_dist) {
- max_dist=dist;
- max_l=1.0-dist;
- }
- }
- } break;
- }
-
- }
- }
-
- v.color=Color(max_l,max_l,max_l,1.0);
-
- }
-
- st->add_to_format(VS::ARRAY_FORMAT_COLOR);
- if (m.is_valid()) {
- Ref<FixedSpatialMaterial> fm = m;
- if (fm.is_valid())
- fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY,true);
- }
- }
- }
- }
- }
- }
-
- if (p_prebake)
- return;
-
- g.baked = Ref<Mesh>( memnew( Mesh ));
-
- for(Map< Ref<Material>, Ref<SurfaceTool> >::Element *E=surfaces.front();E;E=E->next()) {
-
- Ref<SurfaceTool> st = E->get();
- st->commit(g.baked);
- }
-
- g.bake_instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(g.bake_instance,g.baked->get_rid());
-
- if (is_inside_world())
- _octant_enter_world(p_key);
-
- g.dirty=true;
- _queue_dirty_map();
-}
void GridMap::_notification(int p_what) {
@@ -1011,10 +720,6 @@ void GridMap::_notification(int p_what) {
last_transform=get_global_transform();
- if (use_baked_light) {
-
- _find_baked_light();
- }
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -1036,15 +741,6 @@ void GridMap::_notification(int p_what) {
_octant_exit_world(E->key());
}
- if (use_baked_light) {
-
- if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
- }
- _baked_light_changed();
-
- }
//_queue_dirty_map(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS);
//_update_dirty_map_callback();
@@ -1122,9 +818,6 @@ void GridMap::_clear_internal(bool p_keep_areas) {
VS::get_singleton()->free(F->get().multimesh_instance);
}
- //unbake just in case
- if (E->get()->bake_instance.is_valid())
- VS::get_singleton()->free(E->get()->bake_instance);
if (E->get()->collision_debug.is_valid())
VS::get_singleton()->free(E->get()->collision_debug);
@@ -1188,9 +881,6 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_theme","theme:MeshLibrary"),&GridMap::set_theme);
ClassDB::bind_method(D_METHOD("get_theme:MeshLibrary"),&GridMap::get_theme);
- ClassDB::bind_method(D_METHOD("set_bake","enable"),&GridMap::set_bake);
- ClassDB::bind_method(D_METHOD("is_baking_enabled"),&GridMap::is_baking_enabled);
-
ClassDB::bind_method(D_METHOD("set_cell_size","size"),&GridMap::set_cell_size);
ClassDB::bind_method(D_METHOD("get_cell_size"),&GridMap::get_cell_size);
@@ -1226,20 +916,11 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("area_get_portal_disable_color","area"),&GridMap::area_get_portal_disable_color);
ClassDB::bind_method(D_METHOD("erase_area","area"),&GridMap::erase_area);
ClassDB::bind_method(D_METHOD("get_unused_area_id","area"),&GridMap::get_unused_area_id);
- ClassDB::bind_method(D_METHOD("bake_geometry"),&GridMap::bake_geometry);
-
- ClassDB::bind_method(D_METHOD("_baked_light_changed"),&GridMap::_baked_light_changed);
- ClassDB::bind_method(D_METHOD("set_use_baked_light","use"),&GridMap::set_use_baked_light);
- ClassDB::bind_method(D_METHOD("is_using_baked_light","use"),&GridMap::is_using_baked_light);
-
- ClassDB::bind_method(D_METHOD("_get_baked_light_meshes"),&GridMap::_get_baked_light_meshes);
-
-
-
- ClassDB::set_method_flags("GridMap","bake_geometry",METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
ClassDB::bind_method(D_METHOD("clear"),&GridMap::clear);
+ ClassDB::bind_method(D_METHOD("get_meshes"),&GridMap::get_meshes);
+
BIND_CONSTANT( INVALID_CELL_ITEM );
}
@@ -1622,23 +1303,6 @@ int GridMap::get_unused_area_id() const {
return area_map.back()->key()+1;
}
-
-void GridMap::set_bake(bool p_bake) {
-
- bake=p_bake;
- if (bake==false) {
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
-
- _octant_clear_baked(E->key());
- }
- }
-}
-
-bool GridMap::is_baking_enabled() const {
-
- return bake;
-}
-
void GridMap::set_cell_scale(float p_scale) {
cell_scale=p_scale;
@@ -1652,100 +1316,8 @@ float GridMap::get_cell_scale() const{
-void GridMap::bake_geometry() {
-
- //used to compute vertex occlusion
- Ref<TriangleMesh> tmesh;
- Vector<BakeLight> lights;
-
- if (true) {
-
- List<Vector3> vertices;
-
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
- _octant_bake(E->key(),tmesh,lights,&vertices);
-
- }
-
- PoolVector<Vector3> vv;
- vv.fill_with(vertices);
- //print_line("TOTAL VERTICES: "+itos(vv.size()));
- tmesh = Ref<TriangleMesh>( memnew( TriangleMesh ));
- tmesh->create(vv);
-
-
- for(int i=0;i<get_child_count();i++) {
-
- if (get_child(i)->cast_to<Light>()) {
- Light *l = get_child(i)->cast_to<Light>();
- BakeLight bl;
- for(int i=0;i<Light::PARAM_MAX;i++) {
- bl.param[i]=l->get_parameter(Light::Parameter(i));
- }
- Transform t=l->get_global_transform();
- bl.pos=t.origin;
- bl.dir=t.basis.get_axis(2);
- bl.type=l->get_light_type();
- lights.push_back(bl);
-
- }
- }
- }
-
- int idx=0;
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
- if (E->get()->baked.is_valid())
- _octant_clear_baked(E->key());
-
- _octant_bake(E->key(),tmesh,lights);
- print_line("baking "+itos(idx)+"/"+itos(octant_map.size()));
- idx++;
- }
-
-}
-
-void GridMap::_baked_light_changed() {
-
- /*
- if (!baked_light_instance)
- VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID());
- else
- VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance());
- */
- for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) {
-
- for(Map<int,Octant::ItemInstances>::Element *F=E->get()->items.front();F;F=F->next()) {
-
- VS::get_singleton()->instance_geometry_set_baked_light(F->get().multimesh_instance,baked_light_instance?baked_light_instance->get_baked_light_instance():RID());
- }
-
- }
-
-}
-void GridMap::_find_baked_light() {
-
- Node *n=get_parent();
- while(n) {
-
- BakedLightInstance *bl=n->cast_to<BakedLightInstance>();
- if (bl) {
-
- baked_light_instance=bl;
- baked_light_instance->connect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- _baked_light_changed();
-
- return;
- }
-
- n=n->get_parent();
- }
-
- _baked_light_changed();
-}
-
-
-Array GridMap::_get_baked_light_meshes() {
+Array GridMap::get_meshes() {
if (theme.is_null())
return Array();
@@ -1783,31 +1355,6 @@ Array GridMap::_get_baked_light_meshes() {
return meshes;
}
-void GridMap::set_use_baked_light(bool p_use) {
-
- if (use_baked_light==p_use)
- return;
-
- use_baked_light=p_use;
-
- if (is_inside_world()) {
- if (!p_use) {
- if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
- }
- _baked_light_changed();
- } else {
- _find_baked_light();
- }
- }
-
-}
-
-bool GridMap::is_using_baked_light() const{
-
- return use_baked_light;
-}
@@ -1825,12 +1372,8 @@ GridMap::GridMap() {
clip_floor=0;
clip_axis=Vector3::AXIS_Z;
clip_above=true;
- baked_lock=false;
- bake=false;
cell_scale=1.0;
- baked_light_instance=NULL;
- use_baked_light=false;
navigation = NULL;
set_notify_transform(true);
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 04d140cdc6..5d4133383b 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -103,8 +103,6 @@ class GridMap : public Spatial {
Ref<NavigationMesh> navmesh;
};
- Ref<Mesh> baked;
- RID bake_instance;
RID collision_debug;
RID collision_debug_instance;
@@ -140,14 +138,12 @@ class GridMap : public Spatial {
float cell_size;
int octant_size;
bool center_x,center_y,center_z;
- bool bake;
float cell_scale;
Navigation *navigation;
bool clip;
bool clip_above;
int clip_floor;
- bool baked_lock;
Vector3::Axis clip_axis;
@@ -205,9 +201,7 @@ class GridMap : public Spatial {
void _octant_exit_world(const OctantKey &p_key);
void _octant_update(const OctantKey &p_key);
void _octant_transform(const OctantKey &p_key);
- void _octant_clear_baked(const OctantKey &p_key);
void _octant_clear_navmesh(const GridMap::OctantKey&);
- void _octant_bake(const OctantKey &p_key,const Ref<TriangleMesh>& p_tmesh=RES(),const Vector<BakeLight> &p_lights=Vector<BakeLight>(),List<Vector3> *r_prebake=NULL);
bool awaiting_update;
void _queue_dirty_map();
@@ -221,14 +215,6 @@ class GridMap : public Spatial {
void _clear_internal(bool p_keep_areas=false);
- BakedLightInstance *baked_light_instance;
- bool use_baked_light;
- void _find_baked_light();
- void _baked_light_changed();
-
-
- Array _get_baked_light_meshes();
-
protected:
bool _set(const StringName& p_name, const Variant& p_value);
@@ -285,13 +271,11 @@ public:
void set_cell_scale(float p_scale);
float get_cell_scale() const;
- void set_bake(bool p_bake);
- bool is_baking_enabled() const;
- void bake_geometry();
- void set_use_baked_light(bool p_use);
- bool is_using_baked_light() const;
+ Array get_meshes();
+
+
void clear();
GridMap();
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index d4c7cb7ca9..2630360058 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -249,7 +249,7 @@ void GridMapEditor::_update_cursor_transform() {
if (cursor_instance.is_valid()) {
VisualServer::get_singleton()->instance_set_transform(cursor_instance,cursor_transform);
- VisualServer::get_singleton()->instance_geometry_set_flag(cursor_instance,VS::INSTANCE_FLAG_VISIBLE,cursor_visible);
+ VisualServer::get_singleton()->instance_set_visible(cursor_instance,cursor_visible);
}
}
@@ -852,11 +852,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
if (!node) {
set_process(false);
for(int i=0;i<3;i++) {
- VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,false);
+ VisualServer::get_singleton()->instance_set_visible(grid_instance[i],false);
}
- VisualServer::get_singleton()->instance_geometry_set_flag(cursor_instance, VS::INSTANCE_FLAG_VISIBLE,false);
+ VisualServer::get_singleton()->instance_set_visible(cursor_instance,false);
_clear_areas();
@@ -884,13 +884,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
{
//update grids
- indicator_mat = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_UNSHADED, true );
- VisualServer::get_singleton()->material_set_flag( indicator_mat, VisualServer::MATERIAL_FLAG_ONTOP, false );
-
- VisualServer::get_singleton()->fixed_material_set_param(indicator_mat,VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.8,0.5,0.1));
- VisualServer::get_singleton()->fixed_material_set_flag( indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
- VisualServer::get_singleton()->fixed_material_set_flag( indicator_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY, true );
+ indicator_mat.instance();
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
+ indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
+ indicator_mat->set_albedo(Color(0.8,0.5,0.1));
Vector<Vector3> grid_points[3];
@@ -937,8 +935,8 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
d.resize(VS::ARRAY_MAX);
d[VS::ARRAY_VERTEX]=grid_points[i];
d[VS::ARRAY_COLOR]=grid_colors[i];
- VisualServer::get_singleton()->mesh_add_surface(grid[i],VisualServer::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i],VisualServer::PRIMITIVE_LINES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(grid[i],0,indicator_mat->get_rid());
}
@@ -976,7 +974,7 @@ void GridMapEditor::update_grid() {
for(int i=0;i<3;i++) {
- VisualServer::get_singleton()->instance_geometry_set_flag(grid_instance[i],VS::INSTANCE_FLAG_VISIBLE,i==edit_axis);
+ VisualServer::get_singleton()->instance_set_visible(grid_instance[i],i==edit_axis);
}
@@ -1103,7 +1101,7 @@ void GridMapEditor::_update_areas_display() {
if (!node) {
return;
}
-
+#if 0
_clear_areas();
List<int> areas;
node->get_area_list(&areas);
@@ -1118,6 +1116,8 @@ void GridMapEditor::_update_areas_display() {
color=Color(1,1,1,0.2);
else
color.set_hsv(Math::fmod(area*0.37,1),Math::fmod(area*0.75,1),1.0,0.2);
+
+
RID material = VisualServer::get_singleton()->fixed_material_create();
VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_DIFFUSE,color );
VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_EMISSION,0.5 );
@@ -1149,7 +1149,7 @@ void GridMapEditor::_update_areas_display() {
this->areas.push_back(ad);
}
-
+#endif
}
void GridMapEditor::_edit_mode_changed(int p_what) {
@@ -1295,7 +1295,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
hb->add_child(mode_list);
mode_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));
- EDITOR_DEF("editors/grid_map/preview_size",64)
+ EDITOR_DEF("editors/grid_map/preview_size",64);
display_mode = DISPLAY_THUMBNAIL;
selected_area=-1;
@@ -1387,52 +1387,36 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
Array d;
d.resize(VS::ARRAY_MAX);
- inner_mat = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(inner_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.3));
- VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_ONTOP,true);
- VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->fixed_material_set_flag( inner_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
+ inner_mat.instance();
+ inner_mat->set_albedo(Color(0.7,0.7,1.0,0.3));
+ inner_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
+ inner_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ inner_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
d[VS::ARRAY_VERTEX]=triangles;
- VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_TRIANGLES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh,VS::PRIMITIVE_TRIANGLES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat->get_rid());
- outer_mat = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(outer_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.8));
- VisualServer::get_singleton()->material_set_line_width(outer_mat,3.0);
- VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_ONTOP,true);
- VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->fixed_material_set_flag( outer_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
+ outer_mat.instance();
+ outer_mat->set_albedo(Color(0.7,0.7,1.0,0.3));
+ outer_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
+ outer_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
+ outer_mat->set_line_width(3.0);
+ outer_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
d[VS::ARRAY_VERTEX]=lines;
- VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat);
-
-
- inner_mat_dup = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(inner_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.3));
- VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_ONTOP,true);
- VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->fixed_material_set_flag( inner_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
-
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh,VS::PRIMITIVE_LINES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat->get_rid());
d[VS::ARRAY_VERTEX]=triangles;
- VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat_dup);
-
- outer_mat_dup = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param(outer_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.8));
- VisualServer::get_singleton()->material_set_line_width(outer_mat_dup,3.0);
- VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_ONTOP,true);
- VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true);
- VisualServer::get_singleton()->fixed_material_set_flag( outer_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
-
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat->get_rid());
d[VS::ARRAY_VERTEX]=lines;
- VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_LINES,d);
- VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat_dup);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(duplicate_mesh,VS::PRIMITIVE_LINES,d);
+ VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat->get_rid());
}
@@ -1452,14 +1436,10 @@ GridMapEditor::~GridMapEditor() {
VisualServer::get_singleton()->free(grid[i]);
if (grid_instance[i].is_valid())
VisualServer::get_singleton()->free(grid_instance[i]);
- if (cursor_instance)
+ if (cursor_instance.is_valid())
VisualServer::get_singleton()->free(cursor_instance);
}
- VisualServer::get_singleton()->free(inner_mat);
- VisualServer::get_singleton()->free(outer_mat);
- VisualServer::get_singleton()->free(inner_mat_dup);
- VisualServer::get_singleton()->free(outer_mat_dup);
VisualServer::get_singleton()->free(selection_mesh);
if (selection_instance.is_valid())
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index 2c0ff99dc6..66ec5dc4bc 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -112,12 +112,9 @@ class GridMapEditor : public VBoxContainer {
RID duplicate_mesh;
RID duplicate_instance;
- RID indicator_mat;
-
- RID inner_mat;
- RID outer_mat;
- RID inner_mat_dup;
- RID outer_mat_dup;
+ Ref<FixedSpatialMaterial> indicator_mat;
+ Ref<FixedSpatialMaterial> inner_mat;
+ Ref<FixedSpatialMaterial> outer_mat;
bool updating;
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();
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index a48b6d3827..275137ae5a 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -622,6 +622,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Transform2D body_transform = p_from;
+
{
//STEP 1, FREE BODY IF STUCK
@@ -645,6 +646,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
bool collided=false;
+
int amount = _cull_aabb_for_body(p_body,body_aabb);
for(int j=0;j<p_body->get_shape_count();j++) {
@@ -682,11 +684,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
- if (!collided)
+ if (!collided) {
break;
+ }
Vector2 recover_motion;
+
for(int i=0;i<cbk.amount;i++) {
Vector2 a = sr[i*2+0];
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 68767da4ce..dbf8fb442b 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -712,7 +712,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t
} break;
case VS::ARRAY_BONES: {
- ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY, ERR_INVALID_PARAMETER );
+ ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY && p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER );
PoolVector<int> array = p_arrays[ai];