mirror of
https://github.com/Relintai/props.git
synced 2024-11-12 10:15:25 +01:00
Work on fixing compile.
This commit is contained in:
parent
7ccb1b7819
commit
0fd63f6cb6
@ -54,14 +54,14 @@ GroundClutter::~GroundClutter() {
|
||||
void GroundClutter::_bind_methods() {
|
||||
|
||||
#ifdef TEXTURE_PACKER_PRESENT
|
||||
BIND_VMETHOD(MethodInfo("_add_textures_to", PropertyInfo(Variant::OBJECT, "packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker")));
|
||||
//BIND_VMETHOD(MethodInfo("_add_textures_to", PropertyInfo(Variant::OBJECT, "packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter::add_textures_to);
|
||||
#endif
|
||||
|
||||
#ifdef VOXELMAN_PRESENT
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "should"), "_should_spawn", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
|
||||
BIND_VMETHOD(MethodInfo("_add_meshes_to", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
|
||||
//BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "should"), "_should_spawn", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
|
||||
//BIND_VMETHOD(MethodInfo("_add_meshes_to", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("should_spawn", "chunk", "x", "y", "z"), &GroundClutter::should_spawn);
|
||||
ClassDB::bind_method(D_METHOD("add_meshes_to", "mesher", "chunk", "x", "y", "z"), &GroundClutter::add_meshes_to);
|
||||
|
@ -25,6 +25,11 @@ SOFTWARE.
|
||||
#include "../props/prop_data.h"
|
||||
#include "../singleton/prop_utils.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/separator.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
@ -72,12 +77,12 @@ void PropEditorPlugin::convert_scene(Node *root, const String &path) {
|
||||
res->copy_from(data);
|
||||
|
||||
ResourceSaver s;
|
||||
s.save(path, res);
|
||||
s.save(res, path);
|
||||
|
||||
res.unref();
|
||||
} else {
|
||||
ResourceSaver s;
|
||||
s.save(path, data);
|
||||
s.save(data, path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,9 +111,7 @@ void PropEditorPlugin::_convert_selected_scene_to_prop_data(Variant param) {
|
||||
convert_selected_scene_to_prop_data();
|
||||
}
|
||||
|
||||
PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) {
|
||||
editor = p_node;
|
||||
|
||||
PropEditorPlugin::PropEditorPlugin() {
|
||||
#if VERSION_MAJOR < 4
|
||||
editor->add_tool_menu_item("Convert active scene to PropData", this, "convert_active_scene_to_prop_data");
|
||||
editor->add_tool_menu_item("Convert selected scene(s) to PropData", this, "convert_selected_scene_to_prop_data");
|
||||
@ -128,7 +131,7 @@ PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
b->CONNECT("pressed", this, PropEditorPlugin, _quick_convert_button_pressed);
|
||||
b->set_text("To Prop");
|
||||
b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to PropData.", KEY_MASK_ALT + KEY_U));
|
||||
b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to PropData.", KeyModifierMask::ALT + Key::U));
|
||||
|
||||
add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, container);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ SOFTWARE.
|
||||
#ifndef PROP_EDITOR_PLUGIN_H
|
||||
#define PROP_EDITOR_PLUGIN_H
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
|
||||
#include "core/version.h"
|
||||
@ -31,7 +30,6 @@ SOFTWARE.
|
||||
class PropEditorPlugin : public EditorPlugin {
|
||||
|
||||
GDCLASS(PropEditorPlugin, EditorPlugin);
|
||||
EditorNode *editor;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@ -53,7 +51,7 @@ public:
|
||||
void _convert_selected_scene_to_prop_data(Variant param);
|
||||
void _quick_convert_button_pressed();
|
||||
|
||||
PropEditorPlugin(EditorNode *p_node);
|
||||
PropEditorPlugin();
|
||||
~PropEditorPlugin();
|
||||
};
|
||||
|
||||
|
@ -102,7 +102,7 @@ void PropMesherJobStep::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_simplification_step_ratio"), &PropMesherJobStep::get_simplification_step_ratio);
|
||||
ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &PropMesherJobStep::set_simplification_step_ratio);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_step_ratio"), "set_simplification_step_ratio", "get_simplification_step_ratio");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplification_step_ratio"), "set_simplification_step_ratio", "get_simplification_step_ratio");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_simplification_steps"), &PropMesherJobStep::get_simplification_steps);
|
||||
ClassDB::bind_method(D_METHOD("set_simplification_steps", "value"), &PropMesherJobStep::set_simplification_steps);
|
||||
@ -110,7 +110,7 @@ void PropMesherJobStep::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &PropMesherJobStep::get_simplification_agressiveness);
|
||||
ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &PropMesherJobStep::set_simplification_agressiveness);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_agressiveness"), "set_simplification_agressiveness", "get_simplification_agressiveness");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "simplification_agressiveness"), "set_simplification_agressiveness", "get_simplification_agressiveness");
|
||||
#endif
|
||||
|
||||
BIND_ENUM_CONSTANT(TYPE_NORMAL);
|
||||
|
@ -96,7 +96,7 @@ void PropTextureJob::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob::should_do, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob::should_return);
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_execute"));
|
||||
//BIND_VMETHOD(MethodInfo("_execute"));
|
||||
ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob::execute);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("completed"));
|
||||
|
@ -143,10 +143,10 @@ void PropMaterialCache::materials_set(const Vector<Variant> &materials) {
|
||||
}
|
||||
}
|
||||
|
||||
void PropMaterialCache::texture_add(const Ref<Texture> &texture) {
|
||||
void PropMaterialCache::texture_add(const Ref<Texture2D> &texture) {
|
||||
_textures.push_back(texture);
|
||||
}
|
||||
void PropMaterialCache::texture_remove(const Ref<Texture> &texture) {
|
||||
void PropMaterialCache::texture_remove(const Ref<Texture2D> &texture) {
|
||||
for (int i = 0; i < _textures.size(); ++i) {
|
||||
if (_textures[i] == texture) {
|
||||
_textures.remove_at(i);
|
||||
@ -165,8 +165,8 @@ void PropMaterialCache::textures_clear() {
|
||||
int PropMaterialCache::texture_count() {
|
||||
return _textures.size();
|
||||
}
|
||||
Ref<Texture> PropMaterialCache::texture_get(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture>());
|
||||
Ref<Texture2D> PropMaterialCache::texture_get(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture2D>());
|
||||
|
||||
return _textures[index];
|
||||
}
|
||||
@ -175,10 +175,10 @@ Ref<AtlasTexture> PropMaterialCache::texture_get_atlas(const int index) {
|
||||
|
||||
return texture_get_atlas_tex(_textures[index]);
|
||||
}
|
||||
Ref<AtlasTexture> PropMaterialCache::texture_get_atlas_tex(const Ref<Texture> &texture) {
|
||||
Ref<AtlasTexture> PropMaterialCache::texture_get_atlas_tex(const Ref<Texture2D> &texture) {
|
||||
return Ref<AtlasTexture>();
|
||||
}
|
||||
Rect2 PropMaterialCache::texture_get_uv_rect(const Ref<Texture> &texture) {
|
||||
Rect2 PropMaterialCache::texture_get_uv_rect(const Ref<Texture2D> &texture) {
|
||||
return Rect2(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ void PropMaterialCache::prop_add_textures(const Ref<PropData> &prop) {
|
||||
Ref<PropDataMeshData> pdm = prop->get_prop(i);
|
||||
|
||||
if (pdm.is_valid()) {
|
||||
Ref<Texture> tex = pdm->get_texture();
|
||||
Ref<Texture2D> tex = pdm->get_texture();
|
||||
|
||||
if (!tex.is_valid())
|
||||
continue;
|
||||
@ -233,7 +233,7 @@ void PropMaterialCache::prop_remove_textures(const Ref<PropData> &prop) {
|
||||
Ref<PropDataMeshData> pdm = prop->get_prop(i);
|
||||
|
||||
if (pdm.is_valid()) {
|
||||
Ref<Texture> tex = pdm->get_texture();
|
||||
Ref<Texture2D> tex = pdm->get_texture();
|
||||
|
||||
if (!tex.is_valid())
|
||||
continue;
|
||||
@ -251,7 +251,7 @@ void PropMaterialCache::prop_remove_textures(const Ref<PropData> &prop) {
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < twd->get_texture_count(); ++j) {
|
||||
const Ref<Texture> &tex = twd->get_texture(j);
|
||||
const Ref<Texture2D> &tex = twd->get_texture(j);
|
||||
|
||||
if (tex.is_valid()) {
|
||||
texture_remove(tex);
|
||||
@ -259,7 +259,7 @@ void PropMaterialCache::prop_remove_textures(const Ref<PropData> &prop) {
|
||||
}
|
||||
|
||||
for (int j = 0; j < twd->get_flavour_texture_count(); ++j) {
|
||||
const Ref<Texture> &tex = twd->get_flavour_texture(j);
|
||||
const Ref<Texture2D> &tex = twd->get_flavour_texture(j);
|
||||
|
||||
if (tex.is_valid()) {
|
||||
texture_remove(tex);
|
||||
@ -300,7 +300,7 @@ void PropMaterialCache::initial_setup_default() {
|
||||
}
|
||||
}
|
||||
|
||||
void PropMaterialCache::setup_material_albedo(Ref<Texture> texture) {
|
||||
void PropMaterialCache::setup_material_albedo(Ref<Texture2D> texture) {
|
||||
if (has_method("_setup_material_albedo"))
|
||||
call("_setup_material_albedo", texture);
|
||||
}
|
||||
|
@ -68,15 +68,15 @@ public:
|
||||
Vector<Variant> materials_get();
|
||||
void materials_set(const Vector<Variant> &materials);
|
||||
|
||||
virtual void texture_add(const Ref<Texture> &texture);
|
||||
virtual void texture_remove(const Ref<Texture> &texture);
|
||||
virtual void texture_add(const Ref<Texture2D> &texture);
|
||||
virtual void texture_remove(const Ref<Texture2D> &texture);
|
||||
virtual void texture_remove_index(const int index);
|
||||
virtual void textures_clear();
|
||||
virtual int texture_count();
|
||||
virtual Ref<Texture> texture_get(const int index);
|
||||
virtual Ref<Texture2D> texture_get(const int index);
|
||||
virtual Ref<AtlasTexture> texture_get_atlas(const int index);
|
||||
virtual Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture> &texture);
|
||||
virtual Rect2 texture_get_uv_rect(const Ref<Texture> &texture);
|
||||
virtual Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture2D> &texture);
|
||||
virtual Rect2 texture_get_uv_rect(const Ref<Texture2D> &texture);
|
||||
|
||||
void prop_add_textures(const Ref<PropData> &prop);
|
||||
void prop_remove_textures(const Ref<PropData> &prop);
|
||||
@ -85,7 +85,7 @@ public:
|
||||
|
||||
virtual void initial_setup_default();
|
||||
|
||||
void setup_material_albedo(Ref<Texture> texture);
|
||||
void setup_material_albedo(Ref<Texture2D> texture);
|
||||
|
||||
PropMaterialCache();
|
||||
~PropMaterialCache();
|
||||
@ -97,7 +97,7 @@ protected:
|
||||
bool _initialized;
|
||||
|
||||
Vector<Ref<Material>> _materials;
|
||||
Vector<Ref<Texture>> _textures;
|
||||
Vector<Ref<Texture2D>> _textures;
|
||||
|
||||
int _ref_count;
|
||||
|
||||
|
@ -61,14 +61,14 @@ void PropMaterialCachePCM::set_margin(const int margin) {
|
||||
_packer->set_margin(margin);
|
||||
}
|
||||
|
||||
Ref<AtlasTexture> PropMaterialCachePCM::texture_get_atlas_tex(const Ref<Texture> &texture) {
|
||||
Ref<AtlasTexture> PropMaterialCachePCM::texture_get_atlas_tex(const Ref<Texture2D> &texture) {
|
||||
if (!_packer->contains_texture(texture)) {
|
||||
return Ref<AtlasTexture>();
|
||||
}
|
||||
|
||||
return _packer->get_texture(texture);
|
||||
}
|
||||
Rect2 PropMaterialCachePCM::texture_get_uv_rect(const Ref<Texture> &texture) {
|
||||
Rect2 PropMaterialCachePCM::texture_get_uv_rect(const Ref<Texture2D> &texture) {
|
||||
if (!texture.is_valid()) {
|
||||
return Rect2(0, 0, 1, 1);
|
||||
}
|
||||
@ -81,13 +81,13 @@ Rect2 PropMaterialCachePCM::texture_get_uv_rect(const Ref<Texture> &texture) {
|
||||
|
||||
Rect2 region = at->get_region();
|
||||
|
||||
Ref<Texture> tex = at->get_atlas();
|
||||
Ref<Texture2D> tex = at->get_atlas();
|
||||
|
||||
if (!tex.is_valid()) {
|
||||
return Rect2(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
Ref<Image> image = tex->get_data();
|
||||
Ref<Image> image = tex->get_image();
|
||||
|
||||
if (!image.is_valid()) {
|
||||
return Rect2(0, 0, 1, 1);
|
||||
@ -106,7 +106,7 @@ void PropMaterialCachePCM::refresh_rects() {
|
||||
bool texture_added = false;
|
||||
|
||||
for (int i = 0; i < _textures.size(); i++) {
|
||||
Ref<Texture> tex = _textures.get(i);
|
||||
Ref<Texture2D> tex = _textures.get(i);
|
||||
|
||||
ERR_CONTINUE(!tex.is_valid());
|
||||
|
||||
@ -121,7 +121,7 @@ void PropMaterialCachePCM::refresh_rects() {
|
||||
|
||||
ERR_FAIL_COND(_packer->get_texture_count() == 0);
|
||||
|
||||
Ref<Texture> tex = _packer->get_generated_texture(0);
|
||||
Ref<Texture2D> tex = _packer->get_generated_texture(0);
|
||||
|
||||
setup_material_albedo(tex);
|
||||
}
|
||||
@ -141,7 +141,7 @@ void PropMaterialCachePCM::initial_setup_default() {
|
||||
set_margin(pc->get_margin());
|
||||
}
|
||||
|
||||
void PropMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
|
||||
void PropMaterialCachePCM::_setup_material_albedo(Ref<Texture2D> texture) {
|
||||
int count = material_get_num();
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -157,7 +157,7 @@ void PropMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
|
||||
Ref<ShaderMaterial> shmat = m;
|
||||
|
||||
if (shmat.is_valid()) {
|
||||
shmat->set_shader_param("texture_albedo", texture);
|
||||
shmat->set_shader_parameter("texture_albedo", texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,14 +62,14 @@ public:
|
||||
int get_margin() const;
|
||||
void set_margin(const int margin);
|
||||
|
||||
Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture> &texture);
|
||||
Rect2 texture_get_uv_rect(const Ref<Texture> &texture);
|
||||
Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture2D> &texture);
|
||||
Rect2 texture_get_uv_rect(const Ref<Texture2D> &texture);
|
||||
|
||||
void refresh_rects();
|
||||
|
||||
void initial_setup_default();
|
||||
|
||||
void _setup_material_albedo(Ref<Texture> texture);
|
||||
void _setup_material_albedo(Ref<Texture2D> texture);
|
||||
|
||||
PropMaterialCachePCM();
|
||||
~PropMaterialCachePCM();
|
||||
|
@ -37,7 +37,7 @@ SOFTWARE.
|
||||
|
||||
class PropESSEntity : public Spatial {
|
||||
GDCLASS(PropESSEntity, Spatial);
|
||||
OBJ_CATEGORY("Props");
|
||||
//OBJ_CATEGORY("Props");
|
||||
|
||||
public:
|
||||
PropESSEntity();
|
||||
|
@ -108,7 +108,7 @@ void PropInstance::_build() {
|
||||
|
||||
//this way we won't delete the user's nodes
|
||||
if (n->get_owner() == NULL) {
|
||||
n->queue_delete();
|
||||
n->queue_free();
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
|
||||
if (!sc.is_valid())
|
||||
continue;
|
||||
|
||||
Node *n = sc->instance();
|
||||
Node *n = sc->instantiate();
|
||||
add_child(n);
|
||||
|
||||
Spatial *sp = Object::cast_to<Spatial>(n);
|
||||
@ -235,7 +235,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
|
||||
Ref<ShaderMaterial> shmat = mat;
|
||||
|
||||
if (shmat.is_valid()) {
|
||||
shmat->set_shader_param("texture_albedo", texture);
|
||||
shmat->set_shader_parameter("texture_albedo", texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,15 +294,15 @@ void PropInstance::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_prop_preprocess",
|
||||
PropertyInfo(Variant::TRANSFORM, "tarnsform"),
|
||||
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
|
||||
//BIND_VMETHOD(MethodInfo("_prop_preprocess",
|
||||
// PropertyInfo(Variant::TRANSFORM, "tarnsform"),
|
||||
// PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance::prop_preprocess);
|
||||
ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance::_prop_preprocess);
|
||||
|
||||
//---
|
||||
BIND_VMETHOD(MethodInfo("_init_materials"));
|
||||
//BIND_VMETHOD(MethodInfo("_init_materials"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("init_materials"), &PropInstance::init_materials);
|
||||
ClassDB::bind_method(D_METHOD("_init_materials"), &PropInstance::_init_materials);
|
||||
@ -312,8 +312,8 @@ void PropInstance::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("queue_build"), &PropInstance::queue_build);
|
||||
ClassDB::bind_method(D_METHOD("build_finished"), &PropInstance::build_finished);
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_build"));
|
||||
BIND_VMETHOD(MethodInfo("_build_finished"));
|
||||
//BIND_VMETHOD(MethodInfo("_build"));
|
||||
//BIND_VMETHOD(MethodInfo("_build_finished"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_build"), &PropInstance::_build);
|
||||
ClassDB::bind_method(D_METHOD("_build_finished"), &PropInstance::_build_finished);
|
||||
|
@ -26,8 +26,6 @@ SOFTWARE.
|
||||
|
||||
#include "./props/prop_data.h"
|
||||
|
||||
#include "../opensimplex/open_simplex_noise.h"
|
||||
|
||||
const String PropInstanceJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process";
|
||||
|
||||
PropInstanceJob::ActiveBuildPhaseType PropInstanceJob::get_build_phase_type() {
|
||||
@ -149,8 +147,8 @@ PropInstanceJob::~PropInstanceJob() {
|
||||
}
|
||||
|
||||
void PropInstanceJob::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
//BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
//BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_build_phase_type"), &PropInstanceJob::get_build_phase_type);
|
||||
ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &PropInstanceJob::set_build_phase_type);
|
||||
@ -168,14 +166,14 @@ void PropInstanceJob::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("finished"), &PropInstanceJob::finished);
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_reset"));
|
||||
//BIND_VMETHOD(MethodInfo("_reset"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("reset"), &PropInstanceJob::reset);
|
||||
ClassDB::bind_method(D_METHOD("_reset"), &PropInstanceJob::_reset);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob::_execute);
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_execute_phase"));
|
||||
//BIND_VMETHOD(MethodInfo("_execute_phase"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("execute_phase"), &PropInstanceJob::execute_phase);
|
||||
ClassDB::bind_method(D_METHOD("_execute_phase"), &PropInstanceJob::_execute_phase);
|
||||
@ -204,7 +202,7 @@ void PropInstanceJob::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob::should_do, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob::should_return);
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_execute"));
|
||||
//BIND_VMETHOD(MethodInfo("_execute"));
|
||||
ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob::execute);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("completed"));
|
||||
|
@ -51,7 +51,9 @@ typedef class RenderingServer VS;
|
||||
#include "jobs/prop_mesher_job_step.h"
|
||||
#include "lights/prop_light.h"
|
||||
#include "material_cache/prop_material_cache.h"
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/3d/camera_3d.h"
|
||||
|
||||
#include "scene/main/window.h"
|
||||
|
||||
#if TEXTURE_PACKER_PRESENT
|
||||
#include "./singleton/prop_cache.h"
|
||||
@ -65,7 +67,7 @@ typedef class RenderingServer VS;
|
||||
|
||||
#include "tiled_wall/tiled_wall_data.h"
|
||||
|
||||
#include "scene/resources/box_shape.h"
|
||||
#include "scene/resources/box_shape_3d.h"
|
||||
|
||||
const float PropInstanceMerger::LOD_CHECK_INTERVAL = 2;
|
||||
|
||||
@ -263,8 +265,8 @@ RID PropInstanceMerger::collider_body_get(const int index) {
|
||||
return _colliders[index].body;
|
||||
}
|
||||
|
||||
Ref<Shape> PropInstanceMerger::collider_shape_get(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _colliders.size(), Ref<Shape>());
|
||||
Ref<Shape3D> PropInstanceMerger::collider_shape_get(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _colliders.size(), Ref<Shape3D>());
|
||||
|
||||
return _colliders[index].shape;
|
||||
}
|
||||
@ -275,7 +277,7 @@ RID PropInstanceMerger::collider_shape_rid_get(const int index) {
|
||||
return _colliders[index].shape_rid;
|
||||
}
|
||||
|
||||
int PropInstanceMerger::collider_add(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid, const RID &body, const bool owns_shape) {
|
||||
int PropInstanceMerger::collider_add(const Transform &local_transform, const Ref<Shape3D> &shape, const RID &shape_rid, const RID &body, const bool owns_shape) {
|
||||
ERR_FAIL_COND_V(!shape.is_valid() && shape_rid == RID(), 0);
|
||||
|
||||
int index = _colliders.size();
|
||||
@ -346,7 +348,7 @@ void PropInstanceMerger::apply_lod_level() {
|
||||
return;
|
||||
}
|
||||
|
||||
VisualServer *vs = VisualServer::get_singleton();
|
||||
RenderingServer *vs = RenderingServer::get_singleton();
|
||||
|
||||
for (int i = 0; i < _meshes.size(); ++i) {
|
||||
RID mi = _meshes[i].mesh_instance;
|
||||
@ -383,11 +385,11 @@ void PropInstanceMerger::apply_lod_level() {
|
||||
|
||||
void PropInstanceMerger::debug_mesh_allocate() {
|
||||
if (_debug_mesh_rid == RID()) {
|
||||
_debug_mesh_rid = VisualServer::get_singleton()->mesh_create();
|
||||
_debug_mesh_rid = RenderingServer::get_singleton()->mesh_create();
|
||||
}
|
||||
|
||||
if (_debug_mesh_instance == RID()) {
|
||||
_debug_mesh_instance = VisualServer::get_singleton()->instance_create();
|
||||
_debug_mesh_instance = RenderingServer::get_singleton()->instance_create();
|
||||
|
||||
if (GET_WORLD().is_valid())
|
||||
VS::get_singleton()->instance_set_scenario(_debug_mesh_instance, GET_WORLD()->get_scenario());
|
||||
@ -399,11 +401,11 @@ void PropInstanceMerger::debug_mesh_allocate() {
|
||||
}
|
||||
void PropInstanceMerger::debug_mesh_free() {
|
||||
if (_debug_mesh_instance != RID()) {
|
||||
VisualServer::get_singleton()->free(_debug_mesh_instance);
|
||||
RenderingServer::get_singleton()->free(_debug_mesh_instance);
|
||||
}
|
||||
|
||||
if (_debug_mesh_rid != RID()) {
|
||||
VisualServer::get_singleton()->free(_debug_mesh_rid);
|
||||
RenderingServer::get_singleton()->free(_debug_mesh_rid);
|
||||
}
|
||||
}
|
||||
bool PropInstanceMerger::debug_mesh_has() {
|
||||
@ -411,13 +413,13 @@ bool PropInstanceMerger::debug_mesh_has() {
|
||||
}
|
||||
void PropInstanceMerger::debug_mesh_clear() {
|
||||
if (_debug_mesh_rid != RID()) {
|
||||
VisualServer::get_singleton()->mesh_clear(_debug_mesh_rid);
|
||||
RenderingServer::get_singleton()->mesh_clear(_debug_mesh_rid);
|
||||
}
|
||||
}
|
||||
void PropInstanceMerger::debug_mesh_array_clear() {
|
||||
_debug_mesh_array.resize(0);
|
||||
}
|
||||
void PropInstanceMerger::debug_mesh_add_vertices_to(const PoolVector3Array &arr) {
|
||||
void PropInstanceMerger::debug_mesh_add_vertices_to(const PackedVector3Array &arr) {
|
||||
_debug_mesh_array.append_array(arr);
|
||||
|
||||
if (_debug_mesh_array.size() % 2 == 1) {
|
||||
@ -434,13 +436,13 @@ void PropInstanceMerger::debug_mesh_send() {
|
||||
SceneTree *st = SceneTree::get_singleton();
|
||||
|
||||
Array arr;
|
||||
arr.resize(VisualServer::ARRAY_MAX);
|
||||
arr[VisualServer::ARRAY_VERTEX] = _debug_mesh_array;
|
||||
arr.resize(RenderingServer::ARRAY_MAX);
|
||||
arr[RenderingServer::ARRAY_VERTEX] = _debug_mesh_array;
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(_debug_mesh_rid, VisualServer::PRIMITIVE_LINES, arr);
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(_debug_mesh_rid, RenderingServer::PRIMITIVE_LINES, arr);
|
||||
|
||||
if (st) {
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(_debug_mesh_rid, 0, SceneTree::get_singleton()->get_debug_collision_material()->get_rid());
|
||||
RenderingServer::get_singleton()->mesh_surface_set_material(_debug_mesh_rid, 0, SceneTree::get_singleton()->get_debug_collision_material()->get_rid());
|
||||
}
|
||||
|
||||
debug_mesh_array_clear();
|
||||
@ -489,7 +491,7 @@ void PropInstanceMerger::free_colliders() {
|
||||
for (int i = 0; i < _colliders.size(); ++i) {
|
||||
ColliderBody &e = _colliders.write[i];
|
||||
|
||||
PhysicsServer::get_singleton()->free(e.body);
|
||||
PhysicsServer3D::get_singleton()->free(e.body);
|
||||
|
||||
e.body = RID();
|
||||
|
||||
@ -508,7 +510,7 @@ void PropInstanceMerger::_build() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_inside_tree() || !get_world().is_valid()) {
|
||||
if (!is_inside_tree() || !get_world_3d().is_valid()) {
|
||||
queue_build();
|
||||
return;
|
||||
}
|
||||
@ -527,7 +529,7 @@ void PropInstanceMerger::_build() {
|
||||
|
||||
//this way we won't delete the user's nodes
|
||||
if (n->get_owner() == NULL) {
|
||||
n->queue_delete();
|
||||
n->queue_free();
|
||||
}
|
||||
}
|
||||
|
||||
@ -623,17 +625,17 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
|
||||
_job->add_tiled_wall(tiled_wall_data, t);
|
||||
|
||||
if (tiled_wall_data->get_collision()) {
|
||||
Ref<BoxShape> tws;
|
||||
Ref<BoxShape3D> tws;
|
||||
tws.instantiate();
|
||||
|
||||
float hew = tiled_wall_data->get_width() / 2.0;
|
||||
float heh = tiled_wall_data->get_heigth() / 2.0;
|
||||
|
||||
tws->set_extents(Vector3(hew, heh, 0.01));
|
||||
tws->set_size(Vector3(hew, heh, 0.01));
|
||||
|
||||
Transform tt = t;
|
||||
//tt.origin += Vector3(hew, heh, 0);
|
||||
tt.translate(hew, heh, 0);
|
||||
tt.translate_local(hew, heh, 0);
|
||||
|
||||
_job->add_collision_shape(tws, tt, true);
|
||||
}
|
||||
@ -649,7 +651,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
|
||||
if (!sc.is_valid())
|
||||
continue;
|
||||
|
||||
Node *n = sc->instance();
|
||||
Node *n = sc->instantiate();
|
||||
add_child(n);
|
||||
n->set_owner(this);
|
||||
|
||||
@ -705,7 +707,7 @@ void PropInstanceMerger::collision_layer_changed() {
|
||||
const ColliderBody &c = _colliders[i];
|
||||
|
||||
if (c.body != RID()) {
|
||||
PhysicsServer::get_singleton()->body_set_collision_layer(c.body, _collision_layer);
|
||||
PhysicsServer3D::get_singleton()->body_set_collision_layer(c.body, _collision_layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -714,7 +716,7 @@ void PropInstanceMerger::collision_mask_changed() {
|
||||
const ColliderBody &c = _colliders[i];
|
||||
|
||||
if (c.body != RID()) {
|
||||
PhysicsServer::get_singleton()->body_set_collision_mask(c.body, _collision_mask);
|
||||
PhysicsServer3D::get_singleton()->body_set_collision_mask(c.body, _collision_mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -861,7 +863,7 @@ void PropInstanceMerger::_notification(int p_what) {
|
||||
Viewport *vp = st->get_root();
|
||||
|
||||
if (vp) {
|
||||
Camera *cam = vp->get_camera();
|
||||
Camera3D *cam = vp->get_camera_3d();
|
||||
|
||||
if (cam) {
|
||||
Vector3 cam_world_pos = cam->get_global_transform().xform(Vector3());
|
||||
@ -900,7 +902,7 @@ void PropInstanceMerger::_notification(int p_what) {
|
||||
|
||||
_last_transform = new_transform;
|
||||
|
||||
VisualServer *vs = VisualServer::get_singleton();
|
||||
RenderingServer *vs = RenderingServer::get_singleton();
|
||||
|
||||
for (int i = 0; i < _meshes.size(); ++i) {
|
||||
RID mir = _meshes[i].mesh_instance;
|
||||
@ -918,7 +920,7 @@ void PropInstanceMerger::_notification(int p_what) {
|
||||
const ColliderBody &c = _colliders[i];
|
||||
|
||||
if (c.body != RID()) {
|
||||
PhysicsServer::get_singleton()->body_set_shape_transform(c.body, 0, new_transform * c.transform);
|
||||
PhysicsServer3D::get_singleton()->body_set_shape_transform(c.body, 0, new_transform * c.transform);
|
||||
}
|
||||
}
|
||||
|
||||
@ -932,7 +934,7 @@ void PropInstanceMerger::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void PropInstanceMerger::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_create_job"));
|
||||
//BIND_VMETHOD(MethodInfo("_create_job"));
|
||||
ClassDB::bind_method(D_METHOD("_create_job"), &PropInstanceMerger::_create_job);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_job"), &PropInstanceMerger::get_job);
|
||||
@ -949,11 +951,11 @@ void PropInstanceMerger::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_first_lod_distance_squared"), &PropInstanceMerger::get_first_lod_distance_squared);
|
||||
ClassDB::bind_method(D_METHOD("set_first_lod_distance_squared", "value"), &PropInstanceMerger::set_first_lod_distance_squared);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "first_lod_distance_squared"), "set_first_lod_distance_squared", "get_first_lod_distance_squared");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "first_lod_distance_squared"), "set_first_lod_distance_squared", "get_first_lod_distance_squared");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_lod_reduction_distance_squared"), &PropInstanceMerger::get_lod_reduction_distance_squared);
|
||||
ClassDB::bind_method(D_METHOD("set_lod_reduction_distance_squared", "value"), &PropInstanceMerger::set_lod_reduction_distance_squared);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "lod_reduction_distance_squared"), "set_lod_reduction_distance_squared", "get_lod_reduction_distance_squared");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lod_reduction_distance_squared"), "set_lod_reduction_distance_squared", "get_lod_reduction_distance_squared");
|
||||
|
||||
///Materials
|
||||
ClassDB::bind_method(D_METHOD("material_get", "index"), &PropInstanceMerger::material_get);
|
||||
|
@ -90,9 +90,9 @@ public:
|
||||
//Colliders
|
||||
Transform collider_local_transform_get(const int index);
|
||||
RID collider_body_get(const int index);
|
||||
Ref<Shape> collider_shape_get(const int index);
|
||||
Ref<Shape3D> collider_shape_get(const int index);
|
||||
RID collider_shape_rid_get(const int index);
|
||||
int collider_add(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid, const RID &body, const bool owns_shape = false);
|
||||
int collider_add(const Transform &local_transform, const Ref<Shape3D> &shape, const RID &shape_rid, const RID &body, const bool owns_shape = false);
|
||||
int collider_get_num() const;
|
||||
void colliders_clear();
|
||||
|
||||
@ -108,7 +108,7 @@ public:
|
||||
bool debug_mesh_has();
|
||||
void debug_mesh_clear();
|
||||
void debug_mesh_array_clear();
|
||||
void debug_mesh_add_vertices_to(const PoolVector3Array &arr);
|
||||
void debug_mesh_add_vertices_to(const PackedVector3Array &arr);
|
||||
void debug_mesh_send();
|
||||
void draw_debug_mdr_colliders();
|
||||
|
||||
@ -138,7 +138,7 @@ protected:
|
||||
struct ColliderBody {
|
||||
Transform transform;
|
||||
RID body;
|
||||
Ref<Shape> shape;
|
||||
Ref<Shape3D> shape;
|
||||
RID shape_rid;
|
||||
bool owns_shape;
|
||||
|
||||
@ -175,7 +175,7 @@ private:
|
||||
//debug
|
||||
RID _debug_mesh_rid;
|
||||
RID _debug_mesh_instance;
|
||||
PoolVector3Array _debug_mesh_array;
|
||||
PackedVector3Array _debug_mesh_array;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -36,7 +36,7 @@ SOFTWARE.
|
||||
#include "prop_instance.h"
|
||||
#include "prop_instance_merger.h"
|
||||
#include "prop_mesher.h"
|
||||
#include "scene/resources/shape.h"
|
||||
#include "scene/resources/shape_3d.h"
|
||||
#include "singleton/prop_cache.h"
|
||||
|
||||
#ifdef MESH_DATA_RESOURCE_PRESENT
|
||||
@ -82,7 +82,7 @@ void PropInstancePropJob::set_jobs_step(int index, const Ref<PropMesherJobStep>
|
||||
void PropInstancePropJob::remove_jobs_step(const int index) {
|
||||
ERR_FAIL_INDEX(index, _job_steps.size());
|
||||
|
||||
_job_steps.remove(index);
|
||||
_job_steps.remove_at(index);
|
||||
}
|
||||
void PropInstancePropJob::add_jobs_step(const Ref<PropMesherJobStep> &step) {
|
||||
_job_steps.push_back(step);
|
||||
@ -136,7 +136,7 @@ void PropInstancePropJob::clear_meshes() {
|
||||
}
|
||||
#endif
|
||||
|
||||
void PropInstancePropJob::add_tiled_wall(const Ref<PropDataTiledWall> &data, const Transform &base_transform) {
|
||||
void PropInstancePropJob::add_tiled_wall(const Ref<PropDataTiledWall> &data, const Transform3D &base_transform) {
|
||||
PTWEntry e;
|
||||
e.data = data;
|
||||
e.base_transform = base_transform;
|
||||
@ -229,19 +229,20 @@ void PropInstancePropJob::phase_physics_process() {
|
||||
continue;
|
||||
}
|
||||
|
||||
RID body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
|
||||
RID body = PhysicsServer3D::get_singleton()->body_create();
|
||||
PhysicsServer3D::get_singleton()->body_set_mode(body, PhysicsServer3D::BODY_MODE_STATIC);
|
||||
|
||||
PhysicsServer::get_singleton()->body_add_shape(body, e.shape->get_rid());
|
||||
PhysicsServer3D::get_singleton()->body_add_shape(body, e.shape->get_rid());
|
||||
|
||||
//TODO store the layer mask somewhere
|
||||
PhysicsServer::get_singleton()->body_set_collision_layer(body, _prop_instace->get_collision_layer());
|
||||
PhysicsServer::get_singleton()->body_set_collision_mask(body, _prop_instace->get_collision_mask());
|
||||
PhysicsServer3D::get_singleton()->body_set_collision_layer(body, _prop_instace->get_collision_layer());
|
||||
PhysicsServer3D::get_singleton()->body_set_collision_mask(body, _prop_instace->get_collision_mask());
|
||||
|
||||
if (_prop_instace->is_inside_tree() && _prop_instace->is_inside_world()) {
|
||||
Ref<World> world = _prop_instace->GET_WORLD();
|
||||
Ref<World3D> world = _prop_instace->get_world_3d();
|
||||
|
||||
if (world.is_valid() && world->get_space() != RID()) {
|
||||
PhysicsServer::get_singleton()->body_set_space(body, world->get_space());
|
||||
PhysicsServer3D::get_singleton()->body_set_space(body, world->get_space());
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,12 +423,8 @@ void PropInstancePropJob::phase_steps() {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
RID mesh_rid = _prop_instace->mesh_get(i);
|
||||
|
||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
#if !GODOT4
|
||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
#else
|
||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||
#endif
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -481,12 +478,12 @@ void PropInstancePropJob::step_type_normal() {
|
||||
|
||||
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
|
||||
|
||||
VS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
RS::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->material_lod_get(_current_mesh);
|
||||
|
||||
if (lmat.is_valid()) {
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
RenderingServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
}
|
||||
|
||||
++_current_mesh;
|
||||
@ -501,14 +498,14 @@ void PropInstancePropJob::step_type_normal_lod() {
|
||||
void PropInstancePropJob::step_type_drop_uv2() {
|
||||
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
|
||||
|
||||
temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant();
|
||||
temp_mesh_arr[RenderingServer::ARRAY_TEX_UV2] = Variant();
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->material_lod_get(_current_mesh);
|
||||
|
||||
if (lmat.is_valid()) {
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
RenderingServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
}
|
||||
|
||||
++_current_mesh;
|
||||
@ -520,12 +517,12 @@ void PropInstancePropJob::step_type_merge_verts() {
|
||||
|
||||
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->material_lod_get(_current_mesh);
|
||||
|
||||
if (lmat.is_valid()) {
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
RenderingServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
}
|
||||
|
||||
++_current_mesh;
|
||||
@ -537,23 +534,23 @@ void PropInstancePropJob::step_type_bake_texture() {
|
||||
Ref<Texture> tex;
|
||||
|
||||
if (mat.is_valid()) {
|
||||
tex = mat->get_shader_param("texture_albedo");
|
||||
tex = mat->get_shader_parameter("texture_albedo");
|
||||
} else if (spmat.is_valid()) {
|
||||
tex = spmat->get_texture(StandardMaterial3D::TEXTURE_ALBEDO);
|
||||
}
|
||||
|
||||
if (tex.is_valid()) {
|
||||
temp_mesh_arr = bake_mesh_array_uv(temp_mesh_arr, tex);
|
||||
temp_mesh_arr[VisualServer::ARRAY_TEX_UV] = Variant();
|
||||
temp_mesh_arr[RenderingServer::ARRAY_TEX_UV] = Variant();
|
||||
|
||||
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->material_lod_get(_current_mesh);
|
||||
|
||||
if (lmat.is_valid()) {
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
RenderingServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,12 +573,12 @@ void PropInstancePropJob::step_type_simplify_mesh() {
|
||||
|
||||
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, temp_mesh_arr);
|
||||
|
||||
Ref<Material> lmat = _material_cache->material_lod_get(_current_mesh);
|
||||
|
||||
if (lmat.is_valid()) {
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
RenderingServer::get_singleton()->mesh_surface_set_material(mesh_rid, 0, lmat->get_rid());
|
||||
}
|
||||
|
||||
++_current_mesh;
|
||||
@ -591,13 +588,13 @@ void PropInstancePropJob::step_type_simplify_mesh() {
|
||||
}
|
||||
|
||||
Array PropInstancePropJob::merge_mesh_array(Array arr) const {
|
||||
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr);
|
||||
ERR_FAIL_COND_V(arr.size() != RenderingServer::ARRAY_MAX, arr);
|
||||
|
||||
PoolVector3Array verts = arr[VisualServer::ARRAY_VERTEX];
|
||||
PoolVector3Array normals = arr[VisualServer::ARRAY_NORMAL];
|
||||
PoolVector2Array uvs = arr[VisualServer::ARRAY_TEX_UV];
|
||||
PoolColorArray colors = arr[VisualServer::ARRAY_COLOR];
|
||||
PoolIntArray indices = arr[VisualServer::ARRAY_INDEX];
|
||||
PackedVector3Array verts = arr[RenderingServer::ARRAY_VERTEX];
|
||||
PackedVector3Array normals = arr[RenderingServer::ARRAY_NORMAL];
|
||||
PackedVector2Array uvs = arr[RenderingServer::ARRAY_TEX_UV];
|
||||
PackedColorArray colors = arr[RenderingServer::ARRAY_COLOR];
|
||||
PackedInt32Array indices = arr[RenderingServer::ARRAY_INDEX];
|
||||
|
||||
bool has_normals = normals.size() > 0;
|
||||
bool has_uvs = uvs.size() > 0;
|
||||
@ -619,14 +616,14 @@ Array PropInstancePropJob::merge_mesh_array(Array arr) const {
|
||||
int rem = equals[k];
|
||||
int remk = rem - k;
|
||||
|
||||
verts.remove(remk);
|
||||
verts.remove_at(remk);
|
||||
|
||||
if (has_normals)
|
||||
normals.remove(remk);
|
||||
normals.remove_at(remk);
|
||||
if (has_uvs)
|
||||
uvs.remove(remk);
|
||||
uvs.remove_at(remk);
|
||||
if (has_colors)
|
||||
colors.remove(remk);
|
||||
colors.remove_at(remk);
|
||||
|
||||
for (int j = 0; j < indices.size(); ++j) {
|
||||
int indx = indices[j];
|
||||
@ -641,39 +638,35 @@ Array PropInstancePropJob::merge_mesh_array(Array arr) const {
|
||||
++i;
|
||||
}
|
||||
|
||||
arr[VisualServer::ARRAY_VERTEX] = verts;
|
||||
arr[RenderingServer::ARRAY_VERTEX] = verts;
|
||||
|
||||
if (has_normals)
|
||||
arr[VisualServer::ARRAY_NORMAL] = normals;
|
||||
arr[RenderingServer::ARRAY_NORMAL] = normals;
|
||||
if (has_uvs)
|
||||
arr[VisualServer::ARRAY_TEX_UV] = uvs;
|
||||
arr[RenderingServer::ARRAY_TEX_UV] = uvs;
|
||||
if (has_colors)
|
||||
arr[VisualServer::ARRAY_COLOR] = colors;
|
||||
arr[RenderingServer::ARRAY_COLOR] = colors;
|
||||
|
||||
arr[VisualServer::ARRAY_INDEX] = indices;
|
||||
arr[RenderingServer::ARRAY_INDEX] = indices;
|
||||
|
||||
return arr;
|
||||
}
|
||||
Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_color) const {
|
||||
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr);
|
||||
Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref<Texture2D> tex, const float mul_color) const {
|
||||
ERR_FAIL_COND_V(arr.size() != RenderingServer::ARRAY_MAX, arr);
|
||||
ERR_FAIL_COND_V(!tex.is_valid(), arr);
|
||||
|
||||
Ref<Image> img = tex->get_data();
|
||||
Ref<Image> img = tex->get_image();
|
||||
|
||||
ERR_FAIL_COND_V(!img.is_valid(), arr);
|
||||
|
||||
Vector2 imgsize = img->get_size();
|
||||
|
||||
PoolVector2Array uvs = arr[VisualServer::ARRAY_TEX_UV];
|
||||
PoolColorArray colors = arr[VisualServer::ARRAY_COLOR];
|
||||
PackedVector2Array uvs = arr[RenderingServer::ARRAY_TEX_UV];
|
||||
PackedColorArray colors = arr[RenderingServer::ARRAY_COLOR];
|
||||
|
||||
if (colors.size() < uvs.size())
|
||||
colors.resize(uvs.size());
|
||||
|
||||
#if !GODOT4
|
||||
img->lock();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < uvs.size(); ++i) {
|
||||
Vector2 uv = uvs[i];
|
||||
uv *= imgsize;
|
||||
@ -686,11 +679,7 @@ Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const
|
||||
colors.set(i, colors[i] * c * mul_color);
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
img->unlock();
|
||||
#endif
|
||||
|
||||
arr[VisualServer::ARRAY_COLOR] = colors;
|
||||
arr[RenderingServer::ARRAY_COLOR] = colors;
|
||||
|
||||
return arr;
|
||||
}
|
||||
@ -707,12 +696,8 @@ void PropInstancePropJob::reset_meshes() {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
RID mesh_rid = _prop_instace->mesh_get(i);
|
||||
|
||||
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
#if !GODOT4
|
||||
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
|
||||
#else
|
||||
VS::get_singleton()->mesh_clear(mesh_rid);
|
||||
#endif
|
||||
if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
|
||||
RS::get_singleton()->mesh_clear(mesh_rid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class PropInstance;
|
||||
class PropInstanceMerger;
|
||||
class PropMesherJobStep;
|
||||
class PropMaterialCache;
|
||||
class Shape;
|
||||
class Shape3D;
|
||||
class PropLight;
|
||||
class PropDataTiledWall;
|
||||
|
||||
@ -51,7 +51,7 @@ public:
|
||||
void add_jobs_step(const Ref<PropMesherJobStep> &step);
|
||||
int get_jobs_step_count() const;
|
||||
|
||||
void add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape = false);
|
||||
void add_collision_shape(const Ref<Shape3D> &shape, const Transform3D &transform, const bool owns_shape = false);
|
||||
void clear_collision_shapes();
|
||||
|
||||
PropInstanceMerger *get_prop_instace();
|
||||
@ -62,11 +62,11 @@ public:
|
||||
void set_prop_mesher(const Ref<PropMesher> &mesher);
|
||||
|
||||
#if MESH_DATA_RESOURCE_PRESENT
|
||||
void add_mesh(const Ref<PropDataMeshData> &mesh_data, const Transform &base_transform);
|
||||
void add_mesh(const Ref<PropDataMeshData> &mesh_data, const Transform3D &base_transform);
|
||||
void clear_meshes();
|
||||
#endif
|
||||
|
||||
void add_tiled_wall(const Ref<PropDataTiledWall> &data, const Transform &base_transform);
|
||||
void add_tiled_wall(const Ref<PropDataTiledWall> &data, const Transform3D &base_transform);
|
||||
void clear_tiled_walls();
|
||||
|
||||
void add_light(const Ref<PropLight> &light);
|
||||
@ -89,7 +89,7 @@ public:
|
||||
void step_type_simplify_mesh();
|
||||
|
||||
Array merge_mesh_array(Array arr) const;
|
||||
Array bake_mesh_array_uv(Array arr, Ref<Texture> tex, float mul_color = 0.7) const;
|
||||
Array bake_mesh_array_uv(Array arr, Ref<Texture2D> tex, float mul_color = 0.7) const;
|
||||
|
||||
void reset_meshes();
|
||||
|
||||
@ -103,18 +103,18 @@ protected:
|
||||
#if MESH_DATA_RESOURCE_PRESENT
|
||||
struct PMDREntry {
|
||||
Ref<PropDataMeshData> mesh_data;
|
||||
Transform base_transform;
|
||||
Transform3D base_transform;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct PTWEntry {
|
||||
Ref<PropDataTiledWall> data;
|
||||
Transform base_transform;
|
||||
Transform3D base_transform;
|
||||
};
|
||||
|
||||
struct CollisionShapeEntry {
|
||||
Ref<Shape> shape;
|
||||
Transform transform;
|
||||
Ref<Shape3D> shape;
|
||||
Transform3D transform;
|
||||
bool owns_shape;
|
||||
|
||||
CollisionShapeEntry() {
|
||||
|
129
prop_mesher.cpp
129
prop_mesher.cpp
@ -23,7 +23,7 @@ SOFTWARE.
|
||||
#include "prop_mesher.h"
|
||||
|
||||
#include "lights/prop_light.h"
|
||||
#include "modules/opensimplex/open_simplex_noise.h"
|
||||
#include "modules/noise/fastnoise_lite.h"
|
||||
|
||||
#include "material_cache/prop_material_cache.h"
|
||||
#include "tiled_wall/tiled_wall_data.h"
|
||||
@ -155,15 +155,15 @@ _FORCE_INLINE_ void PropMesher::set_build_flags(const int flags) {
|
||||
_build_flags = flags;
|
||||
|
||||
if ((_build_flags & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) {
|
||||
_format |= VisualServer::ARRAY_FORMAT_COLOR;
|
||||
_format |= RenderingServer::ARRAY_FORMAT_COLOR;
|
||||
} else {
|
||||
_format ^= VisualServer::ARRAY_FORMAT_COLOR;
|
||||
_format ^= RenderingServer::ARRAY_FORMAT_COLOR;
|
||||
}
|
||||
}
|
||||
|
||||
Array PropMesher::build_mesh() {
|
||||
Array a;
|
||||
a.resize(VisualServer::ARRAY_MAX);
|
||||
a.resize(RenderingServer::ARRAY_MAX);
|
||||
|
||||
if (_vertices.size() == 0) {
|
||||
//Nothing to do
|
||||
@ -173,133 +173,70 @@ Array PropMesher::build_mesh() {
|
||||
{
|
||||
PoolVector<Vector3> array;
|
||||
array.resize(_vertices.size());
|
||||
#if !GODOT4
|
||||
PoolVector<Vector3>::Write w = array.write();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < _vertices.size(); ++i) {
|
||||
#if !GODOT4
|
||||
w[i] = _vertices[i].vertex;
|
||||
#else
|
||||
array.set(i, _vertices[i].vertex);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
w.release();
|
||||
#endif
|
||||
|
||||
a[VisualServer::ARRAY_VERTEX] = array;
|
||||
a[RenderingServer::ARRAY_VERTEX] = array;
|
||||
}
|
||||
|
||||
if ((_format & VisualServer::ARRAY_FORMAT_NORMAL) == 0) {
|
||||
if ((_format & RenderingServer::ARRAY_FORMAT_NORMAL) == 0) {
|
||||
generate_normals();
|
||||
}
|
||||
|
||||
{
|
||||
PoolVector<Vector3> array;
|
||||
array.resize(_vertices.size());
|
||||
#if !GODOT4
|
||||
PoolVector<Vector3>::Write w = array.write();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < _vertices.size(); ++i) {
|
||||
#if !GODOT4
|
||||
w[i] = _vertices[i].normal;
|
||||
#else
|
||||
array.set(i, _vertices[i].normal);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
w.release();
|
||||
#endif
|
||||
a[VisualServer::ARRAY_NORMAL] = array;
|
||||
a[RenderingServer::ARRAY_NORMAL] = array;
|
||||
}
|
||||
|
||||
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) {
|
||||
if ((_format & RenderingServer::ARRAY_FORMAT_COLOR) != 0) {
|
||||
PoolVector<Color> array;
|
||||
array.resize(_vertices.size());
|
||||
#if !GODOT4
|
||||
PoolVector<Color>::Write w = array.write();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < _vertices.size(); ++i) {
|
||||
#if !GODOT4
|
||||
w[i] = _vertices[i].color;
|
||||
#else
|
||||
array.set(i, _vertices[i].color);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
w.release();
|
||||
#endif
|
||||
a[VisualServer::ARRAY_COLOR] = array;
|
||||
a[RenderingServer::ARRAY_COLOR] = array;
|
||||
}
|
||||
|
||||
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) {
|
||||
if ((_format & RenderingServer::ARRAY_FORMAT_TEX_UV) != 0) {
|
||||
PoolVector<Vector2> array;
|
||||
array.resize(_vertices.size());
|
||||
#if !GODOT4
|
||||
PoolVector<Vector2>::Write w = array.write();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < _vertices.size(); ++i) {
|
||||
#if !GODOT4
|
||||
w[i] = _vertices[i].uv;
|
||||
#else
|
||||
array.set(i, _vertices[i].uv);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
w.release();
|
||||
#endif
|
||||
|
||||
a[VisualServer::ARRAY_TEX_UV] = array;
|
||||
a[RenderingServer::ARRAY_TEX_UV] = array;
|
||||
}
|
||||
|
||||
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV2) != 0) {
|
||||
if ((_format & RenderingServer::ARRAY_FORMAT_TEX_UV2) != 0) {
|
||||
PoolVector<Vector2> array;
|
||||
array.resize(_vertices.size());
|
||||
#if !GODOT4
|
||||
PoolVector<Vector2>::Write w = array.write();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < _vertices.size(); ++i) {
|
||||
#if !GODOT4
|
||||
w[i] = _vertices[i].uv2;
|
||||
#else
|
||||
array.set(i, _vertices[i].uv2);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
w.release();
|
||||
#endif
|
||||
a[VisualServer::ARRAY_TEX_UV2] = array;
|
||||
a[RenderingServer::ARRAY_TEX_UV2] = array;
|
||||
}
|
||||
|
||||
if (_indices.size() > 0) {
|
||||
PoolVector<int> array;
|
||||
array.resize(_indices.size());
|
||||
#if !GODOT4
|
||||
PoolVector<int>::Write w = array.write();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < _indices.size(); ++i) {
|
||||
#if !GODOT4
|
||||
w[i] = _indices[i];
|
||||
#else
|
||||
array.set(i, _indices[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GODOT4
|
||||
w.release();
|
||||
#endif
|
||||
a[VisualServer::ARRAY_INDEX] = array;
|
||||
a[RenderingServer::ARRAY_INDEX] = array;
|
||||
}
|
||||
|
||||
return a;
|
||||
@ -308,7 +245,7 @@ Array PropMesher::build_mesh() {
|
||||
void PropMesher::build_mesh_into(RID mesh) {
|
||||
ERR_FAIL_COND(mesh == RID());
|
||||
|
||||
VS::get_singleton()->mesh_clear(mesh);
|
||||
RS::get_singleton()->mesh_clear(mesh);
|
||||
|
||||
if (_vertices.size() == 0) {
|
||||
//Nothing to do
|
||||
@ -317,14 +254,14 @@ void PropMesher::build_mesh_into(RID mesh) {
|
||||
|
||||
Array arr = build_mesh();
|
||||
|
||||
VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VisualServer::PRIMITIVE_TRIANGLES, arr);
|
||||
RS::get_singleton()->mesh_add_surface_from_arrays(mesh, RenderingServer::PRIMITIVE_TRIANGLES, arr);
|
||||
|
||||
if (_material.is_valid())
|
||||
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _material->get_rid());
|
||||
RS::get_singleton()->mesh_surface_set_material(mesh, 0, _material->get_rid());
|
||||
}
|
||||
|
||||
void PropMesher::generate_normals(bool p_flip) {
|
||||
_format = _format | VisualServer::ARRAY_FORMAT_NORMAL;
|
||||
_format = _format | RenderingServer::ARRAY_FORMAT_NORMAL;
|
||||
|
||||
for (int i = 0; i < _indices.size(); i += 3) {
|
||||
int i0 = _indices[i];
|
||||
@ -426,7 +363,7 @@ void PropMesher::remove_doubles_hashed() {
|
||||
for (int j = 0; j < indices.size(); ++j) {
|
||||
int index = indices[j];
|
||||
|
||||
hashes.remove(index);
|
||||
hashes.remove_at(index);
|
||||
_vertices.remove_at(index);
|
||||
|
||||
//make all indices that were bigger than the one we replaced one lower
|
||||
@ -466,7 +403,7 @@ void PropMesher::reset() {
|
||||
_last_tangent = Plane();
|
||||
}
|
||||
|
||||
void PropMesher::add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref<TiledWallData> &tiled_wall_data, Ref<PropMaterialCache> cache) {
|
||||
void PropMesher::add_tiled_wall_simple(const int width, const int height, const Transform3D &transform, const Ref<TiledWallData> &tiled_wall_data, Ref<PropMaterialCache> cache) {
|
||||
ERR_FAIL_COND(!tiled_wall_data.is_valid());
|
||||
ERR_FAIL_COND(!cache.is_valid());
|
||||
ERR_FAIL_COND(width < 0);
|
||||
@ -610,7 +547,7 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const
|
||||
}
|
||||
}
|
||||
|
||||
void PropMesher::add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect) {
|
||||
void PropMesher::add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform3D &transform, const Rect2 &texture_rect) {
|
||||
int vc = get_vertex_count();
|
||||
|
||||
//x + 1, y
|
||||
@ -703,7 +640,7 @@ void PropMesher::add_mesh_data_resource_transform(Ref<MeshDataResource> mesh, co
|
||||
}
|
||||
}
|
||||
|
||||
void PropMesher::add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) {
|
||||
void PropMesher::add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PackedColorArray &colors, const Rect2 uv_rect) {
|
||||
if (mesh->get_array().size() == 0)
|
||||
return;
|
||||
|
||||
@ -1001,7 +938,7 @@ void PropMesher::bake_colors_lights() {
|
||||
}
|
||||
|
||||
#ifdef TERRAMAN_PRESENT
|
||||
void PropMesher::bake_lights(MeshInstance *node, Vector<Ref<TerrainLight>> &lights) {
|
||||
void PropMesher::bake_lights(MeshInstance3D *node, Vector<Ref<TerrainLight>> &lights) {
|
||||
ERR_FAIL_COND(node == NULL);
|
||||
|
||||
Color darkColor(0, 0, 0, 1);
|
||||
@ -1137,7 +1074,7 @@ Vector3 PropMesher::get_vertex(const int idx) const {
|
||||
}
|
||||
|
||||
void PropMesher::remove_vertex(const int idx) {
|
||||
_vertices.remove(idx);
|
||||
_vertices.remove_at(idx);
|
||||
}
|
||||
|
||||
PoolVector<Vector3> PropMesher::get_normals() const {
|
||||
@ -1285,7 +1222,7 @@ int PropMesher::get_index(const int idx) const {
|
||||
}
|
||||
|
||||
void PropMesher::remove_index(const int idx) {
|
||||
_indices.remove(idx);
|
||||
_indices.remove_at(idx);
|
||||
}
|
||||
|
||||
PropMesher::PropMesher() {
|
||||
@ -1301,13 +1238,13 @@ PropMesher::PropMesher() {
|
||||
|
||||
_build_flags = 0;
|
||||
|
||||
_format = VisualServer::ARRAY_FORMAT_NORMAL | VisualServer::ARRAY_FORMAT_TEX_UV;
|
||||
_format = RenderingServer::ARRAY_FORMAT_NORMAL | RenderingServer::ARRAY_FORMAT_TEX_UV;
|
||||
|
||||
_noise.instantiate();
|
||||
//todo add properties for these if needed
|
||||
_noise->set_octaves(4);
|
||||
_noise->set_period(30);
|
||||
_noise->set_persistence(0.3);
|
||||
_noise->set_fractal_octaves(4);
|
||||
_noise->set_frequency(30);
|
||||
_noise->set_fractal_lacunarity(0.3);
|
||||
|
||||
_rao_scale_factor = 0.6;
|
||||
_rao_seed = 2134;
|
||||
@ -1343,15 +1280,15 @@ void PropMesher::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_voxel_scale"), &PropMesher::get_voxel_scale);
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &PropMesher::set_voxel_scale);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "voxel_scale"), "set_voxel_scale", "get_voxel_scale");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_ao_strength"), &PropMesher::get_ao_strength);
|
||||
ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &PropMesher::set_ao_strength);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_strength"), "set_ao_strength", "get_ao_strength");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ao_strength"), "set_ao_strength", "get_ao_strength");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_base_light_value"), &PropMesher::get_base_light_value);
|
||||
ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &PropMesher::set_base_light_value);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_light_value"), "set_base_light_value", "get_base_light_value");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "base_light_value"), "set_base_light_value", "get_base_light_value");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_uv_margin"), &PropMesher::get_uv_margin);
|
||||
ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &PropMesher::set_uv_margin);
|
||||
@ -1374,7 +1311,7 @@ void PropMesher::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher::generate_ao);
|
||||
ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher::get_random_ao);
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher")));
|
||||
//BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher")));
|
||||
ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &PropMesher::add_mesher);
|
||||
ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &PropMesher::_add_mesher);
|
||||
|
||||
|
@ -60,7 +60,7 @@ using PoolVector = Vector<N>;
|
||||
#include "../terraman/data/terrain_light.h"
|
||||
#endif
|
||||
|
||||
class OpenSimplexNoise;
|
||||
class FastNoiseLite;
|
||||
class PropLight;
|
||||
class PropMaterialCache;
|
||||
class TiledWallData;
|
||||
@ -145,14 +145,14 @@ public:
|
||||
|
||||
void reset();
|
||||
|
||||
void add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref<TiledWallData> &tiled_wall_data, Ref<PropMaterialCache> cache);
|
||||
void add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect);
|
||||
void add_tiled_wall_simple(const int width, const int height, const Transform3D &transform, const Ref<TiledWallData> &tiled_wall_data, Ref<PropMaterialCache> cache);
|
||||
void add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform3D &transform, const Rect2 &texture_rect);
|
||||
Vector2 transform_uv(const Vector2 &uv, const Rect2 &rect) const;
|
||||
|
||||
#ifdef MESH_DATA_RESOURCE_PRESENT
|
||||
void add_mesh_data_resource(Ref<MeshDataResource> mesh, const Vector3 position = Vector3(0, 0, 0), const Vector3 rotation = Vector3(0, 0, 0), const Vector3 scale = Vector3(1.0, 1.0, 1.0), const Rect2 uv_rect = Rect2(0, 0, 1, 1));
|
||||
void add_mesh_data_resource_transform(Ref<MeshDataResource> mesh, const Transform transform, const Rect2 uv_rect = Rect2(0, 0, 1, 1));
|
||||
void add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1));
|
||||
void add_mesh_data_resource_transform(Ref<MeshDataResource> mesh, const Transform3D transform, const Rect2 uv_rect = Rect2(0, 0, 1, 1));
|
||||
void add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform3D transform, const PackedColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1));
|
||||
#endif
|
||||
|
||||
void generate_ao();
|
||||
@ -173,7 +173,7 @@ public:
|
||||
void bake_colors_lights();
|
||||
|
||||
#ifdef TERRAMAN_PRESENT
|
||||
void bake_lights(MeshInstance *node, Vector<Ref<TerrainLight>> &lights);
|
||||
void bake_lights(MeshInstance3D *node, Vector<Ref<TerrainLight>> &lights);
|
||||
#endif
|
||||
|
||||
Array build_mesh();
|
||||
@ -253,7 +253,7 @@ protected:
|
||||
Rect2 _uv_margin;
|
||||
int _build_flags;
|
||||
|
||||
Ref<OpenSimplexNoise> _noise;
|
||||
Ref<FastNoiseLite> _noise;
|
||||
float _rao_scale_factor;
|
||||
int _rao_seed;
|
||||
};
|
||||
|
@ -44,14 +44,14 @@ void PropSceneInstance::build() {
|
||||
|
||||
//this way we won't delete the user's nodes
|
||||
if (n->get_owner() == NULL) {
|
||||
n->queue_delete();
|
||||
n->queue_free();
|
||||
}
|
||||
}
|
||||
|
||||
if (!_scene.is_valid())
|
||||
return;
|
||||
|
||||
Node *n = _scene->instance();
|
||||
Node *n = _scene->instantiate();
|
||||
|
||||
add_child(n);
|
||||
|
||||
|
@ -61,7 +61,7 @@ void PropDataEntry::processor_process(Ref<PropData> prop_data, Node *node, const
|
||||
call("_processor_process", prop_data, node, transform);
|
||||
}
|
||||
Node *PropDataEntry::processor_get_node_for(const Transform &transform) {
|
||||
return call("_processor_get_node_for", transform);
|
||||
return Object::cast_to<Node>(call("_processor_get_node_for", transform));
|
||||
}
|
||||
bool PropDataEntry::processor_evaluate_children() {
|
||||
return call("_processor_evaluate_children");
|
||||
@ -87,24 +87,24 @@ PropDataEntry::~PropDataEntry() {
|
||||
void PropDataEntry::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_transform"), &PropDataEntry::get_transform);
|
||||
ClassDB::bind_method(D_METHOD("set_transform", "value"), &PropDataEntry::set_transform);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "transform"), "set_transform", "get_transform");
|
||||
|
||||
#if TEXTURE_PACKER_PRESENT
|
||||
BIND_VMETHOD(MethodInfo("_add_textures_into", PropertyInfo(Variant::OBJECT, "texture_packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker")));
|
||||
//BIND_VMETHOD(MethodInfo("_add_textures_into", PropertyInfo(Variant::OBJECT, "texture_packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropDataEntry::add_textures_into);
|
||||
#endif
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "handles"), "_processor_handles"));
|
||||
BIND_VMETHOD(MethodInfo("_processor_process",
|
||||
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"),
|
||||
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"),
|
||||
PropertyInfo(Variant::TRANSFORM, "transform")));
|
||||
//BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "handles"), "_processor_handles"));
|
||||
//BIND_VMETHOD(MethodInfo("_processor_process",
|
||||
// PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"),
|
||||
// PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"),
|
||||
// PropertyInfo(Variant::TRANSFORM3D, "transform")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), "_processor_get_node_for",
|
||||
PropertyInfo(Variant::TRANSFORM, "transform")));
|
||||
//BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), "_processor_get_node_for",
|
||||
// PropertyInfo(Variant::TRANSFORM3D, "transform")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "evaluate"), "_processor_evaluate_children"));
|
||||
//BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "evaluate"), "_processor_evaluate_children"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("processor_handles", "node"), &PropDataEntry::processor_handles);
|
||||
ClassDB::bind_method(D_METHOD("processor_process", "prop_data", "node", "transform"), &PropDataEntry::processor_process);
|
||||
|
@ -44,7 +44,7 @@ SOFTWARE.
|
||||
#include "../material_cache/prop_material_cache.h"
|
||||
#include "../tiled_wall/tiled_wall_data.h"
|
||||
|
||||
#include "core/hashfuncs.h"
|
||||
#include "core/templates/hashfuncs.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
|
||||
@ -116,10 +116,10 @@ void PropCache::set_margin(const int margin) {
|
||||
}
|
||||
#endif
|
||||
|
||||
PoolStringArray PropCache::material_paths_get() const {
|
||||
PackedStringArray PropCache::material_paths_get() const {
|
||||
return _material_paths;
|
||||
}
|
||||
void PropCache::material_paths_set(const PoolStringArray &value) {
|
||||
void PropCache::material_paths_set(const PackedStringArray &value) {
|
||||
_material_paths = value;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ Ref<PropMaterialCache> PropCache::material_cache_get(const Ref<PropData> &prop)
|
||||
ERR_FAIL_COND_V(!prop.is_valid(), Ref<PropMaterialCache>());
|
||||
|
||||
//get pointer's value as uint64
|
||||
uint64_t k = make_uint64_t<const PropData *>(*prop);
|
||||
uint64_t k = hash_make_uint64_t<const PropData *>(*prop);
|
||||
|
||||
_material_cache_mutex.lock();
|
||||
|
||||
@ -207,7 +207,7 @@ Ref<PropMaterialCache> PropCache::material_cache_get(const Ref<PropData> &prop)
|
||||
return m;
|
||||
}
|
||||
|
||||
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instance(_default_prop_material_cache_class));
|
||||
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instantiate(_default_prop_material_cache_class));
|
||||
|
||||
if (!p) {
|
||||
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
|
||||
@ -223,7 +223,7 @@ Ref<PropMaterialCache> PropCache::material_cache_get(const Ref<PropData> &prop)
|
||||
}
|
||||
void PropCache::material_cache_unref(const Ref<PropData> &prop) {
|
||||
//get pointer's value as uint64
|
||||
uint64_t k = make_uint64_t<const PropData *>(*prop);
|
||||
uint64_t k = hash_make_uint64_t<const PropData *>(*prop);
|
||||
|
||||
_material_cache_mutex.lock();
|
||||
|
||||
@ -249,7 +249,7 @@ Ref<PropMaterialCache> PropCache::tiled_wall_material_cache_get(const Ref<TiledW
|
||||
ERR_FAIL_COND_V(!twd.is_valid(), Ref<PropMaterialCache>());
|
||||
|
||||
//get pointer's value as uint64
|
||||
uint64_t k = make_uint64_t<const TiledWallData *>(*twd);
|
||||
uint64_t k = hash_make_uint64_t<const TiledWallData *>(*twd);
|
||||
|
||||
_tiled_wall_material_cache_mutex.lock();
|
||||
|
||||
@ -263,7 +263,7 @@ Ref<PropMaterialCache> PropCache::tiled_wall_material_cache_get(const Ref<TiledW
|
||||
return m;
|
||||
}
|
||||
|
||||
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instance(_default_prop_material_cache_class));
|
||||
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instantiate(_default_prop_material_cache_class));
|
||||
|
||||
if (!p) {
|
||||
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
|
||||
@ -279,7 +279,7 @@ Ref<PropMaterialCache> PropCache::tiled_wall_material_cache_get(const Ref<TiledW
|
||||
}
|
||||
void PropCache::tiled_wall_material_cache_unref(const Ref<TiledWallData> &twd) {
|
||||
//get pointer's value as uint64
|
||||
uint64_t k = make_uint64_t<const TiledWallData *>(*twd);
|
||||
uint64_t k = hash_make_uint64_t<const TiledWallData *>(*twd);
|
||||
|
||||
_tiled_wall_material_cache_mutex.lock();
|
||||
|
||||
@ -314,7 +314,7 @@ Ref<PropMaterialCache> PropCache::material_cache_custom_key_get(const uint64_t k
|
||||
return m;
|
||||
}
|
||||
|
||||
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instance(_default_prop_material_cache_class));
|
||||
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instantiate(_default_prop_material_cache_class));
|
||||
|
||||
if (!p) {
|
||||
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
|
||||
@ -350,19 +350,7 @@ void PropCache::material_cache_custom_key_unref(const uint64_t key) {
|
||||
}
|
||||
|
||||
Ref<Resource> PropCache::load_resource(const String &path, const String &type_hint) {
|
||||
_ResourceLoader *rl = _ResourceLoader::get_singleton();
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
Ref<ResourceInteractiveLoader> resl = rl->load_interactive(path, type_hint);
|
||||
|
||||
ERR_FAIL_COND_V(!resl.is_valid(), Ref<Resource>());
|
||||
|
||||
resl->wait();
|
||||
|
||||
return resl->get_resource();
|
||||
#else
|
||||
return rl->load(path, type_hint);
|
||||
#endif
|
||||
return ResourceLoader::load(path, type_hint);
|
||||
}
|
||||
|
||||
PropCache::PropCache() {
|
||||
@ -387,7 +375,7 @@ PropCache::PropCache() {
|
||||
_margin = GLOBAL_DEF("props/margin", 0);
|
||||
#endif
|
||||
|
||||
_material_paths = GLOBAL_DEF("props/material_paths", PoolStringArray());
|
||||
_material_paths = GLOBAL_DEF("props/material_paths", PackedStringArray());
|
||||
}
|
||||
|
||||
PropCache::~PropCache() {
|
||||
@ -423,7 +411,7 @@ void PropCache::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("material_paths_get"), &PropCache::material_paths_get);
|
||||
ClassDB::bind_method(D_METHOD("material_paths_set", "value"), &PropCache::material_paths_set);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "material_paths"), "material_paths_set", "material_paths_get");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_STRING_ARRAY, "material_paths"), "material_paths_set", "material_paths_get");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("material_add", "value"), &PropCache::material_add);
|
||||
ClassDB::bind_method(D_METHOD("material_get", "index"), &PropCache::material_get);
|
||||
|
@ -76,8 +76,8 @@ public:
|
||||
void set_margin(const int margin);
|
||||
#endif
|
||||
|
||||
PoolStringArray material_paths_get() const;
|
||||
void material_paths_set(const PoolStringArray &array);
|
||||
PackedStringArray material_paths_get() const;
|
||||
void material_paths_set(const PackedStringArray &array);
|
||||
|
||||
void material_add(const Ref<Material> &value);
|
||||
Ref<Material> material_get(const int index);
|
||||
@ -114,9 +114,9 @@ protected:
|
||||
|
||||
StringName _default_prop_material_cache_class;
|
||||
|
||||
Map<uint64_t, Ref<PropMaterialCache>> _material_cache;
|
||||
Map<uint64_t, Ref<PropMaterialCache>> _tiled_wall_material_cache;
|
||||
Map<uint64_t, Ref<PropMaterialCache>> _custom_keyed_material_cache;
|
||||
HashMap<uint64_t, Ref<PropMaterialCache>> _material_cache;
|
||||
HashMap<uint64_t, Ref<PropMaterialCache>> _tiled_wall_material_cache;
|
||||
HashMap<uint64_t, Ref<PropMaterialCache>> _custom_keyed_material_cache;
|
||||
|
||||
Mutex _material_cache_mutex;
|
||||
Mutex _tiled_wall_material_cache_mutex;
|
||||
@ -130,7 +130,7 @@ protected:
|
||||
int _margin;
|
||||
#endif
|
||||
|
||||
PoolStringArray _material_paths;
|
||||
PackedStringArray _material_paths;
|
||||
Vector<Ref<Material>> _materials;
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,9 @@ SOFTWARE.
|
||||
#include "scene/3d/room_manager.h"
|
||||
#endif
|
||||
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/3d/mesh_instance_3d.h"
|
||||
|
||||
#include "scene/3d/node_3d.h"
|
||||
|
||||
#if MESH_DATA_RESOURCE_PRESENT
|
||||
#include "../../mesh_data_resource/nodes/mesh_data_instance.h"
|
||||
@ -67,7 +69,7 @@ Ref<PropData> PropUtils::convert_tree(Node *root) {
|
||||
return data;
|
||||
}
|
||||
|
||||
void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transform &transform) {
|
||||
void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transform3D &transform) {
|
||||
#if VERSION_MAJOR < 4
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(node));
|
||||
#endif
|
||||
@ -88,7 +90,7 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
|
||||
}
|
||||
}
|
||||
|
||||
Spatial *sp = Object::cast_to<Spatial>(node);
|
||||
Node3D *sp = Object::cast_to<Node3D>(node);
|
||||
|
||||
if (!sp) {
|
||||
//reset transform
|
||||
@ -485,7 +487,7 @@ void PropUtils::swap_processors(const int index1, const int index2) {
|
||||
void PropUtils::remove_processor(const int index) {
|
||||
ERR_FAIL_INDEX(index, PropUtils::_processors.size());
|
||||
|
||||
PropUtils::_processors.remove(index);
|
||||
PropUtils::_processors.remove_at(index);
|
||||
}
|
||||
int PropUtils::get_processor_count() {
|
||||
return PropUtils::_processors.size();
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
static PropUtils *get_singleton();
|
||||
|
||||
Ref<PropData> convert_tree(Node *root);
|
||||
void _convert_tree(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
||||
void _convert_tree(Ref<PropData> prop_data, Node *node, const Transform3D &transform);
|
||||
|
||||
#if VERSION_MINOR >= 4
|
||||
bool generate_room_points_node(Node *node);
|
||||
|
@ -50,13 +50,13 @@ Ref<TiledWallData> TiledWall::get_data() {
|
||||
}
|
||||
void TiledWall::set_data(const Ref<TiledWallData> &data) {
|
||||
if (_data.is_valid()) {
|
||||
_data->disconnect(CoreStringNames::get_singleton()->changed, this, "refresh");
|
||||
_data->disconnect(CoreStringNames::get_singleton()->changed, Callable(this, "refresh"));
|
||||
}
|
||||
|
||||
_data = data;
|
||||
|
||||
if (_data.is_valid()) {
|
||||
_data->connect(CoreStringNames::get_singleton()->changed, this, "refresh");
|
||||
_data->connect(CoreStringNames::get_singleton()->changed, Callable(this, "refresh"));
|
||||
}
|
||||
|
||||
call_deferred("refresh");
|
||||
@ -88,7 +88,7 @@ void TiledWall::set_collision_layer(uint32_t p_layer) {
|
||||
_collision_layer = p_layer;
|
||||
|
||||
if (_physics_body_rid != RID()) {
|
||||
PhysicsServer::get_singleton()->area_set_collision_layer(_physics_body_rid, p_layer);
|
||||
PhysicsServer3D::get_singleton()->area_set_collision_layer(_physics_body_rid, p_layer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ void TiledWall::set_collision_mask(uint32_t p_mask) {
|
||||
_collision_mask = p_mask;
|
||||
|
||||
if (_physics_body_rid != RID()) {
|
||||
PhysicsServer::get_singleton()->area_set_collision_mask(_physics_body_rid, p_mask);
|
||||
PhysicsServer3D::get_singleton()->area_set_collision_mask(_physics_body_rid, p_mask);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,22 +108,21 @@ AABB TiledWall::get_aabb() const {
|
||||
return AABB();
|
||||
}
|
||||
|
||||
PoolVector<Face3> TiledWall::get_faces(uint32_t p_usage_flags) const {
|
||||
PoolVector<Face3> faces;
|
||||
Vector<Face3> TiledWall::get_faces(uint32_t p_usage_flags) const {
|
||||
Vector<Face3> faces;
|
||||
|
||||
if (_mesh_array.size() != Mesh::ARRAY_MAX) {
|
||||
return faces;
|
||||
}
|
||||
|
||||
PoolVector<Vector3> vertices = _mesh_array[Mesh::ARRAY_VERTEX];
|
||||
PoolVector<int> indices = _mesh_array[Mesh::ARRAY_INDEX];
|
||||
Vector<Vector3> vertices = _mesh_array[Mesh::ARRAY_VERTEX];
|
||||
Vector<int> indices = _mesh_array[Mesh::ARRAY_INDEX];
|
||||
|
||||
int ts = indices.size() / 3;
|
||||
faces.resize(ts);
|
||||
|
||||
PoolVector<Face3>::Write w = faces.write();
|
||||
PoolVector<Vector3>::Read rv = vertices.read();
|
||||
PoolVector<int>::Read ri = indices.read();
|
||||
Face3 *w = faces.ptrw();
|
||||
const Vector3 *rv = vertices.ptr();
|
||||
|
||||
for (int i = 0; i < ts; i++) {
|
||||
int im3 = (i * 3);
|
||||
@ -133,8 +132,6 @@ PoolVector<Face3> TiledWall::get_faces(uint32_t p_usage_flags) const {
|
||||
}
|
||||
}
|
||||
|
||||
w.release();
|
||||
|
||||
return faces;
|
||||
}
|
||||
|
||||
@ -158,9 +155,9 @@ void TiledWall::refresh() {
|
||||
}
|
||||
|
||||
if (_mesh_rid == RID()) {
|
||||
_mesh_rid = VisualServer::get_singleton()->mesh_create();
|
||||
_mesh_rid = RenderingServer::get_singleton()->mesh_create();
|
||||
|
||||
VS::get_singleton()->instance_set_base(get_instance(), _mesh_rid);
|
||||
RS::get_singleton()->instance_set_base(get_instance(), _mesh_rid);
|
||||
}
|
||||
|
||||
Ref<PropMaterialCache> old_cache;
|
||||
@ -223,12 +220,12 @@ void TiledWall::generate_mesh() {
|
||||
return;
|
||||
}
|
||||
|
||||
VisualServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, _mesh_array);
|
||||
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(_mesh_rid, RenderingServer::PRIMITIVE_TRIANGLES, _mesh_array);
|
||||
|
||||
Ref<Material> material = _cache->material_lod_get(0);
|
||||
|
||||
if (material.is_valid()) {
|
||||
VisualServer::get_singleton()->mesh_surface_set_material(_mesh_rid, 0, material->get_rid());
|
||||
RenderingServer::get_singleton()->mesh_surface_set_material(_mesh_rid, 0, material->get_rid());
|
||||
}
|
||||
|
||||
_aabb.size = Vector3(_width, _height, 0);
|
||||
@ -240,19 +237,19 @@ void TiledWall::clear_mesh() {
|
||||
_mesh_array.clear();
|
||||
|
||||
if (_mesh_rid != RID()) {
|
||||
if (VS::get_singleton()->mesh_get_surface_count(_mesh_rid) > 0)
|
||||
if (RS::get_singleton()->mesh_get_surface_count(_mesh_rid) > 0)
|
||||
#if VERSION_MAJOR < 4
|
||||
VS::get_singleton()->mesh_remove_surface(_mesh_rid, 0);
|
||||
#else
|
||||
VS::get_singleton()->mesh_clear(_mesh_rid);
|
||||
RS::get_singleton()->mesh_clear(_mesh_rid);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void TiledWall::free_mesh() {
|
||||
if (_mesh_rid != RID()) {
|
||||
VS::get_singleton()->instance_set_base(get_instance(), RID());
|
||||
VS::get_singleton()->free(_mesh_rid);
|
||||
RS::get_singleton()->instance_set_base(get_instance(), RID());
|
||||
RS::get_singleton()->free(_mesh_rid);
|
||||
_mesh_rid = RID();
|
||||
}
|
||||
}
|
||||
@ -264,17 +261,17 @@ void TiledWall::create_colliders() {
|
||||
|
||||
free_colliders();
|
||||
|
||||
ERR_FAIL_COND(!get_world().is_valid() && get_world()->get_space() == RID());
|
||||
ERR_FAIL_COND(!get_world_3d().is_valid() && get_world_3d()->get_space() == RID());
|
||||
|
||||
_physics_shape_rid = PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_BOX);
|
||||
_physics_shape_rid = PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_BOX);
|
||||
|
||||
PhysicsServer::get_singleton()->shape_set_data(_physics_shape_rid, Vector3(_width / 2.0, _height / 2.0, 0.01));
|
||||
PhysicsServer::get_singleton()->body_add_shape(_physics_body_rid, _physics_shape_rid);
|
||||
PhysicsServer3D::get_singleton()->shape_set_data(_physics_shape_rid, Vector3(_width / 2.0, _height / 2.0, 0.01));
|
||||
PhysicsServer3D::get_singleton()->body_add_shape(_physics_body_rid, _physics_shape_rid);
|
||||
}
|
||||
|
||||
void TiledWall::free_colliders() {
|
||||
if (_physics_shape_rid != RID()) {
|
||||
PhysicsServer::get_singleton()->free(_physics_shape_rid);
|
||||
PhysicsServer3D::get_singleton()->free(_physics_shape_rid);
|
||||
|
||||
_physics_shape_rid = RID();
|
||||
}
|
||||
@ -287,7 +284,8 @@ TiledWall::TiledWall() {
|
||||
_collision_layer = 1;
|
||||
_collision_mask = 1;
|
||||
|
||||
_physics_body_rid = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
|
||||
_physics_body_rid = PhysicsServer3D::get_singleton()->body_create();
|
||||
PhysicsServer3D::get_singleton()->body_set_mode(_physics_body_rid, PhysicsServer3D::BODY_MODE_STATIC);
|
||||
|
||||
#if VERSION_MINOR >= 4
|
||||
//temporary
|
||||
@ -301,7 +299,7 @@ TiledWall::~TiledWall() {
|
||||
_cache.unref();
|
||||
_mesher.unref();
|
||||
|
||||
PhysicsServer::get_singleton()->free(_physics_body_rid);
|
||||
PhysicsServer3D::get_singleton()->free(_physics_body_rid);
|
||||
|
||||
_physics_body_rid = RID();
|
||||
|
||||
@ -313,27 +311,27 @@ void TiledWall::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_WORLD: {
|
||||
Transform t = get_global_transform();
|
||||
t.translate(Vector3(_width / 2.0, _height / 2.0, 0));
|
||||
t.translate_local(Vector3(_width / 2.0, _height / 2.0, 0));
|
||||
|
||||
PhysicsServer::get_singleton()->body_set_state(_physics_body_rid, PhysicsServer::BODY_STATE_TRANSFORM, t);
|
||||
PhysicsServer3D::get_singleton()->body_set_state(_physics_body_rid, PhysicsServer3D::BODY_STATE_TRANSFORM, t);
|
||||
|
||||
RID space = get_world()->get_space();
|
||||
PhysicsServer::get_singleton()->body_set_space(_physics_body_rid, space);
|
||||
RID space = get_world_3d()->get_space();
|
||||
PhysicsServer3D::get_singleton()->body_set_space(_physics_body_rid, space);
|
||||
|
||||
refresh();
|
||||
|
||||
break;
|
||||
}
|
||||
case NOTIFICATION_EXIT_WORLD: {
|
||||
PhysicsServer::get_singleton()->body_set_space(_physics_body_rid, RID());
|
||||
PhysicsServer3D::get_singleton()->body_set_space(_physics_body_rid, RID());
|
||||
break;
|
||||
}
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
if (_collision) {
|
||||
Transform t = get_global_transform();
|
||||
t.translate(Vector3(_width / 2.0, _height / 2.0, 0));
|
||||
t.translate_local(Vector3(_width / 2.0, _height / 2.0, 0));
|
||||
|
||||
PhysicsServer::get_singleton()->body_set_state(_physics_body_rid, PhysicsServer::BODY_STATE_TRANSFORM, t);
|
||||
PhysicsServer3D::get_singleton()->body_set_state(_physics_body_rid, PhysicsServer3D::BODY_STATE_TRANSFORM, t);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
|
||||
AABB get_aabb() const;
|
||||
PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
|
||||
Vector<Face3> get_faces(uint32_t p_usage_flags) const;
|
||||
|
||||
void refresh();
|
||||
void generate_mesh();
|
||||
|
Loading…
Reference in New Issue
Block a user