Postfix every class with 2D.

This commit is contained in:
Relintai 2021-11-24 14:00:16 +01:00
parent ee35479d38
commit 6f802fcf68
54 changed files with 1452 additions and 1452 deletions

View File

@ -25,45 +25,45 @@ SOFTWARE.
#ifdef VOXELMAN_PRESENT
#include "../../voxelman/world/voxel_chunk.h"
bool GroundClutter::should_spawn(Ref<VoxelChunk> chunk, int x, int y, int z) {
bool GroundClutter2D::should_spawn(Ref<VoxelChunk> chunk, int x, int y, int z) {
if (has_method("_should_spawn"))
return call("_should_spawn", chunk, x, y, z);
return false;
}
void GroundClutter::add_meshes_to(Ref<VoxelMesher> mesher, Ref<VoxelChunk> chunk, int x, int y, int z) {
void GroundClutter2D::add_meshes_to(Ref<VoxelMesher> mesher, Ref<VoxelChunk> chunk, int x, int y, int z) {
if (has_method("_add_meshes_to"))
call("_add_meshes_to", mesher, chunk, x, y, z);
}
#endif
#ifdef TEXTURE_PACKER_PRESENT
void GroundClutter::add_textures_to(Ref<TexturePacker> packer) {
void GroundClutter2D::add_textures_to(Ref<TexturePacker> packer) {
if (has_method("_add_textures_to"))
call("_add_textures_to", packer);
}
#endif
GroundClutter::GroundClutter() {
GroundClutter2D::GroundClutter2D() {
}
GroundClutter::~GroundClutter() {
GroundClutter2D::~GroundClutter2D() {
}
void GroundClutter::_bind_methods() {
void GroundClutter2D::_bind_methods() {
#ifdef TEXTURE_PACKER_PRESENT
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);
ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter2D::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")));
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);
ClassDB::bind_method(D_METHOD("should_spawn", "chunk", "x", "y", "z"), &GroundClutter2D::should_spawn);
ClassDB::bind_method(D_METHOD("add_meshes_to", "mesher", "chunk", "x", "y", "z"), &GroundClutter2D::add_meshes_to);
#endif
}

View File

@ -42,8 +42,8 @@ SOFTWARE.
class VoxelChunk;
class VoxelMesher;
class GroundClutter : public Resource {
GDCLASS(GroundClutter, Resource);
class GroundClutter2D : public Resource {
GDCLASS(GroundClutter2D, Resource);
public:
#ifdef VOXELMAN_PRESENT
@ -56,8 +56,8 @@ public:
void add_textures_to(Ref<TexturePacker> packer);
#endif
GroundClutter();
~GroundClutter();
GroundClutter2D();
~GroundClutter2D();
private:
static void _bind_methods();

View File

@ -22,33 +22,33 @@ SOFTWARE.
#include "ground_clutter_foliage_2d.h"
int GroundClutterFoliage::get_texture_count() const {
int GroundClutterFoliage2D::get_texture_count() const {
return _textures.size();
}
Ref<Texture> GroundClutterFoliage::get_texture(const int index) {
Ref<Texture> GroundClutterFoliage2D::get_texture(const int index) {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture>());
return _textures.get(index);
}
void GroundClutterFoliage::remove_texture(const int index) {
void GroundClutterFoliage2D::remove_texture(const int index) {
ERR_FAIL_INDEX(index, _textures.size());
_textures.remove(index);
}
void GroundClutterFoliage::add_texture(Ref<Texture> texture) {
void GroundClutterFoliage2D::add_texture(Ref<Texture> texture) {
_textures.push_back(texture);
}
GroundClutterFoliage::GroundClutterFoliage() {
GroundClutterFoliage2D::GroundClutterFoliage2D() {
}
GroundClutterFoliage::~GroundClutterFoliage() {
GroundClutterFoliage2D::~GroundClutterFoliage2D() {
_textures.clear();
}
void GroundClutterFoliage::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_count"), &GroundClutterFoliage::get_texture_count);
ClassDB::bind_method(D_METHOD("get_texture", "index"), &GroundClutterFoliage::get_texture);
ClassDB::bind_method(D_METHOD("remove_texture", "index"), &GroundClutterFoliage::remove_texture);
ClassDB::bind_method(D_METHOD("add_texture", "texture"), &GroundClutterFoliage::add_texture);
void GroundClutterFoliage2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_count"), &GroundClutterFoliage2D::get_texture_count);
ClassDB::bind_method(D_METHOD("get_texture", "index"), &GroundClutterFoliage2D::get_texture);
ClassDB::bind_method(D_METHOD("remove_texture", "index"), &GroundClutterFoliage2D::remove_texture);
ClassDB::bind_method(D_METHOD("add_texture", "texture"), &GroundClutterFoliage2D::add_texture);
}

View File

@ -35,8 +35,8 @@ SOFTWARE.
#include "scene/resources/texture.h"
class GroundClutterFoliage : public GroundClutter {
GDCLASS(GroundClutterFoliage, GroundClutter);
class GroundClutterFoliage2D : public GroundClutter2D {
GDCLASS(GroundClutterFoliage2D, GroundClutter2D);
public:
int get_texture_count() const;
@ -44,8 +44,8 @@ public:
void remove_texture(const int index);
void add_texture(Ref<Texture> texture);
GroundClutterFoliage();
~GroundClutterFoliage();
GroundClutterFoliage2D();
~GroundClutterFoliage2D();
private:
static void _bind_methods();

View File

@ -10,29 +10,29 @@ def configure(env):
def get_doc_classes():
return [
"PropDataEntry",
"PropDataLight",
"PropDataProp",
"PropDataScene",
"PropDataPortal",
"PropDataTiledWall",
"PropData",
"PropDataEntry2D",
"PropDataLight2D",
"PropDataProp2D",
"PropDataScene2D",
"PropDataPortal2D",
"PropDataTiledWall2D",
"PropData2D",
"TiledWall",
"TiledWallData",
"TiledWall2D",
"TiledWallData2D",
"PropDataProcessor",
"PropDataProcessor2D",
"GroundClutterFoliage",
"GroundClutter",
"GroundClutterFoliage2D",
"GroundClutter2D",
"PropESSEntity",
"PropInstance",
"PropMeshUtils",
"PropESSEntity2D",
"PropInstance2D",
"PropMeshUtils2D",
"PropSceneInstance",
"PropSceneInstance2D",
"PropUtils",
"PropUtils2D",
]
def get_doc_path():

View File

@ -41,7 +41,7 @@ SOFTWARE.
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method))
#endif
void PropEditorPlugin::convert_active_scene_to_prop_data() {
void PropEditorPlugin2D::convert_active_scene_to_prop_data() {
SceneTree *st = SceneTree::get_singleton();
if (st) {
@ -55,17 +55,17 @@ void PropEditorPlugin::convert_active_scene_to_prop_data() {
}
}
}
void PropEditorPlugin::convert_selected_scene_to_prop_data() {
void PropEditorPlugin2D::convert_selected_scene_to_prop_data() {
}
void PropEditorPlugin::convert_scene(Node *root, const String &path) {
Ref<PropData> data = PropUtils::get_singleton()->convert_tree(root);
void PropEditorPlugin2D::convert_scene(Node *root, const String &path) {
Ref<PropData2D> data = PropUtils2D::get_singleton()->convert_tree(root);
ERR_FAIL_COND(!data.is_valid());
ResourceLoader l;
if (l.exists(path)) {
Ref<PropData> res = l.load(path, "PropData");
Ref<PropData2D> res = l.load(path, "PropData");
ERR_FAIL_COND(!res.is_valid());
@ -81,7 +81,7 @@ void PropEditorPlugin::convert_scene(Node *root, const String &path) {
}
}
void PropEditorPlugin::find_room_points(Variant param) {
void PropEditorPlugin2D::find_room_points(Variant param) {
#if VERSION_MINOR >= 4
SceneTree *st = SceneTree::get_singleton();
@ -89,24 +89,24 @@ void PropEditorPlugin::find_room_points(Variant param) {
Node *scene = st->get_edited_scene_root();
if (scene) {
PropUtils::get_singleton()->generate_room_points_node(scene);
PropUtils2D::get_singleton()->generate_room_points_node(scene);
}
}
#endif
}
void PropEditorPlugin::_quick_convert_button_pressed() {
void PropEditorPlugin2D::_quick_convert_button_pressed() {
convert_active_scene_to_prop_data();
}
void PropEditorPlugin::_convert_active_scene_to_prop_data(Variant param) {
void PropEditorPlugin2D::_convert_active_scene_to_prop_data(Variant param) {
convert_active_scene_to_prop_data();
}
void PropEditorPlugin::_convert_selected_scene_to_prop_data(Variant param) {
void PropEditorPlugin2D::_convert_selected_scene_to_prop_data(Variant param) {
convert_selected_scene_to_prop_data();
}
PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) {
PropEditorPlugin2D::PropEditorPlugin2D(EditorNode *p_node) {
editor = p_node;
#if VERSION_MAJOR < 4
@ -126,21 +126,21 @@ PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) {
container->add_child(b);
b->set_flat(true);
b->CONNECT("pressed", this, PropEditorPlugin, _quick_convert_button_pressed);
b->CONNECT("pressed", this, PropEditorPlugin2D, _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));
add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, container);
}
PropEditorPlugin::~PropEditorPlugin() {
PropEditorPlugin2D::~PropEditorPlugin2D() {
}
void PropEditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("convert_active_scene_to_prop_data"), &PropEditorPlugin::_convert_active_scene_to_prop_data);
ClassDB::bind_method(D_METHOD("convert_selected_scene_to_prop_data"), &PropEditorPlugin::_convert_active_scene_to_prop_data);
void PropEditorPlugin2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("convert_active_scene_to_prop_data"), &PropEditorPlugin2D::_convert_active_scene_to_prop_data);
ClassDB::bind_method(D_METHOD("convert_selected_scene_to_prop_data"), &PropEditorPlugin2D::_convert_active_scene_to_prop_data);
ClassDB::bind_method(D_METHOD("find_room_points"), &PropEditorPlugin::find_room_points);
ClassDB::bind_method(D_METHOD("find_room_points"), &PropEditorPlugin2D::find_room_points);
ClassDB::bind_method(D_METHOD("_quick_convert_button_pressed"), &PropEditorPlugin::_quick_convert_button_pressed);
ClassDB::bind_method(D_METHOD("_quick_convert_button_pressed"), &PropEditorPlugin2D::_quick_convert_button_pressed);
}

View File

@ -28,16 +28,16 @@ SOFTWARE.
#include "core/version.h"
class PropEditorPlugin : public EditorPlugin {
class PropEditorPlugin2D : public EditorPlugin {
GDCLASS(PropEditorPlugin, EditorPlugin);
GDCLASS(PropEditorPlugin2D, EditorPlugin);
EditorNode *editor;
protected:
static void _bind_methods();
public:
virtual String get_name() const { return "PropEditorPlugin"; }
virtual String get_name() const { return "PropEditorPlugin2D"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object) {}
virtual bool handles(Object *p_object) const { return false; }
@ -53,8 +53,8 @@ public:
void _convert_selected_scene_to_prop_data(Variant param);
void _quick_convert_button_pressed();
PropEditorPlugin(EditorNode *p_node);
~PropEditorPlugin();
PropEditorPlugin2D(EditorNode *p_node);
~PropEditorPlugin2D();
};
#endif

View File

@ -22,54 +22,54 @@ SOFTWARE.
#include "prop_mesher_job_step_2d.h"
const String PropMesherJobStep::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh";
const String PropMesherJobStep2D::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh";
PropMesherJobStep::PropMesherJobStepType PropMesherJobStep::get_job_type() const {
PropMesherJobStep2D::PropMesherJobStepType2D PropMesherJobStep2D::get_job_type() const {
return _job_type;
}
void PropMesherJobStep::set_job_type(const PropMesherJobStep::PropMesherJobStepType value) {
void PropMesherJobStep2D::set_job_type(const PropMesherJobStep2D::PropMesherJobStepType2D value) {
_job_type = value;
}
int PropMesherJobStep::get_lod_index() const {
int PropMesherJobStep2D::get_lod_index() const {
return _lod_index;
}
void PropMesherJobStep::set_lod_index(const int value) {
void PropMesherJobStep2D::set_lod_index(const int value) {
_lod_index = value;
}
#ifdef MESH_UTILS_PRESENT
Ref<FastQuadraticMeshSimplifier> PropMesherJobStep::get_fqms() {
Ref<FastQuadraticMeshSimplifier> PropMesherJobStep2D::get_fqms() {
return _fqms;
}
void PropMesherJobStep::set_fqms(const Ref<FastQuadraticMeshSimplifier> &val) {
void PropMesherJobStep2D::set_fqms(const Ref<FastQuadraticMeshSimplifier> &val) {
_fqms = val;
}
float PropMesherJobStep::get_simplification_step_ratio() const {
float PropMesherJobStep2D::get_simplification_step_ratio() const {
return _simplification_step_ratio;
}
void PropMesherJobStep::set_simplification_step_ratio(const float value) {
void PropMesherJobStep2D::set_simplification_step_ratio(const float value) {
_simplification_step_ratio = value;
}
int PropMesherJobStep::get_simplification_steps() const {
int PropMesherJobStep2D::get_simplification_steps() const {
return _simplification_steps;
}
void PropMesherJobStep::set_simplification_steps(const int value) {
void PropMesherJobStep2D::set_simplification_steps(const int value) {
_simplification_steps = value;
}
float PropMesherJobStep::get_simplification_agressiveness() const {
float PropMesherJobStep2D::get_simplification_agressiveness() const {
return _simplification_agressiveness;
}
void PropMesherJobStep::set_simplification_agressiveness(const float value) {
void PropMesherJobStep2D::set_simplification_agressiveness(const float value) {
_simplification_agressiveness = value;
}
#endif
PropMesherJobStep::PropMesherJobStep() {
PropMesherJobStep2D::PropMesherJobStep2D() {
_job_type = TYPE_NORMAL;
_lod_index = 0;
@ -80,36 +80,36 @@ PropMesherJobStep::PropMesherJobStep() {
#endif
}
PropMesherJobStep::~PropMesherJobStep() {
PropMesherJobStep2D::~PropMesherJobStep2D() {
#ifdef MESH_UTILS_PRESENT
_fqms.unref();
#endif
}
void PropMesherJobStep::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_job_type"), &PropMesherJobStep::get_job_type);
ClassDB::bind_method(D_METHOD("set_job_type", "value"), &PropMesherJobStep::set_job_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "job_type", PROPERTY_HINT_ENUM, PropMesherJobStep::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE), "set_job_type", "get_job_type");
void PropMesherJobStep2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_job_type"), &PropMesherJobStep2D::get_job_type);
ClassDB::bind_method(D_METHOD("set_job_type", "value"), &PropMesherJobStep2D::set_job_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "job_type", PROPERTY_HINT_ENUM, PropMesherJobStep2D::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE), "set_job_type", "get_job_type");
ClassDB::bind_method(D_METHOD("get_lod_index"), &PropMesherJobStep::get_lod_index);
ClassDB::bind_method(D_METHOD("set_lod_index", "value"), &PropMesherJobStep::set_lod_index);
ClassDB::bind_method(D_METHOD("get_lod_index"), &PropMesherJobStep2D::get_lod_index);
ClassDB::bind_method(D_METHOD("set_lod_index", "value"), &PropMesherJobStep2D::set_lod_index);
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_index"), "set_lod_index", "get_lod_index");
#ifdef MESH_UTILS_PRESENT
ClassDB::bind_method(D_METHOD("get_fqms"), &PropMesherJobStep::get_fqms);
ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep::set_fqms);
ClassDB::bind_method(D_METHOD("get_fqms"), &PropMesherJobStep2D::get_fqms);
ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep2D::set_fqms);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fqms", PROPERTY_HINT_RESOURCE_TYPE, "FastQuadraticMeshSimplifier"), "set_fqms", "get_fqms");
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);
ClassDB::bind_method(D_METHOD("get_simplification_step_ratio"), &PropMesherJobStep2D::get_simplification_step_ratio);
ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &PropMesherJobStep2D::set_simplification_step_ratio);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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);
ClassDB::bind_method(D_METHOD("get_simplification_steps"), &PropMesherJobStep2D::get_simplification_steps);
ClassDB::bind_method(D_METHOD("set_simplification_steps", "value"), &PropMesherJobStep2D::set_simplification_steps);
ADD_PROPERTY(PropertyInfo(Variant::INT, "simplification_steps"), "set_simplification_steps", "get_simplification_steps");
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);
ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &PropMesherJobStep2D::get_simplification_agressiveness);
ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &PropMesherJobStep2D::set_simplification_agressiveness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_agressiveness"), "set_simplification_agressiveness", "get_simplification_agressiveness");
#endif

View File

@ -35,15 +35,15 @@ SOFTWARE.
#include "../../mesh_utils/fast_quadratic_mesh_simplifier.h"
#endif
class PropMesherJobStep : public Reference {
GDCLASS(PropMesherJobStep, Reference);
class PropMesherJobStep2D : public Reference {
GDCLASS(PropMesherJobStep2D, Reference);
public:
//todo add:
//type generate lighting,
//type skip (this would leave the mesh empty)
//type previous mesh (this would set the previous mesh's rid to the current lod level)
enum PropMesherJobStepType {
enum PropMesherJobStepType2D {
TYPE_NORMAL = 0,
TYPE_NORMAL_LOD,
TYPE_DROP_UV2,
@ -55,8 +55,8 @@ public:
static const String BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE;
PropMesherJobStepType get_job_type() const;
void set_job_type(const PropMesherJobStepType value);
PropMesherJobStepType2D get_job_type() const;
void set_job_type(const PropMesherJobStepType2D value);
int get_lod_index() const;
void set_lod_index(const int value);
@ -75,13 +75,13 @@ public:
void set_simplification_agressiveness(const float value);
#endif
PropMesherJobStep();
~PropMesherJobStep();
PropMesherJobStep2D();
~PropMesherJobStep2D();
protected:
static void _bind_methods();
PropMesherJobStepType _job_type;
PropMesherJobStepType2D _job_type;
int _lod_index;
#ifdef MESH_UTILS_PRESENT
@ -92,6 +92,6 @@ protected:
#endif
};
VARIANT_ENUM_CAST(PropMesherJobStep::PropMesherJobStepType);
VARIANT_ENUM_CAST(PropMesherJobStep2D::PropMesherJobStepType2D);
#endif

View File

@ -27,16 +27,16 @@ SOFTWARE.
#endif
#if TEXTURE_PACKER_PRESENT
Ref<TexturePacker> PropTextureJob::get_merger() {
Ref<TexturePacker> PropTextureJob2D::get_merger() {
return _merger;
}
void PropTextureJob::set_merger(const Ref<TexturePacker> &merger) {
void PropTextureJob2D::set_merger(const Ref<TexturePacker> &merger) {
_merger = merger;
}
#endif
void PropTextureJob::_execute() {
void PropTextureJob2D::_execute() {
#if TEXTURE_PACKER_PRESENT
if (!_merger.is_valid()) {
set_complete(true);
@ -49,7 +49,7 @@ void PropTextureJob::_execute() {
set_complete(true);
}
PropTextureJob::PropTextureJob() {
PropTextureJob2D::PropTextureJob2D() {
#if !THREAD_POOL_PRESENT
_complete = true;
_cancelled = false;
@ -62,110 +62,110 @@ PropTextureJob::PropTextureJob() {
#endif
}
PropTextureJob::~PropTextureJob() {
PropTextureJob2D::~PropTextureJob2D() {
}
void PropTextureJob::_bind_methods() {
void PropTextureJob2D::_bind_methods() {
#if TEXTURE_PACKER_PRESENT
ClassDB::bind_method(D_METHOD("get_merger"), &PropTextureJob::get_merger);
ClassDB::bind_method(D_METHOD("set_merger", "value"), &PropTextureJob::set_merger);
ClassDB::bind_method(D_METHOD("get_merger"), &PropTextureJob2D::get_merger);
ClassDB::bind_method(D_METHOD("set_merger", "value"), &PropTextureJob2D::set_merger);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "merger", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"), "set_merger", "get_merger");
#endif
ClassDB::bind_method(D_METHOD("_execute"), &PropTextureJob::_execute);
ClassDB::bind_method(D_METHOD("_execute"), &PropTextureJob2D::_execute);
#if !THREAD_POOL_PRESENT
ClassDB::bind_method(D_METHOD("get_complete"), &PropTextureJob::get_complete);
ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropTextureJob::set_complete);
ClassDB::bind_method(D_METHOD("get_complete"), &PropTextureJob2D::get_complete);
ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropTextureJob2D::set_complete);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete");
ClassDB::bind_method(D_METHOD("get_start_time"), &PropTextureJob::get_start_time);
ClassDB::bind_method(D_METHOD("set_start_time", "value"), &PropTextureJob::set_start_time);
ClassDB::bind_method(D_METHOD("get_start_time"), &PropTextureJob2D::get_start_time);
ClassDB::bind_method(D_METHOD("set_start_time", "value"), &PropTextureJob2D::set_start_time);
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time");
ClassDB::bind_method(D_METHOD("get_current_run_stage"), &PropTextureJob::get_current_run_stage);
ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &PropTextureJob::set_current_run_stage);
ClassDB::bind_method(D_METHOD("get_current_run_stage"), &PropTextureJob2D::get_current_run_stage);
ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &PropTextureJob2D::set_current_run_stage);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage");
ClassDB::bind_method(D_METHOD("get_stage"), &PropTextureJob::get_stage);
ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropTextureJob::set_stage);
ClassDB::bind_method(D_METHOD("get_stage"), &PropTextureJob2D::get_stage);
ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropTextureJob2D::set_stage);
ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage");
ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropTextureJob::get_current_execution_time);
ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropTextureJob2D::get_current_execution_time);
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob::should_return);
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob2D::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob2D::should_return);
BIND_VMETHOD(MethodInfo("_execute"));
ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob::execute);
ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob2D::execute);
ADD_SIGNAL(MethodInfo("completed"));
#endif
}
#if !THREAD_POOL_PRESENT
bool PropTextureJob::get_complete() const {
bool PropTextureJob2D::get_complete() const {
return _complete;
}
void PropTextureJob::set_complete(const bool value) {
void PropTextureJob2D::set_complete(const bool value) {
_complete = value;
}
bool PropTextureJob::get_cancelled() const {
bool PropTextureJob2D::get_cancelled() const {
return _cancelled;
}
void PropTextureJob::set_cancelled(const bool value) {
void PropTextureJob2D::set_cancelled(const bool value) {
_cancelled = value;
}
float PropTextureJob::get_max_allocated_time() const {
float PropTextureJob2D::get_max_allocated_time() const {
return _max_allocated_time;
}
void PropTextureJob::set_max_allocated_time(const float value) {
void PropTextureJob2D::set_max_allocated_time(const float value) {
_max_allocated_time = value;
}
int PropTextureJob::get_start_time() const {
int PropTextureJob2D::get_start_time() const {
return _start_time;
}
void PropTextureJob::set_start_time(const int value) {
void PropTextureJob2D::set_start_time(const int value) {
_start_time = value;
}
int PropTextureJob::get_current_run_stage() const {
int PropTextureJob2D::get_current_run_stage() const {
return _current_run_stage;
}
void PropTextureJob::set_current_run_stage(const int value) {
void PropTextureJob2D::set_current_run_stage(const int value) {
_current_run_stage = value;
}
int PropTextureJob::get_stage() const {
int PropTextureJob2D::get_stage() const {
return _stage;
}
void PropTextureJob::set_stage(const int value) {
void PropTextureJob2D::set_stage(const int value) {
_stage = value;
}
void PropTextureJob::reset_stages() {
void PropTextureJob2D::reset_stages() {
_current_run_stage = 0;
_stage = 0;
}
float PropTextureJob::get_current_execution_time() {
float PropTextureJob2D::get_current_execution_time() {
return 0;
}
bool PropTextureJob::should_do(const bool just_check) {
bool PropTextureJob2D::should_do(const bool just_check) {
return true;
}
bool PropTextureJob::should_return() {
bool PropTextureJob2D::should_return() {
if (_cancelled)
return true;
return false;
}
void PropTextureJob::execute() {
void PropTextureJob2D::execute() {
ERR_FAIL_COND(!has_method("_execute"));
call("_execute");

View File

@ -43,11 +43,11 @@ class TexturePacker;
#endif
#if THREAD_POOL_PRESENT
class PropTextureJob : public ThreadPoolJob {
GDCLASS(PropTextureJob, ThreadPoolJob);
class PropTextureJob2D : public ThreadPoolJob {
GDCLASS(PropTextureJob2D, ThreadPoolJob);
#else
class PropTextureJob : public Reference {
GDCLASS(PropTextureJob, Reference);
class PropTextureJob2D : public Reference {
GDCLASS(PropTextureJob2D, Reference);
#endif
public:
@ -58,8 +58,8 @@ public:
void _execute();
PropTextureJob();
~PropTextureJob();
PropTextureJob2D();
~PropTextureJob2D();
protected:
static void _bind_methods();

View File

@ -22,44 +22,44 @@ SOFTWARE.
#include "prop_light_2d.h"
Vector3 PropLight::get_position() {
Vector3 PropLight2D::get_position() {
return _position;
}
void PropLight::set_position(const Vector3 &pos) {
void PropLight2D::set_position(const Vector3 &pos) {
_position = pos;
}
Color PropLight::get_color() const {
Color PropLight2D::get_color() const {
return _color;
}
void PropLight::set_color(const Color &color) {
void PropLight2D::set_color(const Color &color) {
_color = color;
}
float PropLight::get_size() const {
float PropLight2D::get_size() const {
return _size;
}
void PropLight::set_size(const float size) {
void PropLight2D::set_size(const float size) {
_size = size;
}
PropLight::PropLight() {
PropLight2D::PropLight2D() {
_size = 0;
}
PropLight::~PropLight() {
PropLight2D::~PropLight2D() {
}
void PropLight::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_position"), &PropLight::get_position);
ClassDB::bind_method(D_METHOD("set_position"), &PropLight::set_position);
void PropLight2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_position"), &PropLight2D::get_position);
ClassDB::bind_method(D_METHOD("set_position"), &PropLight2D::set_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "world_position"), "set_position", "get_position");
ClassDB::bind_method(D_METHOD("get_color"), &PropLight::get_color);
ClassDB::bind_method(D_METHOD("set_color"), &PropLight::set_color);
ClassDB::bind_method(D_METHOD("get_color"), &PropLight2D::get_color);
ClassDB::bind_method(D_METHOD("set_color"), &PropLight2D::set_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ClassDB::bind_method(D_METHOD("get_size"), &PropLight::get_size);
ClassDB::bind_method(D_METHOD("set_size"), &PropLight::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &PropLight2D::get_size);
ClassDB::bind_method(D_METHOD("set_size"), &PropLight2D::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
}

View File

@ -35,8 +35,8 @@ SOFTWARE.
#include "core/color.h"
#endif
class PropLight : public Reference {
GDCLASS(PropLight, Reference);
class PropLight2D : public Reference {
GDCLASS(PropLight2D, Reference);
public:
Vector3 get_position();
@ -48,8 +48,8 @@ public:
float get_size() const;
void set_size(const float strength);
PropLight();
~PropLight();
PropLight2D();
~PropLight2D();
private:
static void _bind_methods();

View File

@ -54,44 +54,44 @@ SOFTWARE.
#endif
bool PropMaterialCache::get_initialized() {
bool PropMaterialCache2D::get_initialized() {
return _initialized;
}
void PropMaterialCache::set_initialized(const bool value) {
void PropMaterialCache2D::set_initialized(const bool value) {
_initialized = value;
}
bool PropMaterialCache::mutex_locked() {
bool PropMaterialCache2D::mutex_locked() {
return _locked;
}
void PropMaterialCache::mutex_lock() {
void PropMaterialCache2D::mutex_lock() {
_mutex.lock();
}
void PropMaterialCache::mutex_unlock() {
void PropMaterialCache2D::mutex_unlock() {
_mutex.unlock();
}
int PropMaterialCache::get_ref_count() {
int PropMaterialCache2D::get_ref_count() {
return _ref_count;
}
void PropMaterialCache::set_ref_count(const int value) {
void PropMaterialCache2D::set_ref_count(const int value) {
_ref_count = value;
}
void PropMaterialCache::inc_ref_count() {
void PropMaterialCache2D::inc_ref_count() {
_ref_count += 1;
}
void PropMaterialCache::dec_ref_count() {
void PropMaterialCache2D::dec_ref_count() {
_ref_count -= 1;
}
//Materials
Ref<Material> PropMaterialCache::material_get(const int index) {
Ref<Material> PropMaterialCache2D::material_get(const int index) {
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
return _materials[index];
}
Ref<Material> PropMaterialCache::material_lod_get(const int index) {
Ref<Material> PropMaterialCache2D::material_lod_get(const int index) {
ERR_FAIL_COND_V(_materials.size() == 0, Ref<Material>(NULL));
if (index < 0) {
@ -105,35 +105,35 @@ Ref<Material> PropMaterialCache::material_lod_get(const int index) {
return _materials[index];
}
void PropMaterialCache::material_add(const Ref<Material> &value) {
void PropMaterialCache2D::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
void PropMaterialCache::material_set(const int index, const Ref<Material> &value) {
void PropMaterialCache2D::material_set(const int index, const Ref<Material> &value) {
ERR_FAIL_INDEX(index, _materials.size());
_materials.set(index, value);
}
void PropMaterialCache::material_remove(const int index) {
void PropMaterialCache2D::material_remove(const int index) {
_materials.remove(index);
}
int PropMaterialCache::material_get_num() const {
int PropMaterialCache2D::material_get_num() const {
return _materials.size();
}
void PropMaterialCache::materials_clear() {
void PropMaterialCache2D::materials_clear() {
_materials.clear();
}
Vector<Variant> PropMaterialCache::materials_get() {
Vector<Variant> PropMaterialCache2D::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void PropMaterialCache::materials_set(const Vector<Variant> &materials) {
void PropMaterialCache2D::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
@ -143,10 +143,10 @@ void PropMaterialCache::materials_set(const Vector<Variant> &materials) {
}
}
void PropMaterialCache::texture_add(const Ref<Texture> &texture) {
void PropMaterialCache2D::texture_add(const Ref<Texture> &texture) {
_textures.push_back(texture);
}
void PropMaterialCache::texture_remove(const Ref<Texture> &texture) {
void PropMaterialCache2D::texture_remove(const Ref<Texture> &texture) {
for (int i = 0; i < _textures.size(); ++i) {
if (_textures[i] == texture) {
_textures.remove(i);
@ -154,42 +154,42 @@ void PropMaterialCache::texture_remove(const Ref<Texture> &texture) {
}
}
}
void PropMaterialCache::texture_remove_index(const int index) {
void PropMaterialCache2D::texture_remove_index(const int index) {
ERR_FAIL_INDEX(index, _textures.size());
_textures.remove(index);
}
void PropMaterialCache::textures_clear() {
void PropMaterialCache2D::textures_clear() {
_textures.clear();
}
int PropMaterialCache::texture_count() {
int PropMaterialCache2D::texture_count() {
return _textures.size();
}
Ref<Texture> PropMaterialCache::texture_get(const int index) {
Ref<Texture> PropMaterialCache2D::texture_get(const int index) {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture>());
return _textures[index];
}
Ref<AtlasTexture> PropMaterialCache::texture_get_atlas(const int index) {
Ref<AtlasTexture> PropMaterialCache2D::texture_get_atlas(const int index) {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<AtlasTexture>());
return texture_get_atlas_tex(_textures[index]);
}
Ref<AtlasTexture> PropMaterialCache::texture_get_atlas_tex(const Ref<Texture> &texture) {
Ref<AtlasTexture> PropMaterialCache2D::texture_get_atlas_tex(const Ref<Texture> &texture) {
return Ref<AtlasTexture>();
}
Rect2 PropMaterialCache::texture_get_uv_rect(const Ref<Texture> &texture) {
Rect2 PropMaterialCache2D::texture_get_uv_rect(const Ref<Texture> &texture) {
return Rect2(0, 0, 1, 1);
}
void PropMaterialCache::prop_add_textures(const Ref<PropData> &prop) {
void PropMaterialCache2D::prop_add_textures(const Ref<PropData2D> &prop) {
if (!prop.is_valid()) {
return;
}
for (int i = 0; i < prop->get_prop_count(); ++i) {
#if MESH_DATA_RESOURCE_PRESENT
Ref<PropDataMeshData> pdm = prop->get_prop(i);
Ref<PropData2DMeshData> pdm = prop->get_prop(i);
if (pdm.is_valid()) {
Ref<Texture> tex = pdm->get_texture();
@ -203,34 +203,34 @@ void PropMaterialCache::prop_add_textures(const Ref<PropData> &prop) {
}
#endif
Ref<PropDataTiledWall> pdtw = prop->get_prop(i);
Ref<PropDataTiledWall2D> pdtw = prop->get_prop(i);
if (pdtw.is_valid()) {
Ref<TiledWallData> twd = pdtw->get_data();
Ref<TiledWallData2D> twd = pdtw->get_data();
if (!twd.is_valid())
continue;
twd->setup_cache(Ref<PropMaterialCache>(this));
twd->setup_cache(Ref<PropMaterialCache2D>(this));
continue;
}
Ref<PropDataProp> pdp = prop->get_prop(i);
Ref<PropDataProp2D> pdp = prop->get_prop(i);
if (pdp.is_valid()) {
prop_add_textures(pdp->get_prop());
}
}
}
void PropMaterialCache::prop_remove_textures(const Ref<PropData> &prop) {
void PropMaterialCache2D::prop_remove_textures(const Ref<PropData2D> &prop) {
if (!prop.is_valid()) {
return;
}
for (int i = 0; i < prop->get_prop_count(); ++i) {
#if MESH_DATA_RESOURCE_PRESENT
Ref<PropDataMeshData> pdm = prop->get_prop(i);
Ref<PropData2DMeshData> pdm = prop->get_prop(i);
if (pdm.is_valid()) {
Ref<Texture> tex = pdm->get_texture();
@ -242,10 +242,10 @@ void PropMaterialCache::prop_remove_textures(const Ref<PropData> &prop) {
}
#endif
Ref<PropDataTiledWall> pdtw = prop->get_prop(i);
Ref<PropDataTiledWall2D> pdtw = prop->get_prop(i);
if (pdtw.is_valid()) {
Ref<TiledWallData> twd = pdtw->get_data();
Ref<TiledWallData2D> twd = pdtw->get_data();
if (!twd.is_valid())
continue;
@ -269,7 +269,7 @@ void PropMaterialCache::prop_remove_textures(const Ref<PropData> &prop) {
continue;
}
Ref<PropDataProp> pdp = prop->get_prop(i);
Ref<PropDataProp2D> pdp = prop->get_prop(i);
if (pdp.is_valid()) {
prop_remove_textures(pdp);
@ -277,14 +277,14 @@ void PropMaterialCache::prop_remove_textures(const Ref<PropData> &prop) {
}
}
void PropMaterialCache::refresh_rects() {
void PropMaterialCache2D::refresh_rects() {
_initialized = true;
}
void PropMaterialCache::initial_setup_default() {
void PropMaterialCache2D::initial_setup_default() {
//Note: call only on the main thread! Shader->duplicate() can crash if done from an another thread!
PropCache *pc = PropCache::get_singleton();
PropCache2D *pc = PropCache2D::get_singleton();
pc->ensure_materials_loaded();
@ -300,64 +300,64 @@ void PropMaterialCache::initial_setup_default() {
}
}
void PropMaterialCache::setup_material_albedo(Ref<Texture> texture) {
void PropMaterialCache2D::setup_material_albedo(Ref<Texture> texture) {
if (has_method("_setup_material_albedo"))
call("_setup_material_albedo", texture);
}
PropMaterialCache::PropMaterialCache() {
PropMaterialCache2D::PropMaterialCache2D() {
_ref_count = 0;
_initialized = false;
_locked = false;
}
PropMaterialCache::~PropMaterialCache() {
PropMaterialCache2D::~PropMaterialCache2D() {
_materials.clear();
}
void PropMaterialCache::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_initialized"), &PropMaterialCache::get_initialized);
ClassDB::bind_method(D_METHOD("set_initialized", "value"), &PropMaterialCache::set_initialized);
void PropMaterialCache2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_initialized"), &PropMaterialCache2D::get_initialized);
ClassDB::bind_method(D_METHOD("set_initialized", "value"), &PropMaterialCache2D::set_initialized);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized"), "set_initialized", "get_initialized");
ClassDB::bind_method(D_METHOD("mutex_locked"), &PropMaterialCache::mutex_locked);
ClassDB::bind_method(D_METHOD("mutex_lock"), &PropMaterialCache::mutex_lock);
ClassDB::bind_method(D_METHOD("mutex_unlock"), &PropMaterialCache::mutex_unlock);
ClassDB::bind_method(D_METHOD("mutex_locked"), &PropMaterialCache2D::mutex_locked);
ClassDB::bind_method(D_METHOD("mutex_lock"), &PropMaterialCache2D::mutex_lock);
ClassDB::bind_method(D_METHOD("mutex_unlock"), &PropMaterialCache2D::mutex_unlock);
ClassDB::bind_method(D_METHOD("get_ref_count"), &PropMaterialCache::get_ref_count);
ClassDB::bind_method(D_METHOD("set_ref_count", "value"), &PropMaterialCache::set_ref_count);
ClassDB::bind_method(D_METHOD("get_ref_count"), &PropMaterialCache2D::get_ref_count);
ClassDB::bind_method(D_METHOD("set_ref_count", "value"), &PropMaterialCache2D::set_ref_count);
ADD_PROPERTY(PropertyInfo(Variant::INT, "mat_ref_count"), "set_ref_count", "get_ref_count");
ClassDB::bind_method(D_METHOD("inc_ref_count"), &PropMaterialCache::inc_ref_count);
ClassDB::bind_method(D_METHOD("dec_ref_count"), &PropMaterialCache::dec_ref_count);
ClassDB::bind_method(D_METHOD("inc_ref_count"), &PropMaterialCache2D::inc_ref_count);
ClassDB::bind_method(D_METHOD("dec_ref_count"), &PropMaterialCache2D::dec_ref_count);
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
ClassDB::bind_method(D_METHOD("material_get", "index"), &PropMaterialCache::material_get);
ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &PropMaterialCache::material_lod_get);
ClassDB::bind_method(D_METHOD("material_add", "value"), &PropMaterialCache::material_add);
ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropMaterialCache::material_set);
ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropMaterialCache::material_remove);
ClassDB::bind_method(D_METHOD("material_get_num"), &PropMaterialCache::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &PropMaterialCache::materials_clear);
ClassDB::bind_method(D_METHOD("material_get", "index"), &PropMaterialCache2D::material_get);
ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &PropMaterialCache2D::material_lod_get);
ClassDB::bind_method(D_METHOD("material_add", "value"), &PropMaterialCache2D::material_add);
ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropMaterialCache2D::material_set);
ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropMaterialCache2D::material_remove);
ClassDB::bind_method(D_METHOD("material_get_num"), &PropMaterialCache2D::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &PropMaterialCache2D::materials_clear);
ClassDB::bind_method(D_METHOD("materials_get"), &PropMaterialCache::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropMaterialCache::materials_set);
ClassDB::bind_method(D_METHOD("materials_get"), &PropMaterialCache2D::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropMaterialCache2D::materials_set);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
ClassDB::bind_method(D_METHOD("texture_add", "texture"), &PropMaterialCache::texture_add);
ClassDB::bind_method(D_METHOD("texture_remove", "texture"), &PropMaterialCache::texture_remove);
ClassDB::bind_method(D_METHOD("texture_remove_index", "index"), &PropMaterialCache::texture_remove_index);
ClassDB::bind_method(D_METHOD("textures_clear"), &PropMaterialCache::textures_clear);
ClassDB::bind_method(D_METHOD("texture_count"), &PropMaterialCache::texture_count);
ClassDB::bind_method(D_METHOD("texture_get", "index"), &PropMaterialCache::texture_get);
ClassDB::bind_method(D_METHOD("texture_get_atlas", "index"), &PropMaterialCache::texture_get_atlas);
ClassDB::bind_method(D_METHOD("texture_get_atlas_tex", "index"), &PropMaterialCache::texture_get_atlas_tex);
ClassDB::bind_method(D_METHOD("texture_get_uv_rect", "texture"), &PropMaterialCache::texture_get_uv_rect);
ClassDB::bind_method(D_METHOD("texture_add", "texture"), &PropMaterialCache2D::texture_add);
ClassDB::bind_method(D_METHOD("texture_remove", "texture"), &PropMaterialCache2D::texture_remove);
ClassDB::bind_method(D_METHOD("texture_remove_index", "index"), &PropMaterialCache2D::texture_remove_index);
ClassDB::bind_method(D_METHOD("textures_clear"), &PropMaterialCache2D::textures_clear);
ClassDB::bind_method(D_METHOD("texture_count"), &PropMaterialCache2D::texture_count);
ClassDB::bind_method(D_METHOD("texture_get", "index"), &PropMaterialCache2D::texture_get);
ClassDB::bind_method(D_METHOD("texture_get_atlas", "index"), &PropMaterialCache2D::texture_get_atlas);
ClassDB::bind_method(D_METHOD("texture_get_atlas_tex", "index"), &PropMaterialCache2D::texture_get_atlas_tex);
ClassDB::bind_method(D_METHOD("texture_get_uv_rect", "texture"), &PropMaterialCache2D::texture_get_uv_rect);
ClassDB::bind_method(D_METHOD("prop_add_textures", "prop"), &PropMaterialCache::prop_add_textures);
ClassDB::bind_method(D_METHOD("prop_remove_textures", "prop"), &PropMaterialCache::prop_remove_textures);
ClassDB::bind_method(D_METHOD("prop_add_textures", "prop"), &PropMaterialCache2D::prop_add_textures);
ClassDB::bind_method(D_METHOD("prop_remove_textures", "prop"), &PropMaterialCache2D::prop_remove_textures);
ClassDB::bind_method(D_METHOD("refresh_rects"), &PropMaterialCache::refresh_rects);
ClassDB::bind_method(D_METHOD("refresh_rects"), &PropMaterialCache2D::refresh_rects);
ClassDB::bind_method(D_METHOD("setup_material_albedo", "texture"), &PropMaterialCache::setup_material_albedo);
ClassDB::bind_method(D_METHOD("setup_material_albedo", "texture"), &PropMaterialCache2D::setup_material_albedo);
}

View File

@ -39,10 +39,10 @@ SOFTWARE.
#include "scene/resources/material.h"
#include "core/os/mutex.h"
class PropData;
class PropData2D;
class PropMaterialCache : public Resource {
GDCLASS(PropMaterialCache, Resource)
class PropMaterialCache2D : public Resource {
GDCLASS(PropMaterialCache2D, Resource)
public:
bool get_initialized();
@ -78,8 +78,8 @@ public:
virtual Ref<AtlasTexture> texture_get_atlas_tex(const Ref<Texture> &texture);
virtual Rect2 texture_get_uv_rect(const Ref<Texture> &texture);
void prop_add_textures(const Ref<PropData> &prop);
void prop_remove_textures(const Ref<PropData> &prop);
void prop_add_textures(const Ref<PropData2D> &prop);
void prop_remove_textures(const Ref<PropData2D> &prop);
virtual void refresh_rects();
@ -87,8 +87,8 @@ public:
void setup_material_albedo(Ref<Texture> texture);
PropMaterialCache();
~PropMaterialCache();
PropMaterialCache2D();
~PropMaterialCache2D();
protected:
static void _bind_methods();

View File

@ -26,49 +26,49 @@ SOFTWARE.
#include "../singleton/prop_cache_2d.h"
#include "scene/resources/texture.h"
int PropMaterialCachePCM::get_texture_flags() const {
int PropMaterialCachePCM2D::get_texture_flags() const {
return _packer->get_texture_flags();
}
void PropMaterialCachePCM::set_texture_flags(const int flags) {
void PropMaterialCachePCM2D::set_texture_flags(const int flags) {
_packer->set_texture_flags(flags);
}
int PropMaterialCachePCM::get_max_atlas_size() const {
int PropMaterialCachePCM2D::get_max_atlas_size() const {
return _packer->get_max_atlas_size();
}
void PropMaterialCachePCM::set_max_atlas_size(const int size) {
void PropMaterialCachePCM2D::set_max_atlas_size(const int size) {
_packer->set_max_atlas_size(size);
}
bool PropMaterialCachePCM::get_keep_original_atlases() const {
bool PropMaterialCachePCM2D::get_keep_original_atlases() const {
return _packer->get_keep_original_atlases();
}
void PropMaterialCachePCM::set_keep_original_atlases(const bool value) {
void PropMaterialCachePCM2D::set_keep_original_atlases(const bool value) {
_packer->set_keep_original_atlases(value);
}
Color PropMaterialCachePCM::get_background_color() const {
Color PropMaterialCachePCM2D::get_background_color() const {
return _packer->get_background_color();
}
void PropMaterialCachePCM::set_background_color(const Color &color) {
void PropMaterialCachePCM2D::set_background_color(const Color &color) {
_packer->set_background_color(color);
}
int PropMaterialCachePCM::get_margin() const {
int PropMaterialCachePCM2D::get_margin() const {
return _packer->get_margin();
}
void PropMaterialCachePCM::set_margin(const int margin) {
void PropMaterialCachePCM2D::set_margin(const int margin) {
_packer->set_margin(margin);
}
Ref<AtlasTexture> PropMaterialCachePCM::texture_get_atlas_tex(const Ref<Texture> &texture) {
Ref<AtlasTexture> PropMaterialCachePCM2D::texture_get_atlas_tex(const Ref<Texture> &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 PropMaterialCachePCM2D::texture_get_uv_rect(const Ref<Texture> &texture) {
if (!texture.is_valid()) {
return Rect2(0, 0, 1, 1);
}
@ -102,7 +102,7 @@ Rect2 PropMaterialCachePCM::texture_get_uv_rect(const Ref<Texture> &texture) {
return region;
}
void PropMaterialCachePCM::refresh_rects() {
void PropMaterialCachePCM2D::refresh_rects() {
bool texture_added = false;
for (int i = 0; i < _textures.size(); i++) {
@ -129,10 +129,10 @@ void PropMaterialCachePCM::refresh_rects() {
_initialized = true;
}
void PropMaterialCachePCM::initial_setup_default() {
PropMaterialCache::initial_setup_default();
void PropMaterialCachePCM2D::initial_setup_default() {
PropMaterialCache2D::initial_setup_default();
PropCache *pc = PropCache::get_singleton();
PropCache2D *pc = PropCache2D::get_singleton();
set_texture_flags(pc->get_texture_flags());
set_max_atlas_size(pc->get_max_atlas_size());
@ -141,7 +141,7 @@ void PropMaterialCachePCM::initial_setup_default() {
set_margin(pc->get_margin());
}
void PropMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
void PropMaterialCachePCM2D::_setup_material_albedo(Ref<Texture> texture) {
int count = material_get_num();
for (int i = 0; i < count; ++i) {
@ -162,7 +162,7 @@ void PropMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
}
}
PropMaterialCachePCM::PropMaterialCachePCM() {
PropMaterialCachePCM2D::PropMaterialCachePCM2D() {
_packer.instance();
#if GODOT4
@ -176,31 +176,31 @@ PropMaterialCachePCM::PropMaterialCachePCM() {
_packer->set_margin(0);
}
PropMaterialCachePCM::~PropMaterialCachePCM() {
PropMaterialCachePCM2D::~PropMaterialCachePCM2D() {
_packer->clear();
_packer.unref();
}
void PropMaterialCachePCM::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_flags"), &PropMaterialCachePCM::get_texture_flags);
ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropMaterialCachePCM::set_texture_flags);
void PropMaterialCachePCM2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_flags"), &PropMaterialCachePCM2D::get_texture_flags);
ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropMaterialCachePCM2D::set_texture_flags);
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_texture_flags", "get_texture_flags");
ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &PropMaterialCachePCM::get_max_atlas_size);
ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropMaterialCachePCM::set_max_atlas_size);
ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &PropMaterialCachePCM2D::get_max_atlas_size);
ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropMaterialCachePCM2D::set_max_atlas_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_atlas_size"), "set_max_atlas_size", "get_max_atlas_size");
ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &PropMaterialCachePCM::get_keep_original_atlases);
ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropMaterialCachePCM::set_keep_original_atlases);
ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &PropMaterialCachePCM2D::get_keep_original_atlases);
ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropMaterialCachePCM2D::set_keep_original_atlases);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases");
ClassDB::bind_method(D_METHOD("get_background_color"), &PropMaterialCachePCM::get_background_color);
ClassDB::bind_method(D_METHOD("set_background_color", "color"), &PropMaterialCachePCM::set_background_color);
ClassDB::bind_method(D_METHOD("get_background_color"), &PropMaterialCachePCM2D::get_background_color);
ClassDB::bind_method(D_METHOD("set_background_color", "color"), &PropMaterialCachePCM2D::set_background_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color");
ClassDB::bind_method(D_METHOD("get_margin"), &PropMaterialCachePCM::get_margin);
ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropMaterialCachePCM::set_margin);
ClassDB::bind_method(D_METHOD("get_margin"), &PropMaterialCachePCM2D::get_margin);
ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropMaterialCachePCM2D::set_margin);
ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin");
ClassDB::bind_method(D_METHOD("_setup_material_albedo", "texture"), &PropMaterialCachePCM::_setup_material_albedo);
ClassDB::bind_method(D_METHOD("_setup_material_albedo", "texture"), &PropMaterialCachePCM2D::_setup_material_albedo);
}

View File

@ -43,8 +43,8 @@ SOFTWARE.
class TexturePacker;
class PropData;
class PropMaterialCachePCM : public PropMaterialCache {
GDCLASS(PropMaterialCachePCM, PropMaterialCache);
class PropMaterialCachePCM2D : public PropMaterialCache2D {
GDCLASS(PropMaterialCachePCM2D, PropMaterialCache2D);
public:
int get_texture_flags() const;
@ -71,8 +71,8 @@ public:
void _setup_material_albedo(Ref<Texture> texture);
PropMaterialCachePCM();
~PropMaterialCachePCM();
PropMaterialCachePCM2D();
~PropMaterialCachePCM2D();
protected:
static void _bind_methods();

View File

@ -1,9 +1,9 @@
#include "prop_ess_entity_2d.h"
PropESSEntity::PropESSEntity() {
PropESSEntity2D::PropESSEntity2D() {
}
PropESSEntity::~PropESSEntity() {
PropESSEntity2D::~PropESSEntity2D() {
}
void PropESSEntity::_bind_methods() {
void PropESSEntity2D::_bind_methods() {
}

View File

@ -35,13 +35,13 @@ SOFTWARE.
#include "core/math/vector3.h"
class PropESSEntity : public Spatial {
GDCLASS(PropESSEntity, Spatial);
class PropESSEntity2D : public Spatial {
GDCLASS(PropESSEntity2D, Spatial);
OBJ_CATEGORY("Props");
public:
PropESSEntity();
~PropESSEntity();
PropESSEntity2D();
~PropESSEntity2D();
protected:
static void _bind_methods();

View File

@ -28,10 +28,10 @@
#include "tiled_wall/tiled_wall_2d.h"
#include "tiled_wall/tiled_wall_data_2d.h"
Ref<PropData> PropInstance::get_prop_data() {
Ref<PropData2D> PropInstance2D::get_prop_data() {
return _prop_data;
}
void PropInstance::set_prop_data(const Ref<PropData> &data) {
void PropInstance2D::set_prop_data(const Ref<PropData2D> &data) {
if (_prop_data == data)
return;
@ -44,58 +44,58 @@ void PropInstance::set_prop_data(const Ref<PropData> &data) {
}
}
Ref<Material> PropInstance::get_material() {
Ref<Material> PropInstance2D::get_material() {
return _material;
}
void PropInstance::set_material(const Ref<Material> &material) {
void PropInstance2D::set_material(const Ref<Material> &material) {
_material = material;
}
uint32_t PropInstance::get_collision_layer() const {
uint32_t PropInstance2D::get_collision_layer() const {
return _collision_layer;
}
void PropInstance::set_collision_layer(uint32_t p_layer) {
void PropInstance2D::set_collision_layer(uint32_t p_layer) {
_collision_layer = p_layer;
collision_layer_changed();
}
uint32_t PropInstance::get_collision_mask() const {
uint32_t PropInstance2D::get_collision_mask() const {
return _collision_mask;
}
void PropInstance::set_collision_mask(uint32_t p_mask) {
void PropInstance2D::set_collision_mask(uint32_t p_mask) {
_collision_mask = p_mask;
collision_mask_changed();
}
void PropInstance::collision_layer_changed() {
void PropInstance2D::collision_layer_changed() {
}
void PropInstance::collision_mask_changed() {
void PropInstance2D::collision_mask_changed() {
}
void PropInstance::init_materials() {
void PropInstance2D::init_materials() {
call("_init_materials");
}
void PropInstance::_init_materials() {
void PropInstance2D::_init_materials() {
}
void PropInstance::build() {
void PropInstance2D::build() {
call("_build");
}
void PropInstance::queue_build() {
void PropInstance2D::queue_build() {
_build_queued = true;
}
void PropInstance::build_finished() {
void PropInstance2D::build_finished() {
call("_build_finished");
}
void PropInstance::_build() {
void PropInstance2D::_build() {
_building = true;
_build_queued = false;
@ -118,7 +118,7 @@ void PropInstance::_build() {
prop_preprocess(Transform(), _prop_data);
}
void PropInstance::_build_finished() {
void PropInstance2D::_build_finished() {
_building = false;
if (_build_queued) {
@ -126,28 +126,28 @@ void PropInstance::_build_finished() {
}
}
void PropInstance::prop_preprocess(Transform transform, const Ref<PropData> &prop) {
void PropInstance2D::prop_preprocess(Transform transform, const Ref<PropData2D> &prop) {
call("_prop_preprocess", transform, prop);
}
void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &prop) {
void PropInstance2D::_prop_preprocess(Transform transform, const Ref<PropData2D> &prop) {
//don't set owners, to help working with the editor
ERR_FAIL_COND(!prop.is_valid());
int count = prop->get_prop_count();
for (int i = 0; i < count; ++i) {
Ref<PropDataEntry> e = prop->get_prop(i);
Ref<PropDataEntry2D> e = prop->get_prop(i);
if (!e.is_valid())
continue;
Transform t = transform * e->get_transform();
Ref<PropDataProp> prop_entry_data = e;
Ref<PropDataProp2D> prop_entry_data = e;
if (prop_entry_data.is_valid()) {
Ref<PropData> p = prop_entry_data->get_prop();
Ref<PropData2D> p = prop_entry_data->get_prop();
if (!p.is_valid())
continue;
@ -157,10 +157,10 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
continue;
}
Ref<PropDataTiledWall> tiled_wall_data = e;
Ref<PropDataTiledWall2D> tiled_wall_data = e;
if (tiled_wall_data.is_valid()) {
TiledWall *twn = memnew(TiledWall);
TiledWall2D *twn = memnew(TiledWall2D);
twn->set_width(tiled_wall_data->get_width());
twn->set_heigth(tiled_wall_data->get_heigth());
@ -174,7 +174,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
continue;
}
Ref<PropDataScene> scene_data = e;
Ref<PropDataScene2D> scene_data = e;
if (scene_data.is_valid()) {
Ref<PackedScene> sc = scene_data->get_scene();
@ -194,7 +194,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
continue;
}
Ref<PropDataLight> light_data = e;
Ref<PropDataLight2D> light_data = e;
if (light_data.is_valid()) {
OmniLight *light = memnew(OmniLight);
@ -207,7 +207,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
}
#if MESH_DATA_RESOURCE_PRESENT
Ref<PropDataMeshData> mesh_data = e;
Ref<PropDataMeshData2D> mesh_data = e;
if (mesh_data.is_valid()) {
Ref<MeshDataResource> mdr = mesh_data->get_mesh();
@ -251,7 +251,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &pr
}
}
PropInstance::PropInstance() {
PropInstance2D::PropInstance2D() {
_build_queued = false;
_building = false;
@ -259,11 +259,11 @@ PropInstance::PropInstance() {
_collision_mask = 1;
}
PropInstance::~PropInstance() {
PropInstance2D::~PropInstance2D() {
_prop_data.unref();
}
void PropInstance::_notification(int p_what) {
void PropInstance2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (_prop_data.is_valid()) {
@ -275,20 +275,20 @@ void PropInstance::_notification(int p_what) {
}
}
void PropInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_prop_data"), &PropInstance::get_prop_data);
ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &PropInstance::set_prop_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop_data", "get_prop_data");
void PropInstance2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_prop_data"), &PropInstance2D::get_prop_data);
ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &PropInstance2D::set_prop_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"), "set_prop_data", "get_prop_data");
ClassDB::bind_method(D_METHOD("get_material"), &PropInstance::get_material);
ClassDB::bind_method(D_METHOD("set_material", "material"), &PropInstance::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &PropInstance2D::get_material);
ClassDB::bind_method(D_METHOD("set_material", "material"), &PropInstance2D::set_material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material");
ClassDB::bind_method(D_METHOD("get_collision_layer"), &PropInstance::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PropInstance::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &PropInstance2D::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PropInstance2D::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &PropInstance::get_collision_mask);
ClassDB::bind_method(D_METHOD("set_collision_mask", "layer"), &PropInstance::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &PropInstance2D::get_collision_mask);
ClassDB::bind_method(D_METHOD("set_collision_mask", "layer"), &PropInstance2D::set_collision_mask);
ADD_GROUP("Collision", "collision_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
@ -296,25 +296,25 @@ void PropInstance::_bind_methods() {
BIND_VMETHOD(MethodInfo("_prop_preprocess",
PropertyInfo(Variant::TRANSFORM, "tarnsform"),
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D")));
ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance::prop_preprocess);
ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance::_prop_preprocess);
ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance2D::prop_preprocess);
ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance2D::_prop_preprocess);
//---
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);
ClassDB::bind_method(D_METHOD("init_materials"), &PropInstance2D::init_materials);
ClassDB::bind_method(D_METHOD("_init_materials"), &PropInstance2D::_init_materials);
//---
ClassDB::bind_method(D_METHOD("build"), &PropInstance::build);
ClassDB::bind_method(D_METHOD("queue_build"), &PropInstance::queue_build);
ClassDB::bind_method(D_METHOD("build_finished"), &PropInstance::build_finished);
ClassDB::bind_method(D_METHOD("build"), &PropInstance2D::build);
ClassDB::bind_method(D_METHOD("queue_build"), &PropInstance2D::queue_build);
ClassDB::bind_method(D_METHOD("build_finished"), &PropInstance2D::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);
ClassDB::bind_method(D_METHOD("_build"), &PropInstance2D::_build);
ClassDB::bind_method(D_METHOD("_build_finished"), &PropInstance2D::_build_finished);
}

View File

@ -39,12 +39,12 @@ SOFTWARE.
#include "props/prop_data_2d.h"
class PropInstance : public Spatial {
GDCLASS(PropInstance, Spatial);
class PropInstance2D : public Spatial {
GDCLASS(PropInstance2D, Spatial);
public:
Ref<PropData> get_prop_data();
void set_prop_data(const Ref<PropData> &data);
Ref<PropData2D> get_prop_data();
void set_prop_data(const Ref<PropData2D> &data);
Ref<Material> get_material();
void set_material(const Ref<Material> &material);
@ -68,18 +68,18 @@ public:
virtual void _build();
virtual void _build_finished();
void prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
virtual void _prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
void prop_preprocess(Transform tarnsform, const Ref<PropData2D> &prop);
virtual void _prop_preprocess(Transform tarnsform, const Ref<PropData2D> &prop);
PropInstance();
~PropInstance();
PropInstance2D();
~PropInstance2D();
protected:
void _notification(int p_what);
static void _bind_methods();
protected:
Ref<PropData> _prop_data;
Ref<PropData2D> _prop_data;
Ref<Material> _material;
uint32_t _collision_layer;

View File

@ -28,47 +28,47 @@ SOFTWARE.
#include "../opensimplex/open_simplex_noise.h"
const String PropInstanceJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process";
const String PropInstanceJob2D::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process";
PropInstanceJob::ActiveBuildPhaseType PropInstanceJob::get_build_phase_type() {
PropInstanceJob2D::ActiveBuildPhaseType PropInstanceJob2D::get_build_phase_type() {
return _build_phase_type;
}
void PropInstanceJob::set_build_phase_type(PropInstanceJob::ActiveBuildPhaseType build_phase_type) {
void PropInstanceJob2D::set_build_phase_type(PropInstanceJob2D::ActiveBuildPhaseType build_phase_type) {
_build_phase_type = build_phase_type;
}
void PropInstanceJob::set_prop(const Ref<PropData> &prop) {
void PropInstanceJob2D::set_prop(const Ref<PropData2D> &prop) {
_prop = prop;
_in_tree = true;
}
void PropInstanceJob::set_prop_instance(PropInstance *instance) {
void PropInstanceJob2D::set_prop_instance(PropInstance2D *instance) {
_instance = instance;
}
void PropInstanceJob::set_prop_instance_bind(Node *instance) {
set_prop_instance(Object::cast_to<PropInstance>(instance));
void PropInstanceJob2D::set_prop_instance_bind(Node *instance) {
set_prop_instance(Object::cast_to<PropInstance2D>(instance));
}
int PropInstanceJob::get_phase() {
int PropInstanceJob2D::get_phase() {
return _phase;
}
void PropInstanceJob::set_phase(const int phase) {
void PropInstanceJob2D::set_phase(const int phase) {
_phase = phase;
}
void PropInstanceJob::next_phase() {
void PropInstanceJob2D::next_phase() {
++_phase;
}
bool PropInstanceJob::get_build_done() {
bool PropInstanceJob2D::get_build_done() {
return _build_done;
}
void PropInstanceJob::set_build_done(const bool val) {
void PropInstanceJob2D::set_build_done(const bool val) {
_build_done = val;
}
void PropInstanceJob::finished() {
void PropInstanceJob2D::finished() {
set_build_done(true);
if (_instance) {
@ -76,15 +76,15 @@ void PropInstanceJob::finished() {
}
}
void PropInstanceJob::reset() {
void PropInstanceJob2D::reset() {
call("_reset");
}
void PropInstanceJob::_reset() {
void PropInstanceJob2D::_reset() {
_build_done = false;
_phase = 0;
}
void PropInstanceJob::_execute() {
void PropInstanceJob2D::_execute() {
ActiveBuildPhaseType origpt = _build_phase_type;
while (!get_cancelled() && _in_tree && !_build_done && origpt == _build_phase_type && !should_return()) {
@ -92,28 +92,28 @@ void PropInstanceJob::_execute() {
}
}
void PropInstanceJob::execute_phase() {
void PropInstanceJob2D::execute_phase() {
call("_execute_phase");
}
void PropInstanceJob::_execute_phase() {
void PropInstanceJob2D::_execute_phase() {
finished();
}
void PropInstanceJob::process(const float delta) {
void PropInstanceJob2D::process(const float delta) {
if (has_method("_process"))
call("_process", delta);
}
void PropInstanceJob::physics_process(const float delta) {
void PropInstanceJob2D::physics_process(const float delta) {
if (has_method("_physics_process"))
call("_physics_process", delta);
}
void PropInstanceJob::prop_instance_enter_tree() {
void PropInstanceJob2D::prop_instance_enter_tree() {
_in_tree = true;
}
void PropInstanceJob::prop_instance_exit_tree() {
void PropInstanceJob2D::prop_instance_exit_tree() {
_in_tree = false;
if (get_complete()) {
@ -123,7 +123,7 @@ void PropInstanceJob::prop_instance_exit_tree() {
}
}
PropInstanceJob::PropInstanceJob() {
PropInstanceJob2D::PropInstanceJob2D() {
_instance = NULL;
_in_tree = false;
@ -143,137 +143,137 @@ PropInstanceJob::PropInstanceJob() {
#endif
}
PropInstanceJob::~PropInstanceJob() {
PropInstanceJob2D::~PropInstanceJob2D() {
_prop.unref();
_instance = NULL;
}
void PropInstanceJob::_bind_methods() {
void PropInstanceJob2D::_bind_methods() {
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);
ClassDB::bind_method(D_METHOD("get_build_phase_type"), &PropInstanceJob2D::get_build_phase_type);
ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &PropInstanceJob2D::set_build_phase_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "build_phase_type", PROPERTY_HINT_ENUM, BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE), "set_build_phase_type", "get_build_phase_type");
ClassDB::bind_method(D_METHOD("set_prop", "prop"), &PropInstanceJob::set_prop);
ClassDB::bind_method(D_METHOD("set_prop_instance", "instance"), &PropInstanceJob::set_prop_instance_bind);
ClassDB::bind_method(D_METHOD("set_prop", "prop"), &PropInstanceJob2D::set_prop);
ClassDB::bind_method(D_METHOD("set_prop_instance", "instance"), &PropInstanceJob2D::set_prop_instance_bind);
ClassDB::bind_method(D_METHOD("get_phase"), &PropInstanceJob::get_phase);
ClassDB::bind_method(D_METHOD("set_phase", "phase"), &PropInstanceJob::set_phase);
ClassDB::bind_method(D_METHOD("next_phase"), &PropInstanceJob::next_phase);
ClassDB::bind_method(D_METHOD("get_phase"), &PropInstanceJob2D::get_phase);
ClassDB::bind_method(D_METHOD("set_phase", "phase"), &PropInstanceJob2D::set_phase);
ClassDB::bind_method(D_METHOD("next_phase"), &PropInstanceJob2D::next_phase);
ClassDB::bind_method(D_METHOD("get_build_done"), &PropInstanceJob::get_build_done);
ClassDB::bind_method(D_METHOD("set_build_done", "val"), &PropInstanceJob::set_build_done);
ClassDB::bind_method(D_METHOD("get_build_done"), &PropInstanceJob2D::get_build_done);
ClassDB::bind_method(D_METHOD("set_build_done", "val"), &PropInstanceJob2D::set_build_done);
ClassDB::bind_method(D_METHOD("finished"), &PropInstanceJob::finished);
ClassDB::bind_method(D_METHOD("finished"), &PropInstanceJob2D::finished);
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("reset"), &PropInstanceJob2D::reset);
ClassDB::bind_method(D_METHOD("_reset"), &PropInstanceJob2D::_reset);
ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob::_execute);
ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob2D::_execute);
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);
ClassDB::bind_method(D_METHOD("execute_phase"), &PropInstanceJob2D::execute_phase);
ClassDB::bind_method(D_METHOD("_execute_phase"), &PropInstanceJob2D::_execute_phase);
ClassDB::bind_method(D_METHOD("prop_instance_exit_tree"), &PropInstanceJob::prop_instance_exit_tree);
ClassDB::bind_method(D_METHOD("prop_instance_exit_tree"), &PropInstanceJob2D::prop_instance_exit_tree);
#if !THREAD_POOL_PRESENT
ClassDB::bind_method(D_METHOD("get_complete"), &PropInstanceJob::get_complete);
ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropInstanceJob::set_complete);
ClassDB::bind_method(D_METHOD("get_complete"), &PropInstanceJob2D::get_complete);
ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropInstanceJob2D::set_complete);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete");
ClassDB::bind_method(D_METHOD("get_start_time"), &PropInstanceJob::get_start_time);
ClassDB::bind_method(D_METHOD("set_start_time", "value"), &PropInstanceJob::set_start_time);
ClassDB::bind_method(D_METHOD("get_start_time"), &PropInstanceJob2D::get_start_time);
ClassDB::bind_method(D_METHOD("set_start_time", "value"), &PropInstanceJob2D::set_start_time);
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time");
ClassDB::bind_method(D_METHOD("get_current_run_stage"), &PropInstanceJob::get_current_run_stage);
ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &PropInstanceJob::set_current_run_stage);
ClassDB::bind_method(D_METHOD("get_current_run_stage"), &PropInstanceJob2D::get_current_run_stage);
ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &PropInstanceJob2D::set_current_run_stage);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage");
ClassDB::bind_method(D_METHOD("get_stage"), &PropInstanceJob::get_stage);
ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropInstanceJob::set_stage);
ClassDB::bind_method(D_METHOD("get_stage"), &PropInstanceJob2D::get_stage);
ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropInstanceJob2D::set_stage);
ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage");
ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropInstanceJob::get_current_execution_time);
ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropInstanceJob2D::get_current_execution_time);
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob::should_return);
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob2D::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob2D::should_return);
BIND_VMETHOD(MethodInfo("_execute"));
ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob::execute);
ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob2D::execute);
ADD_SIGNAL(MethodInfo("completed"));
#endif
}
#if !THREAD_POOL_PRESENT
bool PropInstanceJob::get_complete() const {
bool PropInstanceJob2D::get_complete() const {
return _complete;
}
void PropInstanceJob::set_complete(const bool value) {
void PropInstanceJob2D::set_complete(const bool value) {
_complete = value;
}
bool PropInstanceJob::get_cancelled() const {
bool PropInstanceJob2D::get_cancelled() const {
return _cancelled;
}
void PropInstanceJob::set_cancelled(const bool value) {
void PropInstanceJob2D::set_cancelled(const bool value) {
_cancelled = value;
}
float PropInstanceJob::get_max_allocated_time() const {
float PropInstanceJob2D::get_max_allocated_time() const {
return _max_allocated_time;
}
void PropInstanceJob::set_max_allocated_time(const float value) {
void PropInstanceJob2D::set_max_allocated_time(const float value) {
_max_allocated_time = value;
}
int PropInstanceJob::get_start_time() const {
int PropInstanceJob2D::get_start_time() const {
return _start_time;
}
void PropInstanceJob::set_start_time(const int value) {
void PropInstanceJob2D::set_start_time(const int value) {
_start_time = value;
}
int PropInstanceJob::get_current_run_stage() const {
int PropInstanceJob2D::get_current_run_stage() const {
return _current_run_stage;
}
void PropInstanceJob::set_current_run_stage(const int value) {
void PropInstanceJob2D::set_current_run_stage(const int value) {
_current_run_stage = value;
}
int PropInstanceJob::get_stage() const {
int PropInstanceJob2D::get_stage() const {
return _stage;
}
void PropInstanceJob::set_stage(const int value) {
void PropInstanceJob2D::set_stage(const int value) {
_stage = value;
}
void PropInstanceJob::reset_stages() {
void PropInstanceJob2D::reset_stages() {
_current_run_stage = 0;
_stage = 0;
}
float PropInstanceJob::get_current_execution_time() {
float PropInstanceJob2D::get_current_execution_time() {
return 0;
}
bool PropInstanceJob::should_do(const bool just_check) {
bool PropInstanceJob2D::should_do(const bool just_check) {
return true;
}
bool PropInstanceJob::should_return() {
bool PropInstanceJob2D::should_return() {
if (_cancelled)
return true;
return false;
}
void PropInstanceJob::execute() {
void PropInstanceJob2D::execute() {
ERR_FAIL_COND(!has_method("_execute"));
call("_execute");

View File

@ -40,15 +40,15 @@ SOFTWARE.
#endif
class PropData;
class PropInstance;
class PropData2D;
class PropInstance2D;
#if THREAD_POOL_PRESENT
class PropInstanceJob : public ThreadPoolJob {
GDCLASS(PropInstanceJob, ThreadPoolJob);
class PropInstanceJob2D : public ThreadPoolJob {
GDCLASS(PropInstanceJob2D, ThreadPoolJob);
#else
class PropInstanceJob : public Reference {
GDCLASS(PropInstanceJob, Reference);
class PropInstanceJob2D : public Reference {
GDCLASS(PropInstanceJob2D, Reference);
#endif
public:
@ -62,10 +62,10 @@ public:
public:
ActiveBuildPhaseType get_build_phase_type();
void set_build_phase_type(PropInstanceJob::ActiveBuildPhaseType build_phase_type);
void set_build_phase_type(PropInstanceJob2D::ActiveBuildPhaseType build_phase_type);
void set_prop(const Ref<PropData> &prop);
void set_prop_instance(PropInstance *instance);
void set_prop(const Ref<PropData2D> &prop);
void set_prop_instance(PropInstance2D *instance);
void set_prop_instance_bind(Node *instance);
int get_phase();
@ -91,8 +91,8 @@ public:
void prop_instance_enter_tree();
void prop_instance_exit_tree();
PropInstanceJob();
~PropInstanceJob();
PropInstanceJob2D();
~PropInstanceJob2D();
protected:
static void _bind_methods();
@ -101,8 +101,8 @@ protected:
bool _build_done;
int _phase;
bool _in_tree;
Ref<PropData> _prop;
PropInstance *_instance;
Ref<PropData2D> _prop;
PropInstance2D *_instance;
public:
#if !THREAD_POOL_PRESENT
@ -145,6 +145,6 @@ private:
#endif
};
VARIANT_ENUM_CAST(PropInstanceJob::ActiveBuildPhaseType);
VARIANT_ENUM_CAST(PropInstanceJob2D::ActiveBuildPhaseType);
#endif

View File

@ -67,12 +67,12 @@ typedef class RenderingServer VS;
#include "scene/resources/box_shape.h"
const float PropInstanceMerger::LOD_CHECK_INTERVAL = 2;
const float PropInstanceMerger2D::LOD_CHECK_INTERVAL = 2;
bool PropInstanceMerger::get_building() {
bool PropInstanceMerger2D::get_building() {
return _building;
}
void PropInstanceMerger::set_building(const bool value) {
void PropInstanceMerger2D::set_building(const bool value) {
_building = value;
set_physics_process_internal(_building);
@ -82,10 +82,10 @@ void PropInstanceMerger::set_building(const bool value) {
}
}
int PropInstanceMerger::get_lod_level() {
int PropInstanceMerger2D::get_lod_level() {
return _lod_level;
}
void PropInstanceMerger::set_lod_level(const int value) {
void PropInstanceMerger2D::set_lod_level(const int value) {
_lod_level = value;
if (_lod_level < 0) {
@ -95,62 +95,62 @@ void PropInstanceMerger::set_lod_level(const int value) {
apply_lod_level();
}
bool PropInstanceMerger::get_auto_lod() {
bool PropInstanceMerger2D::get_auto_lod() {
return _auto_lod;
}
void PropInstanceMerger::set_auto_lod(const bool value) {
void PropInstanceMerger2D::set_auto_lod(const bool value) {
_auto_lod = value;
check_auto_lod();
}
float PropInstanceMerger::get_first_lod_distance_squared() {
float PropInstanceMerger2D::get_first_lod_distance_squared() {
return _first_lod_distance_squared;
}
void PropInstanceMerger::set_first_lod_distance_squared(const float dist) {
void PropInstanceMerger2D::set_first_lod_distance_squared(const float dist) {
_first_lod_distance_squared = dist;
}
float PropInstanceMerger::get_lod_reduction_distance_squared() {
float PropInstanceMerger2D::get_lod_reduction_distance_squared() {
return _lod_reduction_distance_squared;
}
void PropInstanceMerger::set_lod_reduction_distance_squared(const float dist) {
void PropInstanceMerger2D::set_lod_reduction_distance_squared(const float dist) {
_lod_reduction_distance_squared = dist;
}
Ref<PropInstanceJob> PropInstanceMerger::get_job() {
Ref<PropInstanceJob2D> PropInstanceMerger2D::get_job() {
return _job;
}
void PropInstanceMerger::set_job(const Ref<PropInstanceJob> &job) {
void PropInstanceMerger2D::set_job(const Ref<PropInstanceJob2D> &job) {
_job = job;
}
//Materials
Ref<Material> PropInstanceMerger::material_get(const int index) {
Ref<Material> PropInstanceMerger2D::material_get(const int index) {
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
return _materials[index];
}
void PropInstanceMerger::material_add(const Ref<Material> &value) {
void PropInstanceMerger2D::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
int PropInstanceMerger::material_get_num() const {
int PropInstanceMerger2D::material_get_num() const {
return _materials.size();
}
void PropInstanceMerger::materials_clear() {
void PropInstanceMerger2D::materials_clear() {
_materials.clear();
}
Vector<Variant> PropInstanceMerger::materials_get() {
Vector<Variant> PropInstanceMerger2D::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void PropInstanceMerger::materials_set(const Vector<Variant> &materials) {
void PropInstanceMerger2D::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
@ -161,19 +161,19 @@ void PropInstanceMerger::materials_set(const Vector<Variant> &materials) {
}
//Meshes
RID PropInstanceMerger::mesh_get(const int index) {
RID PropInstanceMerger2D::mesh_get(const int index) {
ERR_FAIL_INDEX_V(index, _meshes.size(), RID());
return _meshes[index].mesh;
}
RID PropInstanceMerger::mesh_instance_get(const int index) {
RID PropInstanceMerger2D::mesh_instance_get(const int index) {
ERR_FAIL_INDEX_V(index, _meshes.size(), RID());
return _meshes[index].mesh_instance;
}
void PropInstanceMerger::mesh_add(const RID mesh_instance, const RID mesh) {
void PropInstanceMerger2D::mesh_add(const RID mesh_instance, const RID mesh) {
MeshEntry e;
e.mesh = mesh;
e.mesh_instance = mesh_instance;
@ -181,15 +181,15 @@ void PropInstanceMerger::mesh_add(const RID mesh_instance, const RID mesh) {
_meshes.push_back(e);
}
int PropInstanceMerger::mesh_get_num() const {
int PropInstanceMerger2D::mesh_get_num() const {
return _meshes.size();
}
void PropInstanceMerger::meshes_clear() {
void PropInstanceMerger2D::meshes_clear() {
_meshes.clear();
}
void PropInstanceMerger::meshes_create(const int num) {
void PropInstanceMerger2D::meshes_create(const int num) {
free_meshes();
for (int i = 0; i < num; ++i) {
@ -216,7 +216,7 @@ void PropInstanceMerger::meshes_create(const int num) {
apply_lod_level();
}
Vector<Variant> PropInstanceMerger::meshes_get() {
Vector<Variant> PropInstanceMerger2D::meshes_get() {
Vector<Variant> r;
for (int i = 0; i < _meshes.size(); i++) {
Array a;
@ -229,7 +229,7 @@ Vector<Variant> PropInstanceMerger::meshes_get() {
return r;
}
void PropInstanceMerger::meshes_set(const Vector<Variant> &meshs) {
void PropInstanceMerger2D::meshes_set(const Vector<Variant> &meshs) {
_meshes.clear();
for (int i = 0; i < _meshes.size(); i++) {
@ -247,31 +247,31 @@ void PropInstanceMerger::meshes_set(const Vector<Variant> &meshs) {
//Collider
Transform PropInstanceMerger::collider_local_transform_get(const int index) {
Transform PropInstanceMerger2D::collider_local_transform_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), Transform());
return _colliders[index].transform;
}
RID PropInstanceMerger::collider_body_get(const int index) {
RID PropInstanceMerger2D::collider_body_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), RID());
return _colliders[index].body;
}
Ref<Shape> PropInstanceMerger::collider_shape_get(const int index) {
Ref<Shape> PropInstanceMerger2D::collider_shape_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), Ref<Shape>());
return _colliders[index].shape;
}
RID PropInstanceMerger::collider_shape_rid_get(const int index) {
RID PropInstanceMerger2D::collider_shape_rid_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), RID());
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 PropInstanceMerger2D::collider_add(const Transform &local_transform, const Ref<Shape> &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();
@ -288,15 +288,15 @@ int PropInstanceMerger::collider_add(const Transform &local_transform, const Ref
return index;
}
int PropInstanceMerger::collider_get_num() const {
int PropInstanceMerger2D::collider_get_num() const {
return _colliders.size();
}
void PropInstanceMerger::colliders_clear() {
void PropInstanceMerger2D::colliders_clear() {
_colliders.clear();
}
Vector<Variant> PropInstanceMerger::colliders_get() {
Vector<Variant> PropInstanceMerger2D::colliders_get() {
Vector<Variant> r;
for (int i = 0; i < _colliders.size(); i++) {
r.push_back(_colliders[i].body);
@ -304,7 +304,7 @@ Vector<Variant> PropInstanceMerger::colliders_get() {
return r;
}
void PropInstanceMerger::colliders_set(const Vector<Variant> &colliders) {
void PropInstanceMerger2D::colliders_set(const Vector<Variant> &colliders) {
_colliders.clear();
for (int i = 0; i < colliders.size(); i++) {
@ -317,7 +317,7 @@ void PropInstanceMerger::colliders_set(const Vector<Variant> &colliders) {
}
}
void PropInstanceMerger::check_auto_lod() {
void PropInstanceMerger2D::check_auto_lod() {
if (!_auto_lod) {
_auto_lod_on = false;
return;
@ -337,7 +337,7 @@ void PropInstanceMerger::check_auto_lod() {
set_process_internal(true);
}
void PropInstanceMerger::apply_lod_level() {
void PropInstanceMerger2D::apply_lod_level() {
if (_meshes.size() == 0) {
return;
}
@ -377,7 +377,7 @@ void PropInstanceMerger::apply_lod_level() {
vs->instance_set_visible(mi, true);
}
void PropInstanceMerger::debug_mesh_allocate() {
void PropInstanceMerger2D::debug_mesh_allocate() {
if (_debug_mesh_rid == RID()) {
_debug_mesh_rid = VisualServer::get_singleton()->mesh_create();
}
@ -393,7 +393,7 @@ void PropInstanceMerger::debug_mesh_allocate() {
VS::get_singleton()->instance_set_visible(_debug_mesh_instance, true);
}
}
void PropInstanceMerger::debug_mesh_free() {
void PropInstanceMerger2D::debug_mesh_free() {
if (_debug_mesh_instance != RID()) {
VisualServer::get_singleton()->free(_debug_mesh_instance);
}
@ -402,25 +402,25 @@ void PropInstanceMerger::debug_mesh_free() {
VisualServer::get_singleton()->free(_debug_mesh_rid);
}
}
bool PropInstanceMerger::debug_mesh_has() {
bool PropInstanceMerger2D::debug_mesh_has() {
return _debug_mesh_rid != RID();
}
void PropInstanceMerger::debug_mesh_clear() {
void PropInstanceMerger2D::debug_mesh_clear() {
if (_debug_mesh_rid != RID()) {
VisualServer::get_singleton()->mesh_clear(_debug_mesh_rid);
}
}
void PropInstanceMerger::debug_mesh_array_clear() {
void PropInstanceMerger2D::debug_mesh_array_clear() {
_debug_mesh_array.resize(0);
}
void PropInstanceMerger::debug_mesh_add_vertices_to(const PoolVector3Array &arr) {
void PropInstanceMerger2D::debug_mesh_add_vertices_to(const PoolVector3Array &arr) {
_debug_mesh_array.append_array(arr);
if (_debug_mesh_array.size() % 2 == 1) {
_debug_mesh_array.append(_debug_mesh_array[_debug_mesh_array.size() - 1]);
}
}
void PropInstanceMerger::debug_mesh_send() {
void PropInstanceMerger2D::debug_mesh_send() {
debug_mesh_allocate();
debug_mesh_clear();
@ -442,7 +442,7 @@ void PropInstanceMerger::debug_mesh_send() {
debug_mesh_array_clear();
}
void PropInstanceMerger::draw_debug_mdr_colliders() {
void PropInstanceMerger2D::draw_debug_mdr_colliders() {
if (!debug_mesh_has()) {
debug_mesh_allocate();
}
@ -462,7 +462,7 @@ void PropInstanceMerger::draw_debug_mdr_colliders() {
debug_mesh_send();
}
void PropInstanceMerger::free_meshes() {
void PropInstanceMerger2D::free_meshes() {
RID rid;
for (int i = 0; i < _meshes.size(); ++i) {
@ -481,7 +481,7 @@ void PropInstanceMerger::free_meshes() {
}
}
void PropInstanceMerger::free_colliders() {
void PropInstanceMerger2D::free_colliders() {
for (int i = 0; i < _colliders.size(); ++i) {
ColliderBody &e = _colliders.write[i];
@ -496,10 +496,10 @@ void PropInstanceMerger::free_colliders() {
}
}
void PropInstanceMerger::_init_materials() {
void PropInstanceMerger2D::_init_materials() {
}
void PropInstanceMerger::_build() {
void PropInstanceMerger2D::_build() {
if (_building) {
return;
}
@ -541,7 +541,7 @@ void PropInstanceMerger::_build() {
_job->reset();
_job->set_complete(false);
Ref<PropMaterialCache> cache = PropCache::get_singleton()->material_cache_get(_prop_data);
Ref<PropMaterialCache2D> cache = PropCache2D::get_singleton()->material_cache_get(_prop_data);
if (cache->material_get_num() == 0) {
//lock it!
@ -574,7 +574,7 @@ Don't submit here, as it starts in physics process mode
*/
}
void PropInstanceMerger::_build_finished() {
void PropInstanceMerger2D::_build_finished() {
set_building(false);
apply_lod_level();
@ -587,22 +587,22 @@ void PropInstanceMerger::_build_finished() {
}
}
void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropData> &prop) {
void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref<PropData2D> &prop) {
ERR_FAIL_COND(!prop.is_valid());
int count = prop->get_prop_count();
for (int i = 0; i < count; ++i) {
Ref<PropDataEntry> e = prop->get_prop(i);
Ref<PropDataEntry2D> e = prop->get_prop(i);
if (!e.is_valid())
continue;
Transform t = transform * e->get_transform();
Ref<PropDataProp> prop_entry_data = e;
Ref<PropDataProp2D> prop_entry_data = e;
if (prop_entry_data.is_valid()) {
Ref<PropData> p = prop_entry_data->get_prop();
Ref<PropData2D> p = prop_entry_data->get_prop();
if (!p.is_valid())
continue;
@ -612,7 +612,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
continue;
}
Ref<PropDataTiledWall> tiled_wall_data = e;
Ref<PropDataTiledWall2D> tiled_wall_data = e;
if (tiled_wall_data.is_valid()) {
_job->add_tiled_wall(tiled_wall_data, t);
@ -636,7 +636,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
continue;
}
Ref<PropDataScene> scene_data = e;
Ref<PropDataScene2D> scene_data = e;
if (scene_data.is_valid()) {
Ref<PackedScene> sc = scene_data->get_scene();
@ -658,11 +658,11 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
}
//Will create a Terralight node, and prop
//PropDataLight could use standard godot light nodes
Ref<PropDataLight> light_data = e;
//PropData2DLight could use standard godot light nodes
Ref<PropDataLight2D> light_data = e;
if (light_data.is_valid()) {
Ref<PropLight> light;
Ref<PropLight2D> light;
light.instance();
Vector3 v = t.xform(Vector3());
@ -677,7 +677,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
}
#if MESH_DATA_RESOURCE_PRESENT
Ref<PropDataMeshData> mesh_data = e;
Ref<PropDataMeshData2D> mesh_data = e;
if (mesh_data.is_valid()) {
Ref<MeshDataResource> mdr = mesh_data->get_mesh();
@ -695,7 +695,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropDat
}
}
void PropInstanceMerger::collision_layer_changed() {
void PropInstanceMerger2D::collision_layer_changed() {
for (int i = 0; i < _colliders.size(); ++i) {
const ColliderBody &c = _colliders[i];
@ -704,7 +704,7 @@ void PropInstanceMerger::collision_layer_changed() {
}
}
}
void PropInstanceMerger::collision_mask_changed() {
void PropInstanceMerger2D::collision_mask_changed() {
for (int i = 0; i < _colliders.size(); ++i) {
const ColliderBody &c = _colliders[i];
@ -714,7 +714,7 @@ void PropInstanceMerger::collision_mask_changed() {
}
}
PropInstanceMerger::PropInstanceMerger() {
PropInstanceMerger2D::PropInstanceMerger2D() {
_build_queued = false;
_auto_lod = true;
_auto_lod_on = false;
@ -731,25 +731,25 @@ PropInstanceMerger::PropInstanceMerger() {
_lod_reduction_distance_squared = 600;
//todo this should probably be in a virtual method, like in Terraman or Voxelman
_job = Ref<PropInstancePropJob>(memnew(PropInstancePropJob()));
_job = Ref<PropInstancePropJob2D>(memnew(PropInstancePropJob2D()));
_job->set_prop_instace(this);
Ref<PropMesherJobStep> js;
Ref<PropMesherJobStep2D> js;
js.instance();
js->set_job_type(PropMesherJobStep::TYPE_NORMAL);
js->set_job_type(PropMesherJobStep2D::TYPE_NORMAL);
_job->add_jobs_step(js);
js.instance();
js->set_job_type(PropMesherJobStep::TYPE_MERGE_VERTS);
js->set_job_type(PropMesherJobStep2D::TYPE_MERGE_VERTS);
_job->add_jobs_step(js);
js.instance();
js->set_job_type(PropMesherJobStep::TYPE_BAKE_TEXTURE);
js->set_job_type(PropMesherJobStep2D::TYPE_BAKE_TEXTURE);
_job->add_jobs_step(js);
}
PropInstanceMerger::~PropInstanceMerger() {
PropInstanceMerger2D::~PropInstanceMerger2D() {
_job.unref();
_prop_data.unref();
@ -757,7 +757,7 @@ PropInstanceMerger::~PropInstanceMerger() {
_materials.clear();
}
void PropInstanceMerger::_notification(int p_what) {
void PropInstanceMerger2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (_prop_data.is_valid()) {
@ -783,10 +783,10 @@ void PropInstanceMerger::_notification(int p_what) {
return;
}
if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_PHYSICS_PROCESS) {
if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_PHYSICS_PROCESS) {
_job->physics_process(get_physics_process_delta_time());
if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_NORMAL) {
if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_NORMAL) {
#if THREAD_POOL_PRESENT
ThreadPool::get_singleton()->add_job(_job);
#else
@ -804,10 +804,10 @@ void PropInstanceMerger::_notification(int p_what) {
return;
}
if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_PROCESS) {
if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_PROCESS) {
_job->process(get_process_delta_time());
if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_NORMAL) {
if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_NORMAL) {
#if THREAD_POOL_PRESENT
ThreadPool::get_singleton()->add_job(_job);
#else
@ -909,72 +909,72 @@ void PropInstanceMerger::_notification(int p_what) {
}
}
void PropInstanceMerger::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_job"), &PropInstanceMerger::get_job);
ClassDB::bind_method(D_METHOD("set_job", "value"), &PropInstanceMerger::set_job);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "job", PROPERTY_HINT_RESOURCE_TYPE, "PropInstanceJob", 0), "set_job", "get_job");
void PropInstanceMerger2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_job"), &PropInstanceMerger2D::get_job);
ClassDB::bind_method(D_METHOD("set_job", "value"), &PropInstanceMerger2D::set_job);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "job", PROPERTY_HINT_RESOURCE_TYPE, "PropInstanceJob2D", 0), "set_job", "get_job");
ClassDB::bind_method(D_METHOD("get_lod_level"), &PropInstanceMerger::get_lod_level);
ClassDB::bind_method(D_METHOD("set_lod_level", "value"), &PropInstanceMerger::set_lod_level);
ClassDB::bind_method(D_METHOD("get_lod_level"), &PropInstanceMerger2D::get_lod_level);
ClassDB::bind_method(D_METHOD("set_lod_level", "value"), &PropInstanceMerger2D::set_lod_level);
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_level"), "set_lod_level", "get_lod_level");
ClassDB::bind_method(D_METHOD("get_auto_lod"), &PropInstanceMerger::get_auto_lod);
ClassDB::bind_method(D_METHOD("set_auto_lod", "value"), &PropInstanceMerger::set_auto_lod);
ClassDB::bind_method(D_METHOD("get_auto_lod"), &PropInstanceMerger2D::get_auto_lod);
ClassDB::bind_method(D_METHOD("set_auto_lod", "value"), &PropInstanceMerger2D::set_auto_lod);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_lod"), "set_auto_lod", "get_auto_lod");
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);
ClassDB::bind_method(D_METHOD("get_first_lod_distance_squared"), &PropInstanceMerger2D::get_first_lod_distance_squared);
ClassDB::bind_method(D_METHOD("set_first_lod_distance_squared", "value"), &PropInstanceMerger2D::set_first_lod_distance_squared);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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);
ClassDB::bind_method(D_METHOD("get_lod_reduction_distance_squared"), &PropInstanceMerger2D::get_lod_reduction_distance_squared);
ClassDB::bind_method(D_METHOD("set_lod_reduction_distance_squared", "value"), &PropInstanceMerger2D::set_lod_reduction_distance_squared);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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);
ClassDB::bind_method(D_METHOD("material_add", "value"), &PropInstanceMerger::material_add);
ClassDB::bind_method(D_METHOD("material_get_num"), &PropInstanceMerger::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &PropInstanceMerger::materials_clear);
ClassDB::bind_method(D_METHOD("material_get", "index"), &PropInstanceMerger2D::material_get);
ClassDB::bind_method(D_METHOD("material_add", "value"), &PropInstanceMerger2D::material_add);
ClassDB::bind_method(D_METHOD("material_get_num"), &PropInstanceMerger2D::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &PropInstanceMerger2D::materials_clear);
ClassDB::bind_method(D_METHOD("materials_get"), &PropInstanceMerger::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropInstanceMerger::materials_set);
ClassDB::bind_method(D_METHOD("materials_get"), &PropInstanceMerger2D::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropInstanceMerger2D::materials_set);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
//Meshes
ClassDB::bind_method(D_METHOD("mesh_get", "index"), &PropInstanceMerger::mesh_get);
ClassDB::bind_method(D_METHOD("mesh_instance_get", "index"), &PropInstanceMerger::mesh_instance_get);
ClassDB::bind_method(D_METHOD("mesh_add", "mesh_instance", "mesh"), &PropInstanceMerger::mesh_add);
ClassDB::bind_method(D_METHOD("mesh_get_num"), &PropInstanceMerger::mesh_get_num);
ClassDB::bind_method(D_METHOD("meshes_clear"), &PropInstanceMerger::meshes_clear);
ClassDB::bind_method(D_METHOD("mesh_get", "index"), &PropInstanceMerger2D::mesh_get);
ClassDB::bind_method(D_METHOD("mesh_instance_get", "index"), &PropInstanceMerger2D::mesh_instance_get);
ClassDB::bind_method(D_METHOD("mesh_add", "mesh_instance", "mesh"), &PropInstanceMerger2D::mesh_add);
ClassDB::bind_method(D_METHOD("mesh_get_num"), &PropInstanceMerger2D::mesh_get_num);
ClassDB::bind_method(D_METHOD("meshes_clear"), &PropInstanceMerger2D::meshes_clear);
ClassDB::bind_method(D_METHOD("meshes_get"), &PropInstanceMerger::meshes_get);
ClassDB::bind_method(D_METHOD("meshes_set"), &PropInstanceMerger::meshes_set);
ClassDB::bind_method(D_METHOD("meshes_get"), &PropInstanceMerger2D::meshes_get);
ClassDB::bind_method(D_METHOD("meshes_set"), &PropInstanceMerger2D::meshes_set);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "meshes", PROPERTY_HINT_NONE, "", 0), "meshes_set", "meshes_get");
//Colliders
ClassDB::bind_method(D_METHOD("collider_local_transform_get", "index"), &PropInstanceMerger::collider_local_transform_get);
ClassDB::bind_method(D_METHOD("collider_body_get", "index"), &PropInstanceMerger::collider_body_get);
ClassDB::bind_method(D_METHOD("collider_shape_get", "index"), &PropInstanceMerger::collider_shape_get);
ClassDB::bind_method(D_METHOD("collider_shape_rid_get", "index"), &PropInstanceMerger::collider_shape_rid_get);
ClassDB::bind_method(D_METHOD("collider_add", "local_transform", "shape", "shape_rid", "body"), &PropInstanceMerger::collider_add);
ClassDB::bind_method(D_METHOD("collider_get_num"), &PropInstanceMerger::collider_get_num);
ClassDB::bind_method(D_METHOD("colliders_clear"), &PropInstanceMerger::colliders_clear);
ClassDB::bind_method(D_METHOD("meshes_create", "num"), &PropInstanceMerger::meshes_create);
ClassDB::bind_method(D_METHOD("collider_local_transform_get", "index"), &PropInstanceMerger2D::collider_local_transform_get);
ClassDB::bind_method(D_METHOD("collider_body_get", "index"), &PropInstanceMerger2D::collider_body_get);
ClassDB::bind_method(D_METHOD("collider_shape_get", "index"), &PropInstanceMerger2D::collider_shape_get);
ClassDB::bind_method(D_METHOD("collider_shape_rid_get", "index"), &PropInstanceMerger2D::collider_shape_rid_get);
ClassDB::bind_method(D_METHOD("collider_add", "local_transform", "shape", "shape_rid", "body"), &PropInstanceMerger2D::collider_add);
ClassDB::bind_method(D_METHOD("collider_get_num"), &PropInstanceMerger2D::collider_get_num);
ClassDB::bind_method(D_METHOD("colliders_clear"), &PropInstanceMerger2D::colliders_clear);
ClassDB::bind_method(D_METHOD("meshes_create", "num"), &PropInstanceMerger2D::meshes_create);
//Colliders
ClassDB::bind_method(D_METHOD("debug_mesh_allocate"), &PropInstanceMerger::debug_mesh_allocate);
ClassDB::bind_method(D_METHOD("debug_mesh_free"), &PropInstanceMerger::debug_mesh_free);
ClassDB::bind_method(D_METHOD("debug_mesh_has"), &PropInstanceMerger::debug_mesh_has);
ClassDB::bind_method(D_METHOD("debug_mesh_clear"), &PropInstanceMerger::debug_mesh_clear);
ClassDB::bind_method(D_METHOD("debug_mesh_array_clear"), &PropInstanceMerger::debug_mesh_array_clear);
ClassDB::bind_method(D_METHOD("debug_mesh_add_vertices_to", "arr"), &PropInstanceMerger::debug_mesh_add_vertices_to);
ClassDB::bind_method(D_METHOD("debug_mesh_send"), &PropInstanceMerger::debug_mesh_send);
ClassDB::bind_method(D_METHOD("draw_debug_mdr_colliders"), &PropInstanceMerger::draw_debug_mdr_colliders);
ClassDB::bind_method(D_METHOD("debug_mesh_allocate"), &PropInstanceMerger2D::debug_mesh_allocate);
ClassDB::bind_method(D_METHOD("debug_mesh_free"), &PropInstanceMerger2D::debug_mesh_free);
ClassDB::bind_method(D_METHOD("debug_mesh_has"), &PropInstanceMerger2D::debug_mesh_has);
ClassDB::bind_method(D_METHOD("debug_mesh_clear"), &PropInstanceMerger2D::debug_mesh_clear);
ClassDB::bind_method(D_METHOD("debug_mesh_array_clear"), &PropInstanceMerger2D::debug_mesh_array_clear);
ClassDB::bind_method(D_METHOD("debug_mesh_add_vertices_to", "arr"), &PropInstanceMerger2D::debug_mesh_add_vertices_to);
ClassDB::bind_method(D_METHOD("debug_mesh_send"), &PropInstanceMerger2D::debug_mesh_send);
ClassDB::bind_method(D_METHOD("draw_debug_mdr_colliders"), &PropInstanceMerger2D::draw_debug_mdr_colliders);
ClassDB::bind_method(D_METHOD("check_auto_lod"), &PropInstanceMerger::check_auto_lod);
ClassDB::bind_method(D_METHOD("apply_lod_level"), &PropInstanceMerger::apply_lod_level);
ClassDB::bind_method(D_METHOD("check_auto_lod"), &PropInstanceMerger2D::check_auto_lod);
ClassDB::bind_method(D_METHOD("apply_lod_level"), &PropInstanceMerger2D::apply_lod_level);
//---
ClassDB::bind_method(D_METHOD("free_meshes"), &PropInstanceMerger::free_meshes);
ClassDB::bind_method(D_METHOD("free_colliders"), &PropInstanceMerger::free_colliders);
ClassDB::bind_method(D_METHOD("free_meshes"), &PropInstanceMerger2D::free_meshes);
ClassDB::bind_method(D_METHOD("free_colliders"), &PropInstanceMerger2D::free_colliders);
}

View File

@ -43,8 +43,8 @@ SOFTWARE.
class MeshDataInstance;
class PropInstanceMerger : public PropInstance {
GDCLASS(PropInstanceMerger, PropInstance);
class PropInstanceMerger2D : public PropInstance2D {
GDCLASS(PropInstanceMerger2D, PropInstance2D);
public:
static const float LOD_CHECK_INTERVAL;
@ -64,8 +64,8 @@ public:
float get_lod_reduction_distance_squared();
void set_lod_reduction_distance_squared(const float dist);
Ref<PropInstanceJob> get_job();
void set_job(const Ref<PropInstanceJob> &job);
Ref<PropInstanceJob2D> get_job();
void set_job(const Ref<PropInstanceJob2D> &job);
///Materials
Ref<Material> material_get(const int index);
@ -120,13 +120,13 @@ public:
virtual void _build();
virtual void _build_finished();
void _prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
void _prop_preprocess(Transform tarnsform, const Ref<PropData2D> &prop);
void collision_layer_changed();
void collision_mask_changed();
PropInstanceMerger();
~PropInstanceMerger();
PropInstanceMerger2D();
~PropInstanceMerger2D();
protected:
void _notification(int p_what);
@ -158,7 +158,7 @@ private:
Transform _last_transform;
Ref<PropInstancePropJob> _job;
Ref<PropInstancePropJob2D> _job;
Vector<Ref<Material>> _materials;
Vector<MeshEntry> _meshes;

View File

@ -62,36 +62,36 @@ SOFTWARE.
#include "props/prop_data_tiled_wall_2d.h"
#include "tiled_wall/tiled_wall_data_2d.h"
Ref<PropMaterialCache> PropInstancePropJob::get_material_cache() {
Ref<PropMaterialCache2D> PropInstancePropJob2D::get_material_cache() {
return _material_cache;
}
void PropInstancePropJob::set_material_cache(const Ref<PropMaterialCache> &cache) {
void PropInstancePropJob2D::set_material_cache(const Ref<PropMaterialCache2D> &cache) {
_material_cache = cache;
}
Ref<PropMesherJobStep> PropInstancePropJob::get_jobs_step(int index) const {
ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref<PropMesherJobStep>());
Ref<PropMesherJobStep2D> PropInstancePropJob2D::get_jobs_step(int index) const {
ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref<PropMesherJobStep2D>());
return _job_steps.get(index);
}
void PropInstancePropJob::set_jobs_step(int index, const Ref<PropMesherJobStep> &step) {
void PropInstancePropJob2D::set_jobs_step(int index, const Ref<PropMesherJobStep2D> &step) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.set(index, step);
}
void PropInstancePropJob::remove_jobs_step(const int index) {
void PropInstancePropJob2D::remove_jobs_step(const int index) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.remove(index);
}
void PropInstancePropJob::add_jobs_step(const Ref<PropMesherJobStep> &step) {
void PropInstancePropJob2D::add_jobs_step(const Ref<PropMesherJobStep2D> &step) {
_job_steps.push_back(step);
}
int PropInstancePropJob::get_jobs_step_count() const {
int PropInstancePropJob2D::get_jobs_step_count() const {
return _job_steps.size();
}
void PropInstancePropJob::add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape) {
void PropInstancePropJob2D::add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape) {
CollisionShapeEntry e;
e.shape = shape;
@ -100,30 +100,30 @@ void PropInstancePropJob::add_collision_shape(const Ref<Shape> &shape, const Tra
_collision_shapes.push_back(e);
}
void PropInstancePropJob::clear_collision_shapes() {
void PropInstancePropJob2D::clear_collision_shapes() {
_collision_shapes.clear();
}
PropInstanceMerger *PropInstancePropJob::get_prop_instace() {
PropInstanceMerger2D *PropInstancePropJob2D::get_prop_instace() {
return _prop_instace;
}
void PropInstancePropJob::set_prop_instace(PropInstanceMerger *prop) {
void PropInstancePropJob2D::set_prop_instace(PropInstanceMerger2D *prop) {
_prop_instace = prop;
_instance = prop;
}
void PropInstancePropJob::set_prop_instace_bind(Node *prop) {
set_prop_instace(Object::cast_to<PropInstanceMerger>(prop));
void PropInstancePropJob2D::set_prop_instace_bind(Node *prop) {
set_prop_instace(Object::cast_to<PropInstanceMerger2D>(prop));
}
Ref<PropMesher> PropInstancePropJob::get_prop_mesher() const {
Ref<PropMesher2D> PropInstancePropJob2D::get_prop_mesher() const {
return _prop_mesher;
}
void PropInstancePropJob::set_prop_mesher(const Ref<PropMesher> &mesher) {
void PropInstancePropJob2D::set_prop_mesher(const Ref<PropMesher2D> &mesher) {
_prop_mesher = mesher;
}
#if MESH_DATA_RESOURCE_PRESENT
void PropInstancePropJob::add_mesh(const Ref<PropDataMeshData> &mesh_data, const Transform &base_transform) {
void PropInstancePropJob2D::add_mesh(const Ref<PropDataMeshData2D> &mesh_data, const Transform &base_transform) {
PMDREntry e;
e.mesh_data = mesh_data;
e.base_transform = base_transform;
@ -131,12 +131,12 @@ void PropInstancePropJob::add_mesh(const Ref<PropDataMeshData> &mesh_data, const
_prop_mesh_datas.push_back(e);
}
void PropInstancePropJob::clear_meshes() {
void PropInstancePropJob2D::clear_meshes() {
_prop_mesh_datas.clear();
}
#endif
void PropInstancePropJob::add_tiled_wall(const Ref<PropDataTiledWall> &data, const Transform &base_transform) {
void PropInstancePropJob2D::add_tiled_wall(const Ref<PropDataTiledWall2D> &data, const Transform &base_transform) {
PTWEntry e;
e.data = data;
e.base_transform = base_transform;
@ -144,25 +144,25 @@ void PropInstancePropJob::add_tiled_wall(const Ref<PropDataTiledWall> &data, con
_prop_tiled_wall_datas.push_back(e);
}
void PropInstancePropJob::clear_tiled_walls() {
void PropInstancePropJob2D::clear_tiled_walls() {
_prop_tiled_wall_datas.clear();
}
void PropInstancePropJob::add_light(const Ref<PropLight> &light) {
void PropInstancePropJob2D::add_light(const Ref<PropLight2D> &light) {
_prop_mesher->add_light(light);
}
void PropInstancePropJob::clear_lights() {
void PropInstancePropJob2D::clear_lights() {
_prop_mesher->clear_lights();
}
void PropInstancePropJob::_physics_process(float delta) {
void PropInstancePropJob2D::_physics_process(float delta) {
if (_phase == 0)
phase_physics_process();
}
void PropInstancePropJob::_execute_phase() {
void PropInstancePropJob2D::_execute_phase() {
if (!_material_cache.is_valid()) {
ERR_PRINT("!PropInstancePropJob::_execute_phase(): !_material_cache.is_valid()");
ERR_PRINT("!PropInstancePropJob2D::_execute_phase(): !_material_cache.is_valid()");
//reset_meshes();
set_complete(true); //So threadpool knows it's done
finished();
@ -186,12 +186,12 @@ void PropInstancePropJob::_execute_phase() {
} else if (_phase > 3) {
set_complete(true); //So threadpool knows it's done
finished();
ERR_FAIL_MSG("PropInstancePropJob: _phase is too high!");
ERR_FAIL_MSG("PropInstancePropJob2D: _phase is too high!");
}
}
void PropInstancePropJob::_reset() {
PropInstanceJob::_reset();
void PropInstancePropJob2D::_reset() {
PropInstanceJob2D::_reset();
_build_done = false;
_phase = 0;
@ -216,7 +216,7 @@ void PropInstancePropJob::_reset() {
set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
}
void PropInstancePropJob::phase_physics_process() {
void PropInstancePropJob2D::phase_physics_process() {
//TODO this should only update the differences
//for (int i = 0; i < _prop_instace->collider_get_num(); ++i) {
// PhysicsServer::get_singleton()->free(_prop_instace->collider_body_get(i));
@ -263,7 +263,7 @@ void PropInstancePropJob::phase_physics_process() {
next_phase();
}
void PropInstancePropJob::phase_setup_cache() {
void PropInstancePropJob2D::phase_setup_cache() {
if (should_do()) {
if (!_material_cache->get_initialized()) {
_material_cache->mutex_lock();
@ -292,7 +292,7 @@ void PropInstancePropJob::phase_setup_cache() {
next_phase();
}
void PropInstancePropJob::phase_prop() {
void PropInstancePropJob2D::phase_prop() {
if (!_prop_mesher.is_valid()) {
set_complete(true); //So threadpool knows it's done
return;
@ -330,7 +330,7 @@ void PropInstancePropJob::phase_prop() {
for (int i = 0; i < _prop_tiled_wall_datas.size(); ++i) {
PTWEntry &e = _prop_tiled_wall_datas.write[i];
Ref<PropDataTiledWall> pdtw = e.data;
Ref<PropDataTiledWall2D> pdtw = e.data;
//Transform t = pdtw->get_transform();
Transform t = e.base_transform;
@ -352,7 +352,7 @@ void PropInstancePropJob::phase_prop() {
}
if (should_do()) {
if ((_prop_mesher->get_build_flags() & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) {
if ((_prop_mesher->get_build_flags() & PropMesher2D::BUILD_FLAG_USE_LIGHTING) != 0) {
_prop_mesher->bake_colors();
}
@ -365,7 +365,7 @@ void PropInstancePropJob::phase_prop() {
next_phase();
}
void PropInstancePropJob::phase_steps() {
void PropInstancePropJob2D::phase_steps() {
ERR_FAIL_COND(!_prop_mesher.is_valid());
if (should_return()) {
@ -388,27 +388,27 @@ void PropInstancePropJob::phase_steps() {
//first count how many we need
int count = 0;
for (int i = 0; i < _job_steps.size(); ++i) {
Ref<PropMesherJobStep> step = _job_steps[i];
Ref<PropMesherJobStep2D> step = _job_steps[i];
ERR_FAIL_COND(!step.is_valid());
switch (step->get_job_type()) {
case PropMesherJobStep::TYPE_NORMAL:
case PropMesherJobStep2D::TYPE_NORMAL:
++count;
break;
case PropMesherJobStep::TYPE_NORMAL_LOD:
case PropMesherJobStep2D::TYPE_NORMAL_LOD:
++count;
break;
case PropMesherJobStep::TYPE_DROP_UV2:
case PropMesherJobStep2D::TYPE_DROP_UV2:
++count;
break;
case PropMesherJobStep::TYPE_MERGE_VERTS:
case PropMesherJobStep2D::TYPE_MERGE_VERTS:
++count;
break;
case PropMesherJobStep::TYPE_BAKE_TEXTURE:
case PropMesherJobStep2D::TYPE_BAKE_TEXTURE:
++count;
break;
case PropMesherJobStep::TYPE_SIMPLIFY_MESH:
case PropMesherJobStep2D::TYPE_SIMPLIFY_MESH:
#ifdef MESH_UTILS_PRESENT
count += step->get_simplification_steps();
#endif
@ -441,30 +441,30 @@ void PropInstancePropJob::phase_steps() {
}
for (; _current_job_step < _job_steps.size();) {
Ref<PropMesherJobStep> step = _job_steps[_current_job_step];
Ref<PropMesherJobStep2D> step = _job_steps[_current_job_step];
ERR_FAIL_COND(!step.is_valid());
switch (step->get_job_type()) {
case PropMesherJobStep::TYPE_NORMAL:
case PropMesherJobStep2D::TYPE_NORMAL:
step_type_normal();
break;
case PropMesherJobStep::TYPE_NORMAL_LOD:
case PropMesherJobStep2D::TYPE_NORMAL_LOD:
step_type_normal_lod();
break;
case PropMesherJobStep::TYPE_DROP_UV2:
case PropMesherJobStep2D::TYPE_DROP_UV2:
step_type_drop_uv2();
break;
case PropMesherJobStep::TYPE_MERGE_VERTS:
case PropMesherJobStep2D::TYPE_MERGE_VERTS:
step_type_merge_verts();
break;
case PropMesherJobStep::TYPE_BAKE_TEXTURE:
case PropMesherJobStep2D::TYPE_BAKE_TEXTURE:
step_type_bake_texture();
break;
case PropMesherJobStep::TYPE_SIMPLIFY_MESH:
case PropMesherJobStep2D::TYPE_SIMPLIFY_MESH:
step_type_simplify_mesh();
break;
case PropMesherJobStep::TYPE_OTHER:
case PropMesherJobStep2D::TYPE_OTHER:
//do nothing
break;
}
@ -482,7 +482,7 @@ void PropInstancePropJob::phase_steps() {
finished();
}
void PropInstancePropJob::step_type_normal() {
void PropInstancePropJob2D::step_type_normal() {
//TODO add a lighting generation step
temp_mesh_arr = _prop_mesher->build_mesh();
@ -500,13 +500,13 @@ void PropInstancePropJob::step_type_normal() {
++_current_mesh;
}
void PropInstancePropJob::step_type_normal_lod() {
void PropInstancePropJob2D::step_type_normal_lod() {
print_error("Error: step_type_normal_lod doesn't work for TerraPropJobs!");
++_current_mesh;
}
void PropInstancePropJob::step_type_drop_uv2() {
void PropInstancePropJob2D::step_type_drop_uv2() {
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant();
@ -522,7 +522,7 @@ void PropInstancePropJob::step_type_drop_uv2() {
++_current_mesh;
}
void PropInstancePropJob::step_type_merge_verts() {
void PropInstancePropJob2D::step_type_merge_verts() {
Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr);
temp_mesh_arr = temp_mesh_arr2;
@ -539,7 +539,7 @@ void PropInstancePropJob::step_type_merge_verts() {
++_current_mesh;
}
void PropInstancePropJob::step_type_bake_texture() {
void PropInstancePropJob2D::step_type_bake_texture() {
Ref<ShaderMaterial> mat = _material_cache->material_lod_get(0);
Ref<SpatialMaterial> spmat = _material_cache->material_lod_get(0);
Ref<Texture> tex;
@ -568,10 +568,10 @@ void PropInstancePropJob::step_type_bake_texture() {
++_current_mesh;
}
void PropInstancePropJob::step_type_simplify_mesh() {
void PropInstancePropJob2D::step_type_simplify_mesh() {
#ifdef MESH_UTILS_PRESENT
Ref<PropMesherJobStep> step = _job_steps[_current_job_step];
Ref<PropMesherJobStep2D> step = _job_steps[_current_job_step];
ERR_FAIL_COND(!step.is_valid());
Ref<FastQuadraticMeshSimplifier> fqms = step->get_fqms();
ERR_FAIL_COND(!fqms.is_valid());
@ -598,7 +598,7 @@ void PropInstancePropJob::step_type_simplify_mesh() {
#endif
}
Array PropInstancePropJob::merge_mesh_array(Array arr) const {
Array PropInstancePropJob2D::merge_mesh_array(Array arr) const {
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr);
PoolVector3Array verts = arr[VisualServer::ARRAY_VERTEX];
@ -662,7 +662,7 @@ Array PropInstancePropJob::merge_mesh_array(Array arr) const {
return arr;
}
Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_color) const {
Array PropInstancePropJob2D::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_color) const {
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr);
ERR_FAIL_COND_V(!tex.is_valid(), arr);
@ -703,7 +703,7 @@ Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const
return arr;
}
void PropInstancePropJob::reset_meshes() {
void PropInstancePropJob2D::reset_meshes() {
if (!_prop_instace) {
return;
}
@ -725,7 +725,7 @@ void PropInstancePropJob::reset_meshes() {
}
}
PropInstancePropJob::PropInstancePropJob() {
PropInstancePropJob2D::PropInstancePropJob2D() {
set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
_prop_instace = NULL;
@ -734,29 +734,29 @@ PropInstancePropJob::PropInstancePropJob() {
//todo allocate this in a virtual method
_prop_mesher.instance();
_prop_mesher->set_build_flags(PropMesher::BUILD_FLAG_USE_LIGHTING | PropMesher::BUILD_FLAG_USE_AO | PropMesher::BUILD_FLAG_USE_RAO | PropMesher::BUILD_FLAG_BAKE_LIGHTS);
_prop_mesher->set_build_flags(PropMesher2D::BUILD_FLAG_USE_LIGHTING | PropMesher2D::BUILD_FLAG_USE_AO | PropMesher2D::BUILD_FLAG_USE_RAO | PropMesher2D::BUILD_FLAG_BAKE_LIGHTS);
}
PropInstancePropJob::~PropInstancePropJob() {
PropInstancePropJob2D::~PropInstancePropJob2D() {
}
void PropInstancePropJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_material_cache"), &PropInstancePropJob::get_material_cache);
ClassDB::bind_method(D_METHOD("set_material_cache", "packer"), &PropInstancePropJob::set_material_cache);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache", 0), "set_material_cache", "get_material_cache");
void PropInstancePropJob2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_material_cache"), &PropInstancePropJob2D::get_material_cache);
ClassDB::bind_method(D_METHOD("set_material_cache", "packer"), &PropInstancePropJob2D::set_material_cache);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache2D", 0), "set_material_cache", "get_material_cache");
ClassDB::bind_method(D_METHOD("get_jobs_step", "index"), &PropInstancePropJob::get_jobs_step);
ClassDB::bind_method(D_METHOD("set_jobs_step", "index", "mesher"), &PropInstancePropJob::set_jobs_step);
ClassDB::bind_method(D_METHOD("remove_jobs_step", "index"), &PropInstancePropJob::remove_jobs_step);
ClassDB::bind_method(D_METHOD("add_jobs_step", "mesher"), &PropInstancePropJob::add_jobs_step);
ClassDB::bind_method(D_METHOD("get_jobs_step_count"), &PropInstancePropJob::get_jobs_step_count);
ClassDB::bind_method(D_METHOD("get_jobs_step", "index"), &PropInstancePropJob2D::get_jobs_step);
ClassDB::bind_method(D_METHOD("set_jobs_step", "index", "mesher"), &PropInstancePropJob2D::set_jobs_step);
ClassDB::bind_method(D_METHOD("remove_jobs_step", "index"), &PropInstancePropJob2D::remove_jobs_step);
ClassDB::bind_method(D_METHOD("add_jobs_step", "mesher"), &PropInstancePropJob2D::add_jobs_step);
ClassDB::bind_method(D_METHOD("get_jobs_step_count"), &PropInstancePropJob2D::get_jobs_step_count);
ClassDB::bind_method(D_METHOD("get_prop_mesher"), &PropInstancePropJob::get_prop_mesher);
ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &PropInstancePropJob::set_prop_mesher);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher", 0), "set_prop_mesher", "get_prop_mesher");
ClassDB::bind_method(D_METHOD("get_prop_mesher"), &PropInstancePropJob2D::get_prop_mesher);
ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &PropInstancePropJob2D::set_prop_mesher);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher2D", 0), "set_prop_mesher", "get_prop_mesher");
ClassDB::bind_method(D_METHOD("add_light", "light"), &PropInstancePropJob::add_light);
ClassDB::bind_method(D_METHOD("clear_lights"), &PropInstancePropJob::clear_lights);
ClassDB::bind_method(D_METHOD("add_light", "light"), &PropInstancePropJob2D::add_light);
ClassDB::bind_method(D_METHOD("clear_lights"), &PropInstancePropJob2D::clear_lights);
ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &PropInstancePropJob::_physics_process);
ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &PropInstancePropJob2D::_physics_process);
}

View File

@ -25,51 +25,51 @@ SOFTWARE.
#include "prop_instance_job_2d.h"
class PropMesher;
class PropInstance;
class PropInstanceMerger;
class PropMesherJobStep;
class PropMaterialCache;
class PropMesher2D;
class PropInstance2D;
class PropInstanceMerger2D;
class PropMesherJobStep2D;
class PropMaterialCache2D;
class Shape;
class PropLight;
class PropDataTiledWall;
class PropLight2D;
class PropDataTiledWall2D;
#if MESH_DATA_RESOURCE_PRESENT
class PropDataMeshData;
#endif
class PropInstancePropJob : public PropInstanceJob {
GDCLASS(PropInstancePropJob, PropInstanceJob);
class PropInstancePropJob2D : public PropInstanceJob2D {
GDCLASS(PropInstancePropJob2D, PropInstanceJob2D);
public:
Ref<PropMaterialCache> get_material_cache();
void set_material_cache(const Ref<PropMaterialCache> &cache);
Ref<PropMaterialCache2D> get_material_cache();
void set_material_cache(const Ref<PropMaterialCache2D> &cache);
Ref<PropMesherJobStep> get_jobs_step(const int index) const;
void set_jobs_step(const int index, const Ref<PropMesherJobStep> &step);
Ref<PropMesherJobStep2D> get_jobs_step(const int index) const;
void set_jobs_step(const int index, const Ref<PropMesherJobStep2D> &step);
void remove_jobs_step(const int index);
void add_jobs_step(const Ref<PropMesherJobStep> &step);
void add_jobs_step(const Ref<PropMesherJobStep2D> &step);
int get_jobs_step_count() const;
void add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape = false);
void clear_collision_shapes();
PropInstanceMerger *get_prop_instace();
void set_prop_instace(PropInstanceMerger *prop);
PropInstanceMerger2D *get_prop_instace();
void set_prop_instace(PropInstanceMerger2D *prop);
void set_prop_instace_bind(Node *prop);
Ref<PropMesher> get_prop_mesher() const;
void set_prop_mesher(const Ref<PropMesher> &mesher);
Ref<PropMesher2D> get_prop_mesher() const;
void set_prop_mesher(const Ref<PropMesher2D> &mesher);
#if MESH_DATA_RESOURCE_PRESENT
void add_mesh(const Ref<PropDataMeshData> &mesh_data, const Transform &base_transform);
void add_mesh(const Ref<PropDataMeshData2D> &mesh_data, const Transform &base_transform);
void clear_meshes();
#endif
void add_tiled_wall(const Ref<PropDataTiledWall> &data, const Transform &base_transform);
void add_tiled_wall(const Ref<PropDataTiledWall2D> &data, const Transform &base_transform);
void clear_tiled_walls();
void add_light(const Ref<PropLight> &light);
void add_light(const Ref<PropLight2D> &light);
void clear_lights();
void _physics_process(float delta);
@ -93,8 +93,8 @@ public:
void reset_meshes();
PropInstancePropJob();
~PropInstancePropJob();
PropInstancePropJob2D();
~PropInstancePropJob2D();
protected:
static void _bind_methods();
@ -108,7 +108,7 @@ protected:
#endif
struct PTWEntry {
Ref<PropDataTiledWall> data;
Ref<PropDataTiledWall2D> data;
Transform base_transform;
};
@ -122,14 +122,14 @@ protected:
}
};
Ref<PropMaterialCache> _material_cache;
Ref<PropMaterialCache2D> _material_cache;
Vector<Ref<PropMesherJobStep>> _job_steps;
Vector<Ref<PropMesherJobStep2D>> _job_steps;
int _current_job_step;
int _current_mesh;
Ref<PropMesher> _prop_mesher;
PropInstanceMerger *_prop_instace;
Ref<PropMesher2D> _prop_mesher;
PropInstanceMerger2D *_prop_instace;
#if MESH_DATA_RESOURCE_PRESENT
Vector<PMDREntry> _prop_mesh_datas;

View File

@ -28,9 +28,9 @@ SOFTWARE.
#include "material_cache/prop_material_cache_2d.h"
#include "tiled_wall/tiled_wall_data_2d.h"
const String PropMesher::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights";
const String PropMesher2D::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights";
bool PropMesher::Vertex::operator==(const Vertex &p_vertex) const {
bool PropMesher2D::Vertex::operator==(const Vertex &p_vertex) const {
if (vertex != p_vertex.vertex)
return false;
@ -65,7 +65,7 @@ bool PropMesher::Vertex::operator==(const Vertex &p_vertex) const {
return true;
}
uint32_t PropMesher::VertexHasher::hash(const Vertex &p_vtx) {
uint32_t PropMesher2D::VertexHasher::hash(const Vertex &p_vtx) {
uint32_t h = hash_djb2_buffer((const uint8_t *)&p_vtx.vertex, sizeof(real_t) * 3);
h = hash_djb2_buffer((const uint8_t *)&p_vtx.normal, sizeof(real_t) * 3, h);
h = hash_djb2_buffer((const uint8_t *)&p_vtx.binormal, sizeof(real_t) * 3, h);
@ -78,90 +78,90 @@ uint32_t PropMesher::VertexHasher::hash(const Vertex &p_vtx) {
return h;
}
int PropMesher::get_channel_index_type() const {
int PropMesher2D::get_channel_index_type() const {
return _channel_index_type;
}
void PropMesher::set_channel_index_type(const int value) {
void PropMesher2D::set_channel_index_type(const int value) {
_channel_index_type = value;
}
int PropMesher::get_channel_index_isolevel() const {
int PropMesher2D::get_channel_index_isolevel() const {
return _channel_index_isolevel;
}
void PropMesher::set_channel_index_isolevel(const int value) {
void PropMesher2D::set_channel_index_isolevel(const int value) {
_channel_index_isolevel = value;
}
int PropMesher::get_mesher_index() const {
int PropMesher2D::get_mesher_index() const {
return _mesher_index;
}
void PropMesher::set_mesher_index(const int value) {
void PropMesher2D::set_mesher_index(const int value) {
_mesher_index = value;
}
int PropMesher::get_format() const {
int PropMesher2D::get_format() const {
return _format;
}
void PropMesher::set_format(const int value) {
void PropMesher2D::set_format(const int value) {
_format = value;
}
int PropMesher::get_texture_scale() const {
int PropMesher2D::get_texture_scale() const {
return _texture_scale;
}
void PropMesher::set_texture_scale(const int value) {
void PropMesher2D::set_texture_scale(const int value) {
_texture_scale = value;
}
Ref<Material> PropMesher::get_material() {
Ref<Material> PropMesher2D::get_material() {
return _material;
}
void PropMesher::set_material(const Ref<Material> &material) {
void PropMesher2D::set_material(const Ref<Material> &material) {
_material = material;
}
float PropMesher::get_ao_strength() const {
float PropMesher2D::get_ao_strength() const {
return _ao_strength;
}
void PropMesher::set_ao_strength(float value) {
void PropMesher2D::set_ao_strength(float value) {
_ao_strength = value;
}
float PropMesher::get_base_light_value() const {
float PropMesher2D::get_base_light_value() const {
return _base_light_value;
}
void PropMesher::set_base_light_value(float value) {
void PropMesher2D::set_base_light_value(float value) {
_base_light_value = value;
}
float PropMesher::get_voxel_scale() const {
float PropMesher2D::get_voxel_scale() const {
return _voxel_scale;
}
void PropMesher::set_voxel_scale(const float voxel_scale) {
void PropMesher2D::set_voxel_scale(const float voxel_scale) {
_voxel_scale = voxel_scale;
}
Rect2 PropMesher::get_uv_margin() const {
Rect2 PropMesher2D::get_uv_margin() const {
return _uv_margin;
}
void PropMesher::set_uv_margin(const Rect2 margin) {
void PropMesher2D::set_uv_margin(const Rect2 margin) {
_uv_margin = margin;
}
_FORCE_INLINE_ int PropMesher::get_build_flags() const {
_FORCE_INLINE_ int PropMesher2D::get_build_flags() const {
return _build_flags;
}
_FORCE_INLINE_ void PropMesher::set_build_flags(const int flags) {
_FORCE_INLINE_ void PropMesher2D::set_build_flags(const int flags) {
_build_flags = flags;
if ((_build_flags & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) {
if ((_build_flags & PropMesher2D::BUILD_FLAG_USE_LIGHTING) != 0) {
_format |= VisualServer::ARRAY_FORMAT_COLOR;
} else {
_format ^= VisualServer::ARRAY_FORMAT_COLOR;
}
}
Array PropMesher::build_mesh() {
Array PropMesher2D::build_mesh() {
Array a;
a.resize(VisualServer::ARRAY_MAX);
@ -305,7 +305,7 @@ Array PropMesher::build_mesh() {
return a;
}
void PropMesher::build_mesh_into(RID mesh) {
void PropMesher2D::build_mesh_into(RID mesh) {
ERR_FAIL_COND(mesh == RID());
VS::get_singleton()->mesh_clear(mesh);
@ -323,7 +323,7 @@ void PropMesher::build_mesh_into(RID mesh) {
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _material->get_rid());
}
void PropMesher::generate_normals(bool p_flip) {
void PropMesher2D::generate_normals(bool p_flip) {
_format = _format | VisualServer::ARRAY_FORMAT_NORMAL;
for (int i = 0; i < _indices.size(); i += 3) {
@ -355,7 +355,7 @@ void PropMesher::generate_normals(bool p_flip) {
}
}
void PropMesher::remove_doubles() {
void PropMesher2D::remove_doubles() {
if (_vertices.size() == 0)
return;
@ -401,7 +401,7 @@ void PropMesher::remove_doubles() {
}
//lot faster that normal remove_doubles, but false positives can happen curtesy of hash collisions
void PropMesher::remove_doubles_hashed() {
void PropMesher2D::remove_doubles_hashed() {
if (_vertices.size() == 0)
return;
@ -453,7 +453,7 @@ void PropMesher::remove_doubles_hashed() {
//print_error("after " + String::num(_vertices.size()) + " " + String::num(duration.count()));
}
void PropMesher::reset() {
void PropMesher2D::reset() {
_vertices.resize(0);
_indices.resize(0);
@ -466,7 +466,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 PropMesher2D::add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref<TiledWallData2D> &tiled_wall_data, Ref<PropMaterialCache2D> cache) {
ERR_FAIL_COND(!tiled_wall_data.is_valid());
ERR_FAIL_COND(!cache.is_valid());
ERR_FAIL_COND(width < 0);
@ -503,11 +503,11 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const
normal_rects.push_back(Rect2(0, 0, 1, 1));
}
TiledWallData::TiledWallTilingType tiling_type = tiled_wall_data->get_tiling_type();
TiledWallData2D::TiledWallTilingType tiling_type = tiled_wall_data->get_tiling_type();
//todo implement flavour!
if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_NONE) {
if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_NONE) {
Rect2 r = normal_rects[0];
if (flavour_rects.size() == 0) {
@ -529,7 +529,7 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const
}
}
}
} else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_HORIZONTAL) {
} else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_HORIZONTAL) {
Rect2 r;
if (flavour_rects.size() == 0) {
@ -555,7 +555,7 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const
}
}
}
} else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_VERTICAL) {
} else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_VERTICAL) {
Rect2 r;
if (flavour_rects.size() == 0) {
@ -581,7 +581,7 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const
}
}
}
} else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_BOTH) {
} else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_BOTH) {
Rect2 r;
if (flavour_rects.size() == 0) {
@ -610,7 +610,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 PropMesher2D::add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect) {
int vc = get_vertex_count();
//x + 1, y
@ -641,7 +641,7 @@ void PropMesher::add_tiled_wall_mesh_rect_simple(const int x, const int y, const
add_indices(vc + 0);
}
_FORCE_INLINE_ Vector2 PropMesher::transform_uv(const Vector2 &uv, const Rect2 &rect) const {
_FORCE_INLINE_ Vector2 PropMesher2D::transform_uv(const Vector2 &uv, const Rect2 &rect) const {
Vector2 ruv = uv;
ruv.x *= rect.size.x;
@ -653,13 +653,13 @@ _FORCE_INLINE_ Vector2 PropMesher::transform_uv(const Vector2 &uv, const Rect2 &
}
#ifdef MESH_DATA_RESOURCE_PRESENT
void PropMesher::add_mesh_data_resource(Ref<MeshDataResource> mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) {
void PropMesher2D::add_mesh_data_resource(Ref<MeshDataResource> mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) {
Transform transform = Transform(Basis(rotation).scaled(scale), position);
add_mesh_data_resource_transform(mesh, transform, uv_rect);
}
void PropMesher::add_mesh_data_resource_transform(Ref<MeshDataResource> mesh, const Transform transform, const Rect2 uv_rect) {
void PropMesher2D::add_mesh_data_resource_transform(Ref<MeshDataResource> mesh, const Transform transform, const Rect2 uv_rect) {
if (mesh->get_array().size() == 0)
return;
@ -703,7 +703,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 PropMesher2D::add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) {
if (mesh->get_array().size() == 0)
return;
@ -748,7 +748,7 @@ void PropMesher::add_mesh_data_resource_transform_colored(Ref<MeshDataResource>
#endif
//Data Management functions
void PropMesher::generate_ao() {
void PropMesher2D::generate_ao() {
/*
ERR_FAIL_COND(!_chunk.is_valid());
@ -787,7 +787,7 @@ void PropMesher::generate_ao() {
}*/
}
float PropMesher::get_random_ao(const Vector3 &position) {
float PropMesher2D::get_random_ao(const Vector3 &position) {
float val = _noise->get_noise_3d(position.x, position.y, position.z);
val *= _rao_scale_factor;
@ -801,12 +801,12 @@ float PropMesher::get_random_ao(const Vector3 &position) {
return val;
}
Color PropMesher::get_light_color_at(const Vector3 &position, const Vector3 &normal) {
Color PropMesher2D::get_light_color_at(const Vector3 &position, const Vector3 &normal) {
Vector3 v_lightDiffuse;
//calculate the lights value
for (int i = 0; i < _lights.size(); ++i) {
Ref<PropLight> light = _lights.get(i);
Ref<PropLight2D> light = _lights.get(i);
Vector3 lightDir = light->get_position() - position;
@ -843,10 +843,10 @@ Color PropMesher::get_light_color_at(const Vector3 &position, const Vector3 &nor
return Color(v_lightDiffuse.x, v_lightDiffuse.y, v_lightDiffuse.z);
}
void PropMesher::add_mesher(const Ref<PropMesher> &mesher) {
void PropMesher2D::add_mesher(const Ref<PropMesher2D> &mesher) {
call("_add_mesher", mesher);
}
void PropMesher::_add_mesher(const Ref<PropMesher> &mesher) {
void PropMesher2D::_add_mesher(const Ref<PropMesher2D> &mesher) {
int orig_size = _vertices.size();
_vertices.append_array(mesher->_vertices);
@ -864,14 +864,14 @@ void PropMesher::_add_mesher(const Ref<PropMesher> &mesher) {
}
}
void PropMesher::add_light(const Ref<PropLight> &light) {
void PropMesher2D::add_light(const Ref<PropLight2D> &light) {
_lights.push_back(light);
}
void PropMesher::clear_lights() {
void PropMesher2D::clear_lights() {
_lights.clear();
}
PoolVector<Vector3> PropMesher::build_collider() const {
PoolVector<Vector3> PropMesher2D::build_collider() const {
PoolVector<Vector3> face_points;
if (_vertices.size() == 0)
@ -901,13 +901,13 @@ PoolVector<Vector3> PropMesher::build_collider() const {
return face_points;
}
void PropMesher::bake_colors() {
if ((get_build_flags() & PropMesher::BUILD_FLAG_USE_LIGHTING) == 0) {
void PropMesher2D::bake_colors() {
if ((get_build_flags() & PropMesher2D::BUILD_FLAG_USE_LIGHTING) == 0) {
return;
}
bool rao = (get_build_flags() & PropMesher::BUILD_FLAG_USE_RAO) != 0;
bool lights = (get_build_flags() & PropMesher::BUILD_FLAG_BAKE_LIGHTS) != 0;
bool rao = (get_build_flags() & PropMesher2D::BUILD_FLAG_USE_RAO) != 0;
bool lights = (get_build_flags() & PropMesher2D::BUILD_FLAG_BAKE_LIGHTS) != 0;
if (rao && lights) {
bake_colors_lights_rao();
@ -925,7 +925,7 @@ void PropMesher::bake_colors() {
}
}
void PropMesher::bake_colors_rao() {
void PropMesher2D::bake_colors_rao() {
for (int i = 0; i < _vertices.size(); ++i) {
Vertex vertex = _vertices[i];
Vector3 vert = vertex.vertex;
@ -949,7 +949,7 @@ void PropMesher::bake_colors_rao() {
_vertices.set(i, vertex);
}
}
void PropMesher::bake_colors_lights_rao() {
void PropMesher2D::bake_colors_lights_rao() {
for (int i = 0; i < _vertices.size(); ++i) {
Vertex vertex = _vertices[i];
Vector3 vert = vertex.vertex;
@ -977,7 +977,7 @@ void PropMesher::bake_colors_lights_rao() {
_vertices.set(i, vertex);
}
}
void PropMesher::bake_colors_lights() {
void PropMesher2D::bake_colors_lights() {
for (int i = 0; i < _vertices.size(); ++i) {
Vertex vertex = _vertices[i];
Vector3 vert = vertex.vertex;
@ -1001,7 +1001,7 @@ void PropMesher::bake_colors_lights() {
}
#ifdef TERRAMAN_PRESENT
void PropMesher::bake_lights(MeshInstance *node, Vector<Ref<TerraLight>> &lights) {
void PropMesher2D::bake_lights(MeshInstance *node, Vector<Ref<TerraLight>> &lights) {
ERR_FAIL_COND(node == NULL);
Color darkColor(0, 0, 0, 1);
@ -1089,7 +1089,7 @@ void PropMesher::bake_lights(MeshInstance *node, Vector<Ref<TerraLight>> &lights
}
#endif
PoolVector<Vector3> PropMesher::get_vertices() const {
PoolVector<Vector3> PropMesher2D::get_vertices() const {
PoolVector<Vector3> arr;
arr.resize(_vertices.size());
@ -1100,7 +1100,7 @@ PoolVector<Vector3> PropMesher::get_vertices() const {
return arr;
}
void PropMesher::set_vertices(const PoolVector<Vector3> &values) {
void PropMesher2D::set_vertices(const PoolVector<Vector3> &values) {
ERR_FAIL_COND(values.size() != _vertices.size());
for (int i = 0; i < _vertices.size(); ++i) {
@ -1112,11 +1112,11 @@ void PropMesher::set_vertices(const PoolVector<Vector3> &values) {
}
}
int PropMesher::get_vertex_count() const {
int PropMesher2D::get_vertex_count() const {
return _vertices.size();
}
void PropMesher::add_vertex(const Vector3 &vertex) {
void PropMesher2D::add_vertex(const Vector3 &vertex) {
Vertex vtx;
vtx.vertex = vertex;
vtx.color = _last_color;
@ -1132,15 +1132,15 @@ void PropMesher::add_vertex(const Vector3 &vertex) {
_vertices.push_back(vtx);
}
Vector3 PropMesher::get_vertex(const int idx) const {
Vector3 PropMesher2D::get_vertex(const int idx) const {
return _vertices.get(idx).vertex;
}
void PropMesher::remove_vertex(const int idx) {
void PropMesher2D::remove_vertex(const int idx) {
_vertices.remove(idx);
}
PoolVector<Vector3> PropMesher::get_normals() const {
PoolVector<Vector3> PropMesher2D::get_normals() const {
PoolVector<Vector3> arr;
arr.resize(_vertices.size());
@ -1151,7 +1151,7 @@ PoolVector<Vector3> PropMesher::get_normals() const {
return arr;
}
void PropMesher::set_normals(const PoolVector<Vector3> &values) {
void PropMesher2D::set_normals(const PoolVector<Vector3> &values) {
ERR_FAIL_COND(values.size() != _vertices.size());
for (int i = 0; i < _vertices.size(); ++i) {
@ -1163,15 +1163,15 @@ void PropMesher::set_normals(const PoolVector<Vector3> &values) {
}
}
void PropMesher::add_normal(const Vector3 &normal) {
void PropMesher2D::add_normal(const Vector3 &normal) {
_last_normal = normal;
}
Vector3 PropMesher::get_normal(int idx) const {
Vector3 PropMesher2D::get_normal(int idx) const {
return _vertices.get(idx).normal;
}
PoolVector<Color> PropMesher::get_colors() const {
PoolVector<Color> PropMesher2D::get_colors() const {
PoolVector<Color> arr;
arr.resize(_vertices.size());
@ -1182,7 +1182,7 @@ PoolVector<Color> PropMesher::get_colors() const {
return arr;
}
void PropMesher::set_colors(const PoolVector<Color> &values) {
void PropMesher2D::set_colors(const PoolVector<Color> &values) {
ERR_FAIL_COND(values.size() != _vertices.size());
for (int i = 0; i < _vertices.size(); ++i) {
@ -1194,15 +1194,15 @@ void PropMesher::set_colors(const PoolVector<Color> &values) {
}
}
void PropMesher::add_color(const Color &color) {
void PropMesher2D::add_color(const Color &color) {
_last_color = color;
}
Color PropMesher::get_color(const int idx) const {
Color PropMesher2D::get_color(const int idx) const {
return _vertices.get(idx).color;
}
PoolVector<Vector2> PropMesher::get_uvs() const {
PoolVector<Vector2> PropMesher2D::get_uvs() const {
PoolVector<Vector2> arr;
arr.resize(_vertices.size());
@ -1213,7 +1213,7 @@ PoolVector<Vector2> PropMesher::get_uvs() const {
return arr;
}
void PropMesher::set_uvs(const PoolVector<Vector2> &values) {
void PropMesher2D::set_uvs(const PoolVector<Vector2> &values) {
ERR_FAIL_COND(values.size() != _vertices.size());
for (int i = 0; i < _vertices.size(); ++i) {
@ -1225,15 +1225,15 @@ void PropMesher::set_uvs(const PoolVector<Vector2> &values) {
}
}
void PropMesher::add_uv(const Vector2 &uv) {
void PropMesher2D::add_uv(const Vector2 &uv) {
_last_uv = uv;
}
Vector2 PropMesher::get_uv(const int idx) const {
Vector2 PropMesher2D::get_uv(const int idx) const {
return _vertices.get(idx).uv;
}
PoolVector<Vector2> PropMesher::get_uv2s() const {
PoolVector<Vector2> PropMesher2D::get_uv2s() const {
PoolVector<Vector2> arr;
arr.resize(_vertices.size());
@ -1244,7 +1244,7 @@ PoolVector<Vector2> PropMesher::get_uv2s() const {
return arr;
}
void PropMesher::set_uv2s(const PoolVector<Vector2> &values) {
void PropMesher2D::set_uv2s(const PoolVector<Vector2> &values) {
ERR_FAIL_COND(values.size() != _vertices.size());
for (int i = 0; i < _vertices.size(); ++i) {
@ -1256,39 +1256,39 @@ void PropMesher::set_uv2s(const PoolVector<Vector2> &values) {
}
}
void PropMesher::add_uv2(const Vector2 &uv) {
void PropMesher2D::add_uv2(const Vector2 &uv) {
_last_uv2 = uv;
}
Vector2 PropMesher::get_uv2(const int idx) const {
Vector2 PropMesher2D::get_uv2(const int idx) const {
return _vertices.get(idx).uv2;
}
PoolVector<int> PropMesher::get_indices() const {
PoolVector<int> PropMesher2D::get_indices() const {
return _indices;
}
void PropMesher::set_indices(const PoolVector<int> &values) {
void PropMesher2D::set_indices(const PoolVector<int> &values) {
_indices = values;
}
int PropMesher::get_indices_count() const {
int PropMesher2D::get_indices_count() const {
return _indices.size();
}
void PropMesher::add_indices(const int index) {
void PropMesher2D::add_indices(const int index) {
_indices.push_back(index);
}
int PropMesher::get_index(const int idx) const {
int PropMesher2D::get_index(const int idx) const {
return _indices.get(idx);
}
void PropMesher::remove_index(const int idx) {
void PropMesher2D::remove_index(const int idx) {
_indices.remove(idx);
}
PropMesher::PropMesher() {
PropMesher2D::PropMesher2D() {
_mesher_index = 0;
_voxel_scale = 1;
_ao_strength = 0.25;
@ -1313,120 +1313,120 @@ PropMesher::PropMesher() {
_rao_seed = 2134;
}
PropMesher::~PropMesher() {
PropMesher2D::~PropMesher2D() {
}
void PropMesher::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_channel_index_type"), &PropMesher::get_channel_index_type);
ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &PropMesher::set_channel_index_type);
void PropMesher2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_channel_index_type"), &PropMesher2D::get_channel_index_type);
ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &PropMesher2D::set_channel_index_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_type"), "set_channel_index_type", "get_channel_index_type");
ClassDB::bind_method(D_METHOD("get_channel_index_isolevel"), &PropMesher::get_channel_index_isolevel);
ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &PropMesher::set_channel_index_isolevel);
ClassDB::bind_method(D_METHOD("get_channel_index_isolevel"), &PropMesher2D::get_channel_index_isolevel);
ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &PropMesher2D::set_channel_index_isolevel);
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_isolevel"), "set_channel_index_isolevel", "get_channel_index_isolevel");
ClassDB::bind_method(D_METHOD("get_mesher_index"), &PropMesher::get_mesher_index);
ClassDB::bind_method(D_METHOD("set_mesher_index", "value"), &PropMesher::set_mesher_index);
ClassDB::bind_method(D_METHOD("get_mesher_index"), &PropMesher2D::get_mesher_index);
ClassDB::bind_method(D_METHOD("set_mesher_index", "value"), &PropMesher2D::set_mesher_index);
ADD_PROPERTY(PropertyInfo(Variant::INT, "mesher_index"), "set_mesher_index", "get_mesher_index");
ClassDB::bind_method(D_METHOD("get_format"), &PropMesher::get_format);
ClassDB::bind_method(D_METHOD("set_format", "value"), &PropMesher::set_format);
ClassDB::bind_method(D_METHOD("get_format"), &PropMesher2D::get_format);
ClassDB::bind_method(D_METHOD("set_format", "value"), &PropMesher2D::set_format);
ADD_PROPERTY(PropertyInfo(Variant::INT, "format"), "set_format", "get_format");
ClassDB::bind_method(D_METHOD("get_texture_scale"), &PropMesher::get_texture_scale);
ClassDB::bind_method(D_METHOD("set_texture_scale", "value"), &PropMesher::set_texture_scale);
ClassDB::bind_method(D_METHOD("get_texture_scale"), &PropMesher2D::get_texture_scale);
ClassDB::bind_method(D_METHOD("set_texture_scale", "value"), &PropMesher2D::set_texture_scale);
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_scale"), "set_texture_scale", "get_texture_scale");
ClassDB::bind_method(D_METHOD("get_material"), &PropMesher::get_material);
ClassDB::bind_method(D_METHOD("set_material", "value"), &PropMesher::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &PropMesher2D::get_material);
ClassDB::bind_method(D_METHOD("set_material", "value"), &PropMesher2D::set_material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material");
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);
ClassDB::bind_method(D_METHOD("get_voxel_scale"), &PropMesher2D::get_voxel_scale);
ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &PropMesher2D::set_voxel_scale);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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);
ClassDB::bind_method(D_METHOD("get_ao_strength"), &PropMesher2D::get_ao_strength);
ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &PropMesher2D::set_ao_strength);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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);
ClassDB::bind_method(D_METHOD("get_base_light_value"), &PropMesher2D::get_base_light_value);
ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &PropMesher2D::set_base_light_value);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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);
ClassDB::bind_method(D_METHOD("get_uv_margin"), &PropMesher2D::get_uv_margin);
ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &PropMesher2D::set_uv_margin);
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "uv_margin"), "set_uv_margin", "get_uv_margin");
ClassDB::bind_method(D_METHOD("get_build_flags"), &PropMesher::get_build_flags);
ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &PropMesher::set_build_flags);
ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, PropMesher::BINDING_STRING_BUILD_FLAGS), "set_build_flags", "get_build_flags");
ClassDB::bind_method(D_METHOD("get_build_flags"), &PropMesher2D::get_build_flags);
ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &PropMesher2D::set_build_flags);
ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, PropMesher2D::BINDING_STRING_BUILD_FLAGS), "set_build_flags", "get_build_flags");
ClassDB::bind_method(D_METHOD("add_tiled_wall_simple", "width", "height", "transform", "tiled_wall_data", "cache"), &PropMesher::add_tiled_wall_simple);
ClassDB::bind_method(D_METHOD("add_tiled_wall_mesh_rect_simple", "x", "y", "transform", "texture_rect"), &PropMesher::add_tiled_wall_mesh_rect_simple);
ClassDB::bind_method(D_METHOD("transform_uv", "uv", "rect"), &PropMesher::transform_uv);
ClassDB::bind_method(D_METHOD("add_tiled_wall_simple", "width", "height", "transform", "tiled_wall_data", "cache"), &PropMesher2D::add_tiled_wall_simple);
ClassDB::bind_method(D_METHOD("add_tiled_wall_mesh_rect_simple", "x", "y", "transform", "texture_rect"), &PropMesher2D::add_tiled_wall_mesh_rect_simple);
ClassDB::bind_method(D_METHOD("transform_uv", "uv", "rect"), &PropMesher2D::transform_uv);
#ifdef MESH_DATA_RESOURCE_PRESENT
ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &PropMesher::add_mesh_data_resource, DEFVAL(Rect2(0, 0, 1, 1)), DEFVAL(Vector3(1.0, 1.0, 1.0)), DEFVAL(Vector3()), DEFVAL(Vector3()));
ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform", "mesh", "transform", "uv_rect"), &PropMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1)));
ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &PropMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1)));
ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &PropMesher2D::add_mesh_data_resource, DEFVAL(Rect2(0, 0, 1, 1)), DEFVAL(Vector3(1.0, 1.0, 1.0)), DEFVAL(Vector3()), DEFVAL(Vector3()));
ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform", "mesh", "transform", "uv_rect"), &PropMesher2D::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1)));
ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &PropMesher2D::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1)));
#endif
ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher::generate_ao);
ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher::get_random_ao);
ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher2D::generate_ao);
ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher2D::get_random_ao);
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);
BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher2D")));
ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &PropMesher2D::add_mesher);
ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &PropMesher2D::_add_mesher);
ClassDB::bind_method(D_METHOD("add_light", "light"), &PropMesher::add_light);
ClassDB::bind_method(D_METHOD("clear_lights"), &PropMesher::clear_lights);
ClassDB::bind_method(D_METHOD("add_light", "light"), &PropMesher2D::add_light);
ClassDB::bind_method(D_METHOD("clear_lights"), &PropMesher2D::clear_lights);
ClassDB::bind_method(D_METHOD("get_vertices"), &PropMesher::get_vertices);
ClassDB::bind_method(D_METHOD("set_vertices", "values"), &PropMesher::set_vertices);
ClassDB::bind_method(D_METHOD("get_vertex_count"), &PropMesher::get_vertex_count);
ClassDB::bind_method(D_METHOD("get_vertex", "idx"), &PropMesher::get_vertex);
ClassDB::bind_method(D_METHOD("remove_vertex", "idx"), &PropMesher::remove_vertex);
ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &PropMesher::add_vertex);
ClassDB::bind_method(D_METHOD("get_vertices"), &PropMesher2D::get_vertices);
ClassDB::bind_method(D_METHOD("set_vertices", "values"), &PropMesher2D::set_vertices);
ClassDB::bind_method(D_METHOD("get_vertex_count"), &PropMesher2D::get_vertex_count);
ClassDB::bind_method(D_METHOD("get_vertex", "idx"), &PropMesher2D::get_vertex);
ClassDB::bind_method(D_METHOD("remove_vertex", "idx"), &PropMesher2D::remove_vertex);
ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &PropMesher2D::add_vertex);
ClassDB::bind_method(D_METHOD("get_normals"), &PropMesher::get_normals);
ClassDB::bind_method(D_METHOD("set_normals", "values"), &PropMesher::set_normals);
ClassDB::bind_method(D_METHOD("get_normal", "idx"), &PropMesher::get_normal);
ClassDB::bind_method(D_METHOD("add_normal", "normal"), &PropMesher::add_normal);
ClassDB::bind_method(D_METHOD("get_normals"), &PropMesher2D::get_normals);
ClassDB::bind_method(D_METHOD("set_normals", "values"), &PropMesher2D::set_normals);
ClassDB::bind_method(D_METHOD("get_normal", "idx"), &PropMesher2D::get_normal);
ClassDB::bind_method(D_METHOD("add_normal", "normal"), &PropMesher2D::add_normal);
ClassDB::bind_method(D_METHOD("get_colors"), &PropMesher::get_colors);
ClassDB::bind_method(D_METHOD("set_colors", "values"), &PropMesher::set_colors);
ClassDB::bind_method(D_METHOD("get_color", "idx"), &PropMesher::get_color);
ClassDB::bind_method(D_METHOD("add_color", "color"), &PropMesher::add_color);
ClassDB::bind_method(D_METHOD("get_colors"), &PropMesher2D::get_colors);
ClassDB::bind_method(D_METHOD("set_colors", "values"), &PropMesher2D::set_colors);
ClassDB::bind_method(D_METHOD("get_color", "idx"), &PropMesher2D::get_color);
ClassDB::bind_method(D_METHOD("add_color", "color"), &PropMesher2D::add_color);
ClassDB::bind_method(D_METHOD("get_uvs"), &PropMesher::get_uvs);
ClassDB::bind_method(D_METHOD("set_uvs", "values"), &PropMesher::set_uvs);
ClassDB::bind_method(D_METHOD("get_uv", "idx"), &PropMesher::get_uv);
ClassDB::bind_method(D_METHOD("add_uv", "uv"), &PropMesher::add_uv);
ClassDB::bind_method(D_METHOD("get_uvs"), &PropMesher2D::get_uvs);
ClassDB::bind_method(D_METHOD("set_uvs", "values"), &PropMesher2D::set_uvs);
ClassDB::bind_method(D_METHOD("get_uv", "idx"), &PropMesher2D::get_uv);
ClassDB::bind_method(D_METHOD("add_uv", "uv"), &PropMesher2D::add_uv);
ClassDB::bind_method(D_METHOD("get_uv2s"), &PropMesher::get_uv2s);
ClassDB::bind_method(D_METHOD("set_uv2s", "values"), &PropMesher::set_uv2s);
ClassDB::bind_method(D_METHOD("get_uv2", "idx"), &PropMesher::get_uv2);
ClassDB::bind_method(D_METHOD("add_uv2", "uv"), &PropMesher::add_uv2);
ClassDB::bind_method(D_METHOD("get_uv2s"), &PropMesher2D::get_uv2s);
ClassDB::bind_method(D_METHOD("set_uv2s", "values"), &PropMesher2D::set_uv2s);
ClassDB::bind_method(D_METHOD("get_uv2", "idx"), &PropMesher2D::get_uv2);
ClassDB::bind_method(D_METHOD("add_uv2", "uv"), &PropMesher2D::add_uv2);
ClassDB::bind_method(D_METHOD("get_indices"), &PropMesher::get_indices);
ClassDB::bind_method(D_METHOD("set_indices", "values"), &PropMesher::set_indices);
ClassDB::bind_method(D_METHOD("get_indices_count"), &PropMesher::get_indices_count);
ClassDB::bind_method(D_METHOD("get_index", "idx"), &PropMesher::get_index);
ClassDB::bind_method(D_METHOD("remove_index", "idx"), &PropMesher::remove_index);
ClassDB::bind_method(D_METHOD("add_indices", "indice"), &PropMesher::add_indices);
ClassDB::bind_method(D_METHOD("get_indices"), &PropMesher2D::get_indices);
ClassDB::bind_method(D_METHOD("set_indices", "values"), &PropMesher2D::set_indices);
ClassDB::bind_method(D_METHOD("get_indices_count"), &PropMesher2D::get_indices_count);
ClassDB::bind_method(D_METHOD("get_index", "idx"), &PropMesher2D::get_index);
ClassDB::bind_method(D_METHOD("remove_index", "idx"), &PropMesher2D::remove_index);
ClassDB::bind_method(D_METHOD("add_indices", "indice"), &PropMesher2D::add_indices);
ClassDB::bind_method(D_METHOD("reset"), &PropMesher::reset);
ClassDB::bind_method(D_METHOD("reset"), &PropMesher2D::reset);
//ClassDB::bind_method(D_METHOD("calculate_vertex_ambient_occlusion", "meshinstance_path", "radius", "intensity", "sampleCount"), &PropMesher::calculate_vertex_ambient_occlusion_path);
//ClassDB::bind_method(D_METHOD("calculate_vertex_ambient_occlusion", "meshinstance_path", "radius", "intensity", "sampleCount"), &PropMesher2D::calculate_vertex_ambient_occlusion_path);
ClassDB::bind_method(D_METHOD("build_mesh"), &PropMesher::build_mesh);
ClassDB::bind_method(D_METHOD("build_mesh_into", "mesh_rid"), &PropMesher::build_mesh_into);
ClassDB::bind_method(D_METHOD("build_collider"), &PropMesher::build_collider);
ClassDB::bind_method(D_METHOD("build_mesh"), &PropMesher2D::build_mesh);
ClassDB::bind_method(D_METHOD("build_mesh_into", "mesh_rid"), &PropMesher2D::build_mesh_into);
ClassDB::bind_method(D_METHOD("build_collider"), &PropMesher2D::build_collider);
ClassDB::bind_method(D_METHOD("bake_colors"), &PropMesher::bake_colors);
ClassDB::bind_method(D_METHOD("bake_colors"), &PropMesher2D::bake_colors);
ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher::generate_normals, DEFVAL(false));
ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher2D::generate_normals, DEFVAL(false));
ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher::remove_doubles);
ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &PropMesher::remove_doubles_hashed);
ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher2D::remove_doubles);
ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &PropMesher2D::remove_doubles_hashed);
}

View File

@ -61,12 +61,12 @@ using PoolVector = Vector<N>;
#endif
class OpenSimplexNoise;
class PropLight;
class PropMaterialCache;
class TiledWallData;
class PropLight2D;
class PropMaterialCache2D;
class TiledWallData2D;
class PropMesher : public Reference {
GDCLASS(PropMesher, Reference);
class PropMesher2D : public Reference {
GDCLASS(PropMesher2D, Reference);
public:
static const String BINDING_STRING_BUILD_FLAGS;
@ -145,7 +145,7 @@ 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_simple(const int width, const int height, const Transform &transform, const Ref<TiledWallData2D> &tiled_wall_data, Ref<PropMaterialCache2D> cache);
void add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect);
Vector2 transform_uv(const Vector2 &uv, const Rect2 &rect) const;
@ -159,10 +159,10 @@ public:
float get_random_ao(const Vector3 &position);
Color get_light_color_at(const Vector3 &position, const Vector3 &normal);
void add_mesher(const Ref<PropMesher> &mesher);
void _add_mesher(const Ref<PropMesher> &mesher);
void add_mesher(const Ref<PropMesher2D> &mesher);
void _add_mesher(const Ref<PropMesher2D> &mesher);
void add_light(const Ref<PropLight> &light);
void add_light(const Ref<PropLight2D> &light);
void clear_lights();
PoolVector<Vector3> build_collider() const;
@ -217,8 +217,8 @@ public:
void remove_index(const int idx);
void add_indices(const int index);
PropMesher();
~PropMesher();
PropMesher2D();
~PropMesher2D();
protected:
static void _bind_methods();
@ -234,7 +234,7 @@ protected:
PoolVector<Vertex> _vertices;
PoolVector<int> _indices;
Vector<Ref<PropLight>> _lights;
Vector<Ref<PropLight2D>> _lights;
Color _last_color;
Vector3 _last_normal;
@ -258,6 +258,6 @@ protected:
int _rao_seed;
};
VARIANT_ENUM_CAST(PropMesher::BuildFlags);
VARIANT_ENUM_CAST(PropMesher2D::BuildFlags);
#endif

View File

@ -8,10 +8,10 @@
#include "core/engine.h"
#endif
Ref<PackedScene> PropSceneInstance::get_scene() {
Ref<PackedScene> PropSceneInstance2D::get_scene() {
return _scene;
}
void PropSceneInstance::set_scene(const Ref<PackedScene> &data) {
void PropSceneInstance2D::set_scene(const Ref<PackedScene> &data) {
if (_scene == data)
return;
@ -20,21 +20,21 @@ void PropSceneInstance::set_scene(const Ref<PackedScene> &data) {
build();
}
bool PropSceneInstance::get_snap_to_mesh() const {
bool PropSceneInstance2D::get_snap_to_mesh() const {
return _snap_to_mesh;
}
void PropSceneInstance::set_snap_to_mesh(const bool value) {
void PropSceneInstance2D::set_snap_to_mesh(const bool value) {
_snap_to_mesh = value;
}
Vector3 PropSceneInstance::get_snap_axis() const {
Vector3 PropSceneInstance2D::get_snap_axis() const {
return _snap_axis;
}
void PropSceneInstance::set_snap_axis(const Vector3 &value) {
void PropSceneInstance2D::set_snap_axis(const Vector3 &value) {
_snap_axis = value;
}
void PropSceneInstance::build() {
void PropSceneInstance2D::build() {
if (!is_inside_tree()) {
return;
}
@ -59,15 +59,15 @@ void PropSceneInstance::build() {
// n->set_owner(get_tree()->get_edited_scene_root());
}
PropSceneInstance::PropSceneInstance() {
PropSceneInstance2D::PropSceneInstance2D() {
_snap_to_mesh = false;
_snap_axis = Vector3(0, -1, 0);
}
PropSceneInstance::~PropSceneInstance() {
PropSceneInstance2D::~PropSceneInstance2D() {
_scene.unref();
}
void PropSceneInstance::_notification(int p_what) {
void PropSceneInstance2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
build();
@ -75,18 +75,18 @@ void PropSceneInstance::_notification(int p_what) {
}
}
void PropSceneInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_scene"), &PropSceneInstance::get_scene);
ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropSceneInstance::set_scene);
void PropSceneInstance2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_scene"), &PropSceneInstance2D::get_scene);
ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropSceneInstance2D::set_scene);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropSceneInstance::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropSceneInstance::set_snap_to_mesh);
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropSceneInstance2D::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropSceneInstance2D::set_snap_to_mesh);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropSceneInstance::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropSceneInstance::set_snap_axis);
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropSceneInstance2D::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropSceneInstance2D::set_snap_axis);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
ClassDB::bind_method(D_METHOD("build"), &PropSceneInstance::build);
ClassDB::bind_method(D_METHOD("build"), &PropSceneInstance2D::build);
}

View File

@ -38,8 +38,8 @@ SOFTWARE.
#include "props/prop_data_2d.h"
#include "scene/resources/packed_scene.h"
class PropSceneInstance : public Spatial {
GDCLASS(PropSceneInstance, Spatial);
class PropSceneInstance2D : public Spatial {
GDCLASS(PropSceneInstance2D, Spatial);
public:
Ref<PackedScene> get_scene();
@ -53,8 +53,8 @@ public:
void build();
PropSceneInstance();
~PropSceneInstance();
PropSceneInstance2D();
~PropSceneInstance2D();
protected:
void _notification(int p_what);

View File

@ -34,51 +34,51 @@ SOFTWARE.
#define Shape Shape3D
#endif
int PropData::get_id() const {
int PropData2D::get_id() const {
return _id;
}
void PropData::set_id(const int value) {
void PropData2D::set_id(const int value) {
_id = value;
}
bool PropData::get_snap_to_mesh() const {
bool PropData2D::get_snap_to_mesh() const {
return _snap_to_mesh;
}
void PropData::set_snap_to_mesh(const bool value) {
void PropData2D::set_snap_to_mesh(const bool value) {
_snap_to_mesh = value;
}
Vector3 PropData::get_snap_axis() const {
Vector3 PropData2D::get_snap_axis() const {
return _snap_axis;
}
void PropData::set_snap_axis(const Vector3 &value) {
void PropData2D::set_snap_axis(const Vector3 &value) {
_snap_axis = value;
}
Ref<PropDataEntry> PropData::get_prop(const int index) const {
ERR_FAIL_INDEX_V(index, _props.size(), Ref<PropDataEntry>());
Ref<PropDataEntry2D> PropData2D::get_prop(const int index) const {
ERR_FAIL_INDEX_V(index, _props.size(), Ref<PropDataEntry2D>());
return _props.get(index);
}
void PropData::set_prop(const int index, const Ref<PropDataEntry> prop) {
void PropData2D::set_prop(const int index, const Ref<PropDataEntry2D> prop) {
ERR_FAIL_INDEX(index, _props.size());
_props.set(index, prop);
}
void PropData::add_prop(const Ref<PropDataEntry> prop) {
void PropData2D::add_prop(const Ref<PropDataEntry2D> prop) {
_props.push_back(prop);
}
void PropData::remove_prop(const int index) {
void PropData2D::remove_prop(const int index) {
ERR_FAIL_INDEX(index, _props.size());
_props.remove(index);
}
int PropData::get_prop_count() const {
int PropData2D::get_prop_count() const {
return _props.size();
}
Vector<Variant> PropData::get_props() {
Vector<Variant> PropData2D::get_props() {
Vector<Variant> r;
for (int i = 0; i < _props.size(); i++) {
#if VERSION_MAJOR < 4
@ -89,21 +89,21 @@ Vector<Variant> PropData::get_props() {
}
return r;
}
void PropData::set_props(const Vector<Variant> &props) {
void PropData2D::set_props(const Vector<Variant> &props) {
_props.clear();
for (int i = 0; i < props.size(); i++) {
Ref<PropDataEntry> prop = Ref<PropDataEntry>(props[i]);
Ref<PropDataEntry2D> prop = Ref<PropDataEntry2D>(props[i]);
_props.push_back(prop);
}
}
#if TEXTURE_PACKER_PRESENT
void PropData::add_textures_into(Ref<TexturePacker> texture_packer) {
void PropData2D::add_textures_into(Ref<TexturePacker> texture_packer) {
ERR_FAIL_COND(!texture_packer.is_valid());
for (int i = 0; i < _props.size(); ++i) {
Ref<PropDataEntry> entry = _props.get(i);
Ref<PropDataEntry2D> entry = _props.get(i);
if (entry.is_valid()) {
entry->add_textures_into(texture_packer);
@ -112,21 +112,21 @@ void PropData::add_textures_into(Ref<TexturePacker> texture_packer) {
}
#endif
bool PropData::get_is_room() const {
bool PropData2D::get_is_room() const {
return _is_room;
}
void PropData::set_is_room(const bool value) {
void PropData2D::set_is_room(const bool value) {
_is_room = value;
}
PoolVector3Array PropData::get_room_bounds() {
PoolVector3Array PropData2D::get_room_bounds() {
return _room_bounds;
}
void PropData::set_room_bounds(const PoolVector3Array &bounds) {
void PropData2D::set_room_bounds(const PoolVector3Array &bounds) {
_room_bounds = bounds;
}
void PropData::copy_from(const Ref<PropData> &prop_data) {
void PropData2D::copy_from(const Ref<PropData2D> &prop_data) {
_id = prop_data->_id;
_snap_to_mesh = prop_data->_snap_to_mesh;
_snap_axis = prop_data->_snap_axis;
@ -143,47 +143,47 @@ void PropData::copy_from(const Ref<PropData> &prop_data) {
emit_changed();
}
PropData::PropData() {
PropData2D::PropData2D() {
_id = 0;
_snap_to_mesh = false;
_is_room = false;
_snap_axis = Vector3(0, -1, 0);
}
PropData::~PropData() {
PropData2D::~PropData2D() {
_props.clear();
}
void PropData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropData::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropData::set_snap_to_mesh);
void PropData2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropData2D::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropData2D::set_snap_to_mesh);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropData::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropData::set_snap_axis);
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropData2D::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropData2D::set_snap_axis);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
ClassDB::bind_method(D_METHOD("get_prop", "index"), &PropData::get_prop);
ClassDB::bind_method(D_METHOD("set_prop", "index", "spell"), &PropData::set_prop);
ClassDB::bind_method(D_METHOD("add_prop", "prop"), &PropData::add_prop);
ClassDB::bind_method(D_METHOD("remove_prop", "index"), &PropData::remove_prop);
ClassDB::bind_method(D_METHOD("get_prop", "index"), &PropData2D::get_prop);
ClassDB::bind_method(D_METHOD("set_prop", "index", "spell"), &PropData2D::set_prop);
ClassDB::bind_method(D_METHOD("add_prop", "prop"), &PropData2D::add_prop);
ClassDB::bind_method(D_METHOD("remove_prop", "index"), &PropData2D::remove_prop);
ClassDB::bind_method(D_METHOD("get_prop_count"), &PropData::get_prop_count);
ClassDB::bind_method(D_METHOD("get_prop_count"), &PropData2D::get_prop_count);
ClassDB::bind_method(D_METHOD("get_props"), &PropData::get_props);
ClassDB::bind_method(D_METHOD("set_props", "props"), &PropData::set_props);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PropDataEntry", PROPERTY_USAGE_DEFAULT, "PropDataEntry"), "set_props", "get_props");
ClassDB::bind_method(D_METHOD("get_props"), &PropData2D::get_props);
ClassDB::bind_method(D_METHOD("set_props", "props"), &PropData2D::set_props);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PropDataEntry2D", PROPERTY_USAGE_DEFAULT, "PropDataEntry2D"), "set_props", "get_props");
#if TEXTURE_PACKER_PRESENT
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData::add_textures_into);
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData2D::add_textures_into);
#endif
ClassDB::bind_method(D_METHOD("get_is_room"), &PropData::get_is_room);
ClassDB::bind_method(D_METHOD("set_is_room", "value"), &PropData::set_is_room);
ClassDB::bind_method(D_METHOD("get_is_room"), &PropData2D::get_is_room);
ClassDB::bind_method(D_METHOD("set_is_room", "value"), &PropData2D::set_is_room);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_room"), "set_is_room", "get_is_room");
ClassDB::bind_method(D_METHOD("get_room_bounds"), &PropData::get_room_bounds);
ClassDB::bind_method(D_METHOD("set_room_bounds", "value"), &PropData::set_room_bounds);
ClassDB::bind_method(D_METHOD("get_room_bounds"), &PropData2D::get_room_bounds);
ClassDB::bind_method(D_METHOD("set_room_bounds", "value"), &PropData2D::set_room_bounds);
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "room_bounds"), "set_room_bounds", "get_room_bounds");
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData::copy_from);
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData2D::copy_from);
}

View File

@ -46,8 +46,8 @@ SOFTWARE.
#include "../../texture_packer/texture_packer.h"
#endif
class PropData : public Resource {
GDCLASS(PropData, Resource);
class PropData2D : public Resource {
GDCLASS(PropData2D, Resource);
public:
int get_id() const;
@ -59,9 +59,9 @@ public:
Vector3 get_snap_axis() const;
void set_snap_axis(const Vector3 &value);
Ref<PropDataEntry> get_prop(const int index) const;
void set_prop(const int index, const Ref<PropDataEntry> prop);
void add_prop(const Ref<PropDataEntry> prop);
Ref<PropDataEntry2D> get_prop(const int index) const;
void set_prop(const int index, const Ref<PropDataEntry2D> prop);
void add_prop(const Ref<PropDataEntry2D> prop);
void remove_prop(const int index);
int get_prop_count() const;
@ -79,10 +79,10 @@ public:
PoolVector3Array get_room_bounds();
void set_room_bounds(const PoolVector3Array &bounds);
void copy_from(const Ref<PropData> &prop_data);
void copy_from(const Ref<PropData2D> &prop_data);
PropData();
~PropData();
PropData2D();
~PropData2D();
protected:
static void _bind_methods();
@ -92,7 +92,7 @@ private:
bool _snap_to_mesh;
Vector3 _snap_axis;
Vector<Ref<PropDataEntry>> _props;
Vector<Ref<PropDataEntry2D>> _props;
bool _is_room;
PoolVector3Array _room_bounds;

View File

@ -40,64 +40,64 @@ SOFTWARE.
#include "../prop_mesher_2d.h"
Transform PropDataEntry::get_transform() const {
Transform PropDataEntry2D::get_transform() const {
return _transform;
}
void PropDataEntry::set_transform(const Transform &value) {
void PropDataEntry2D::set_transform(const Transform &value) {
_transform = value;
}
#if TEXTURE_PACKER_PRESENT
void PropDataEntry::add_textures_into(Ref<TexturePacker> texture_packer) {
void PropDataEntry2D::add_textures_into(Ref<TexturePacker> texture_packer) {
if (has_method("_add_textures_into"))
call("_add_textures_into", texture_packer);
}
#endif
bool PropDataEntry::processor_handles(Node *node) {
bool PropDataEntry2D::processor_handles(Node *node) {
return call("_processor_handles", node);
}
void PropDataEntry::processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
void PropDataEntry2D::processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
call("_processor_process", prop_data, node, transform);
}
Node *PropDataEntry::processor_get_node_for(const Transform &transform) {
Node *PropDataEntry2D::processor_get_node_for(const Transform &transform) {
return call("_processor_get_node_for", transform);
}
bool PropDataEntry::processor_evaluate_children() {
bool PropDataEntry2D::processor_evaluate_children() {
return call("_processor_evaluate_children");
}
bool PropDataEntry::_processor_handles(Node *node) {
bool PropDataEntry2D::_processor_handles(Node *node) {
return false;
}
void PropDataEntry::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
void PropDataEntry2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
}
Node *PropDataEntry::_processor_get_node_for(const Transform &transform) {
Node *PropDataEntry2D::_processor_get_node_for(const Transform &transform) {
return NULL;
}
bool PropDataEntry::_processor_evaluate_children() {
bool PropDataEntry2D::_processor_evaluate_children() {
return true;
}
PropDataEntry::PropDataEntry() {
PropDataEntry2D::PropDataEntry2D() {
}
PropDataEntry::~PropDataEntry() {
PropDataEntry2D::~PropDataEntry2D() {
}
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);
void PropDataEntry2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_transform"), &PropDataEntry2D::get_transform);
ClassDB::bind_method(D_METHOD("set_transform", "value"), &PropDataEntry2D::set_transform);
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "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")));
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropDataEntry::add_textures_into);
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropDataEntry2D::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, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"),
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"),
PropertyInfo(Variant::TRANSFORM, "transform")));
@ -106,14 +106,14 @@ void PropDataEntry::_bind_methods() {
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);
ClassDB::bind_method(D_METHOD("processor_get_node_for", "prop_data"), &PropDataEntry::processor_get_node_for);
ClassDB::bind_method(D_METHOD("processor_evaluate_children"), &PropDataEntry::processor_evaluate_children);
ClassDB::bind_method(D_METHOD("processor_handles", "node"), &PropDataEntry2D::processor_handles);
ClassDB::bind_method(D_METHOD("processor_process", "prop_data", "node", "transform"), &PropDataEntry2D::processor_process);
ClassDB::bind_method(D_METHOD("processor_get_node_for", "prop_data"), &PropDataEntry2D::processor_get_node_for);
ClassDB::bind_method(D_METHOD("processor_evaluate_children"), &PropDataEntry2D::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);
ClassDB::bind_method(D_METHOD("_processor_get_node_for", "transform"), &PropDataEntry::_processor_get_node_for);
ClassDB::bind_method(D_METHOD("_processor_evaluate_children"), &PropDataEntry::_processor_evaluate_children);
ClassDB::bind_method(D_METHOD("_processor_handles", "node"), &PropDataEntry2D::_processor_handles);
ClassDB::bind_method(D_METHOD("_processor_process", "prop_data", "node", "transform"), &PropDataEntry2D::_processor_process);
ClassDB::bind_method(D_METHOD("_processor_get_node_for", "transform"), &PropDataEntry2D::_processor_get_node_for);
ClassDB::bind_method(D_METHOD("_processor_evaluate_children"), &PropDataEntry2D::_processor_evaluate_children);
}

View File

@ -33,12 +33,12 @@ SOFTWARE.
#include "core/math/transform.h"
class PropData;
class PropMesher;
class PropData2D;
class PropMesher2D;
class TexturePacker;
class PropDataEntry : public Resource {
GDCLASS(PropDataEntry, Resource);
class PropDataEntry2D : public Resource {
GDCLASS(PropDataEntry2D, Resource);
public:
Transform get_transform() const;
@ -49,17 +49,17 @@ public:
#endif
bool processor_handles(Node *node);
void processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
void processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
Node *processor_get_node_for(const Transform &transform);
bool processor_evaluate_children();
virtual bool _processor_handles(Node *node);
virtual void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
virtual void _processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
virtual Node *_processor_get_node_for(const Transform &transform);
virtual bool _processor_evaluate_children();
PropDataEntry();
~PropDataEntry();
PropDataEntry2D();
~PropDataEntry2D();
protected:
static void _bind_methods();

View File

@ -32,32 +32,32 @@ SOFTWARE.
#define Light Light3D
#endif
Color PropDataLight::get_light_color() const {
Color PropDataLight2D::get_light_color() const {
return _light_color;
}
void PropDataLight::set_light_color(const Color value) {
void PropDataLight2D::set_light_color(const Color value) {
_light_color = value;
}
int PropDataLight::get_light_size() const {
int PropDataLight2D::get_light_size() const {
return _light_size;
}
void PropDataLight::set_light_size(const int value) {
void PropDataLight2D::set_light_size(const int value) {
_light_size = value;
}
bool PropDataLight::_processor_handles(Node *node) {
bool PropDataLight2D::_processor_handles(Node *node) {
OmniLight *i = Object::cast_to<OmniLight>(node);
return i;
}
void PropDataLight::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
void PropDataLight2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
OmniLight *i = Object::cast_to<OmniLight>(node);
ERR_FAIL_COND(!i);
Ref<PropDataLight> l;
Ref<PropDataLight2D> l;
l.instance();
l->set_light_color(i->get_color());
l->set_light_size(i->get_param(Light::PARAM_RANGE));
@ -65,7 +65,7 @@ void PropDataLight::_processor_process(Ref<PropData> prop_data, Node *node, cons
prop_data->add_prop(l);
}
Node *PropDataLight::_processor_get_node_for(const Transform &transform) {
Node *PropDataLight2D::_processor_get_node_for(const Transform &transform) {
OmniLight *i = memnew(OmniLight);
i->set_color(get_light_color());
@ -75,18 +75,18 @@ Node *PropDataLight::_processor_get_node_for(const Transform &transform) {
return i;
}
PropDataLight::PropDataLight() {
PropDataLight2D::PropDataLight2D() {
_light_size = 0;
}
PropDataLight::~PropDataLight() {
PropDataLight2D::~PropDataLight2D() {
}
void PropDataLight::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_light_color"), &PropDataLight::get_light_color);
ClassDB::bind_method(D_METHOD("set_light_color", "value"), &PropDataLight::set_light_color);
void PropDataLight2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_light_color"), &PropDataLight2D::get_light_color);
ClassDB::bind_method(D_METHOD("set_light_color", "value"), &PropDataLight2D::set_light_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), "set_light_color", "get_light_color");
ClassDB::bind_method(D_METHOD("get_light_size"), &PropDataLight::get_light_size);
ClassDB::bind_method(D_METHOD("set_light_size", "value"), &PropDataLight::set_light_size);
ClassDB::bind_method(D_METHOD("get_light_size"), &PropDataLight2D::get_light_size);
ClassDB::bind_method(D_METHOD("set_light_size", "value"), &PropDataLight2D::set_light_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_size"), "set_light_size", "get_light_size");
}

View File

@ -33,8 +33,8 @@ SOFTWARE.
#include "prop_data_entry_2d.h"
class PropDataLight : public PropDataEntry {
GDCLASS(PropDataLight, PropDataEntry);
class PropDataLight2D : public PropDataEntry2D {
GDCLASS(PropDataLight2D, PropDataEntry2D);
public:
Color get_light_color() const;
@ -44,11 +44,11 @@ public:
void set_light_size(const int value);
bool _processor_handles(Node *node);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataLight();
~PropDataLight();
PropDataLight2D();
~PropDataLight2D();
protected:
static void _bind_methods();

View File

@ -26,53 +26,53 @@ SOFTWARE.
#include "scene/3d/portal.h"
bool PropDataPortal::get_is_active() const {
bool PropDataPortal2D::get_is_active() const {
return _is_active;
}
void PropDataPortal::set_is_active(bool p_active) {
void PropDataPortal2D::set_is_active(bool p_active) {
_is_active = p_active;
}
bool PropDataPortal::get_is_two_way() const {
bool PropDataPortal2D::get_is_two_way() const {
return _is_two_way;
}
void PropDataPortal::set_is_two_way(bool p_two_way) {
void PropDataPortal2D::set_is_two_way(bool p_two_way) {
_is_two_way = p_two_way;
}
bool PropDataPortal::get_use_default_margin() const {
bool PropDataPortal2D::get_use_default_margin() const {
return _use_default_margin;
}
void PropDataPortal::set_use_default_margin(bool p_use) {
void PropDataPortal2D::set_use_default_margin(bool p_use) {
_use_default_margin = p_use;
}
real_t PropDataPortal::get_portal_margin() const {
real_t PropDataPortal2D::get_portal_margin() const {
return _portal_margin;
}
void PropDataPortal::set_portal_margin(real_t p_margin) {
void PropDataPortal2D::set_portal_margin(real_t p_margin) {
_portal_margin = p_margin;
}
PoolVector<Vector2> PropDataPortal::get_points() const {
PoolVector<Vector2> PropDataPortal2D::get_points() const {
return _points;
}
void PropDataPortal::set_points(const PoolVector<Vector2> &p_points) {
void PropDataPortal2D::set_points(const PoolVector<Vector2> &p_points) {
_points = p_points;
}
bool PropDataPortal::_processor_handles(Node *node) {
bool PropDataPortal2D::_processor_handles(Node *node) {
Portal *p = Object::cast_to<Portal>(node);
return p;
}
void PropDataPortal::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
void PropDataPortal2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
Portal *p = Object::cast_to<Portal>(node);
ERR_FAIL_COND(!p);
Ref<PropDataPortal> l;
Ref<PropDataPortal2D> l;
l.instance();
l->set_is_active(p->get_portal_active());
l->set_is_two_way(p->is_two_way());
@ -84,7 +84,7 @@ void PropDataPortal::_processor_process(Ref<PropData> prop_data, Node *node, con
prop_data->add_prop(l);
}
Node *PropDataPortal::_processor_get_node_for(const Transform &transform) {
Node *PropDataPortal2D::_processor_get_node_for(const Transform &transform) {
Portal *p = memnew(Portal);
p->set_portal_active(get_is_active());
@ -98,33 +98,33 @@ Node *PropDataPortal::_processor_get_node_for(const Transform &transform) {
return p;
}
PropDataPortal::PropDataPortal() {
PropDataPortal2D::PropDataPortal2D() {
_is_active = true;
_is_two_way = true;
_use_default_margin = true;
_portal_margin = 1;
}
PropDataPortal::~PropDataPortal() {
PropDataPortal2D::~PropDataPortal2D() {
}
void PropDataPortal::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_is_active"), &PropDataPortal::get_is_active);
ClassDB::bind_method(D_METHOD("set_is_active", "value"), &PropDataPortal::set_is_active);
void PropDataPortal2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_is_active"), &PropDataPortal2D::get_is_active);
ClassDB::bind_method(D_METHOD("set_is_active", "value"), &PropDataPortal2D::set_is_active);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_active"), "set_is_active", "get_is_active");
ClassDB::bind_method(D_METHOD("get_is_two_way"), &PropDataPortal::get_is_two_way);
ClassDB::bind_method(D_METHOD("set_is_two_way", "value"), &PropDataPortal::set_is_two_way);
ClassDB::bind_method(D_METHOD("get_is_two_way"), &PropDataPortal2D::get_is_two_way);
ClassDB::bind_method(D_METHOD("set_is_two_way", "value"), &PropDataPortal2D::set_is_two_way);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_two_way"), "set_is_two_way", "get_is_two_way");
ClassDB::bind_method(D_METHOD("get_use_default_margin"), &PropDataPortal::get_use_default_margin);
ClassDB::bind_method(D_METHOD("set_use_default_margin", "value"), &PropDataPortal::set_use_default_margin);
ClassDB::bind_method(D_METHOD("get_use_default_margin"), &PropDataPortal2D::get_use_default_margin);
ClassDB::bind_method(D_METHOD("set_use_default_margin", "value"), &PropDataPortal2D::set_use_default_margin);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_default_margin"), "set_use_default_margin", "get_use_default_margin");
ClassDB::bind_method(D_METHOD("get_portal_margin"), &PropDataPortal::get_portal_margin);
ClassDB::bind_method(D_METHOD("set_portal_margin", "value"), &PropDataPortal::set_portal_margin);
ClassDB::bind_method(D_METHOD("get_portal_margin"), &PropDataPortal2D::get_portal_margin);
ClassDB::bind_method(D_METHOD("set_portal_margin", "value"), &PropDataPortal2D::set_portal_margin);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "portal_margin"), "set_portal_margin", "get_portal_margin");
ClassDB::bind_method(D_METHOD("get_points"), &PropDataPortal::get_points);
ClassDB::bind_method(D_METHOD("set_points", "value"), &PropDataPortal::set_points);
ClassDB::bind_method(D_METHOD("get_points"), &PropDataPortal2D::get_points);
ClassDB::bind_method(D_METHOD("set_points", "value"), &PropDataPortal2D::set_points);
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "points"), "set_points", "get_points");
}

View File

@ -27,8 +27,8 @@ SOFTWARE.
#include "prop_data_entry_2d.h"
class PropDataPortal : public PropDataEntry {
GDCLASS(PropDataPortal, PropDataEntry);
class PropDataPortal2D : public PropDataEntry2D {
GDCLASS(PropDataPortal2D, PropDataEntry2D);
public:
bool get_is_active() const;
@ -47,11 +47,11 @@ public:
void set_points(const PoolVector<Vector2> &p_points);
bool _processor_handles(Node *node);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataPortal();
~PropDataPortal();
PropDataPortal2D();
~PropDataPortal2D();
protected:
static void _bind_methods();

View File

@ -25,55 +25,55 @@ SOFTWARE.
#include "../prop_instance_2d.h"
#include "prop_data_2d.h"
Ref<PropData> PropDataProp::get_prop() const {
Ref<PropData2D> PropDataProp2D::get_prop() const {
return _prop;
}
void PropDataProp::set_prop(const Ref<PropData> value) {
void PropDataProp2D::set_prop(const Ref<PropData2D> value) {
_prop = value;
}
bool PropDataProp::get_snap_to_mesh() {
bool PropDataProp2D::get_snap_to_mesh() {
return _snap_to_mesh;
}
void PropDataProp::set_snap_to_mesh(bool value) {
void PropDataProp2D::set_snap_to_mesh(bool value) {
_snap_to_mesh = value;
}
Vector3 PropDataProp::get_snap_axis() {
Vector3 PropDataProp2D::get_snap_axis() {
return _snap_axis;
}
void PropDataProp::set_snap_axis(Vector3 value) {
void PropDataProp2D::set_snap_axis(Vector3 value) {
_snap_axis = value;
}
#if TEXTURE_PACKER_PRESENT
void PropDataProp::_add_textures_into(Ref<TexturePacker> texture_packer) {
void PropDataProp2D::_add_textures_into(Ref<TexturePacker> texture_packer) {
if (get_prop().is_valid()) {
get_prop()->add_textures_into(texture_packer);
}
}
#endif
bool PropDataProp::_processor_handles(Node *node) {
PropInstance *i = Object::cast_to<PropInstance>(node);
bool PropDataProp2D::_processor_handles(Node *node) {
PropInstance2D *i = Object::cast_to<PropInstance2D>(node);
return i;
}
void PropDataProp::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
PropInstance *i = Object::cast_to<PropInstance>(node);
void PropDataProp2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
PropInstance2D *i = Object::cast_to<PropInstance2D>(node);
ERR_FAIL_COND(!i);
Ref<PropDataProp> l;
Ref<PropDataProp2D> l;
l.instance();
l->set_prop(i->get_prop_data());
l->set_transform(transform * i->get_transform());
prop_data->add_prop(l);
}
Node *PropDataProp::_processor_get_node_for(const Transform &transform) {
PropInstance *i = memnew(PropInstance);
Node *PropDataProp2D::_processor_get_node_for(const Transform &transform) {
PropInstance2D *i = memnew(PropInstance2D);
i->set_prop_data(get_prop());
i->set_transform(get_transform());
@ -81,29 +81,29 @@ Node *PropDataProp::_processor_get_node_for(const Transform &transform) {
return i;
}
PropDataProp::PropDataProp() {
PropDataProp2D::PropDataProp2D() {
_snap_to_mesh = false;
_snap_axis = Vector3(0, 1, 0);
}
PropDataProp::~PropDataProp() {
PropDataProp2D::~PropDataProp2D() {
if (_prop.is_valid())
_prop.unref();
}
void PropDataProp::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_prop"), &PropDataProp::get_prop);
ClassDB::bind_method(D_METHOD("set_prop", "value"), &PropDataProp::set_prop);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop", "get_prop");
void PropDataProp2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_prop"), &PropDataProp2D::get_prop);
ClassDB::bind_method(D_METHOD("set_prop", "value"), &PropDataProp2D::set_prop);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"), "set_prop", "get_prop");
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataProp::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataProp::set_snap_to_mesh);
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataProp2D::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataProp2D::set_snap_to_mesh);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropDataProp::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataProp::set_snap_axis);
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropDataProp2D::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataProp2D::set_snap_axis);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
#if TEXTURE_PACKER_PRESENT
ClassDB::bind_method(D_METHOD("_add_textures_into", "texture_packer"), &PropDataProp::_add_textures_into);
ClassDB::bind_method(D_METHOD("_add_textures_into", "texture_packer"), &PropDataProp2D::_add_textures_into);
#endif
}

View File

@ -32,12 +32,12 @@ SOFTWARE.
#include "../../texture_packer/texture_packer.h"
#endif
class PropDataProp : public PropDataEntry {
GDCLASS(PropDataProp, PropDataEntry);
class PropDataProp2D : public PropDataEntry2D {
GDCLASS(PropDataProp2D, PropDataEntry2D);
public:
Ref<PropData> get_prop() const;
void set_prop(const Ref<PropData> value);
Ref<PropData2D> get_prop() const;
void set_prop(const Ref<PropData2D> value);
bool get_snap_to_mesh();
void set_snap_to_mesh(bool value);
@ -50,11 +50,11 @@ public:
#endif
bool _processor_handles(Node *node);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataProp();
~PropDataProp();
PropDataProp2D();
~PropDataProp2D();
protected:
static void _bind_methods();
@ -62,7 +62,7 @@ protected:
private:
bool _snap_to_mesh;
Vector3 _snap_axis;
Ref<PropData> _prop;
Ref<PropData2D> _prop;
};
#endif

View File

@ -25,47 +25,47 @@ SOFTWARE.
#include "../prop_scene_instance_2d.h"
#include "prop_data_2d.h"
Ref<PackedScene> PropDataScene::get_scene() {
Ref<PackedScene> PropDataScene2D::get_scene() {
return _scene;
}
void PropDataScene::set_scene(const Ref<PackedScene> &value) {
void PropDataScene2D::set_scene(const Ref<PackedScene> &value) {
_scene = value;
}
bool PropDataScene::get_snap_to_mesh() {
bool PropDataScene2D::get_snap_to_mesh() {
return _snap_to_mesh;
}
void PropDataScene::set_snap_to_mesh(bool value) {
void PropDataScene2D::set_snap_to_mesh(bool value) {
_snap_to_mesh = value;
}
Vector3 PropDataScene::get_snap_axis() {
Vector3 PropDataScene2D::get_snap_axis() {
return _snap_axis;
}
void PropDataScene::set_snap_axis(Vector3 value) {
void PropDataScene2D::set_snap_axis(Vector3 value) {
_snap_axis = value;
}
bool PropDataScene::_processor_handles(Node *node) {
PropSceneInstance *i = Object::cast_to<PropSceneInstance>(node);
bool PropDataScene2D::_processor_handles(Node *node) {
PropSceneInstance2D *i = Object::cast_to<PropSceneInstance2D>(node);
return i;
}
void PropDataScene::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
PropSceneInstance *i = Object::cast_to<PropSceneInstance>(node);
void PropDataScene2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
PropSceneInstance2D *i = Object::cast_to<PropSceneInstance2D>(node);
ERR_FAIL_COND(!i);
Ref<PropDataScene> l;
Ref<PropDataScene2D> l;
l.instance();
l->set_scene(i->get_scene());
l->set_transform(transform * i->get_transform());
prop_data->add_prop(l);
}
Node *PropDataScene::_processor_get_node_for(const Transform &transform) {
PropSceneInstance *i = memnew(PropSceneInstance);
Node *PropDataScene2D::_processor_get_node_for(const Transform &transform) {
PropSceneInstance2D *i = memnew(PropSceneInstance2D);
i->set_scene(get_scene());
i->set_transform(get_transform());
@ -73,25 +73,25 @@ Node *PropDataScene::_processor_get_node_for(const Transform &transform) {
return i;
}
PropDataScene::PropDataScene() {
PropDataScene2D::PropDataScene2D() {
_snap_to_mesh = true;
_snap_axis = Vector3(0, 1, 0);
}
PropDataScene::~PropDataScene() {
PropDataScene2D::~PropDataScene2D() {
if (_scene.is_valid())
_scene.unref();
}
void PropDataScene::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_scene"), &PropDataScene::get_scene);
ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropDataScene::set_scene);
void PropDataScene2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_scene"), &PropDataScene2D::get_scene);
ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropDataScene2D::set_scene);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataScene::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataScene::set_snap_to_mesh);
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataScene2D::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataScene2D::set_snap_to_mesh);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropDataScene::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataScene::set_snap_axis);
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropDataScene2D::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataScene2D::set_snap_axis);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
}

View File

@ -28,8 +28,8 @@ SOFTWARE.
#include "scene/resources/packed_scene.h"
class PropDataScene : public PropDataEntry {
GDCLASS(PropDataScene, PropDataEntry);
class PropDataScene2D : public PropDataEntry2D {
GDCLASS(PropDataScene2D, PropDataEntry2D);
public:
Ref<PackedScene> get_scene();
@ -42,11 +42,11 @@ public:
void set_snap_axis(Vector3 value);
bool _processor_handles(Node *node);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataScene();
~PropDataScene();
PropDataScene2D();
~PropDataScene2D();
protected:
static void _bind_methods();

View File

@ -27,46 +27,46 @@ SOFTWARE.
#include "prop_data_2d.h"
int PropDataTiledWall::get_width() const {
int PropDataTiledWall2D::get_width() const {
return _width;
}
void PropDataTiledWall::set_width(const int value) {
void PropDataTiledWall2D::set_width(const int value) {
_width = value;
}
int PropDataTiledWall::get_heigth() const {
int PropDataTiledWall2D::get_heigth() const {
return _height;
}
void PropDataTiledWall::set_heigth(const int value) {
void PropDataTiledWall2D::set_heigth(const int value) {
_height = value;
}
Ref<TiledWallData> PropDataTiledWall::get_data() {
Ref<TiledWallData2D> PropDataTiledWall2D::get_data() {
return _data;
}
void PropDataTiledWall::set_data(const Ref<TiledWallData> &data) {
void PropDataTiledWall2D::set_data(const Ref<TiledWallData2D> &data) {
_data = data;
}
bool PropDataTiledWall::get_collision() const {
bool PropDataTiledWall2D::get_collision() const {
return _collision;
}
void PropDataTiledWall::set_collision(const int value) {
void PropDataTiledWall2D::set_collision(const int value) {
_collision = value;
}
bool PropDataTiledWall::_processor_handles(Node *node) {
TiledWall *t = Object::cast_to<TiledWall>(node);
bool PropDataTiledWall2D::_processor_handles(Node *node) {
TiledWall2D *t = Object::cast_to<TiledWall2D>(node);
return t;
}
void PropDataTiledWall::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
TiledWall *t = Object::cast_to<TiledWall>(node);
void PropDataTiledWall2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
TiledWall2D *t = Object::cast_to<TiledWall2D>(node);
ERR_FAIL_COND(!t);
Ref<PropDataTiledWall> tw;
Ref<PropDataTiledWall2D> tw;
tw.instance();
tw->set_width(t->get_width());
@ -77,8 +77,8 @@ void PropDataTiledWall::_processor_process(Ref<PropData> prop_data, Node *node,
prop_data->add_prop(tw);
}
Node *PropDataTiledWall::_processor_get_node_for(const Transform &transform) {
TiledWall *t = memnew(TiledWall);
Node *PropDataTiledWall2D::_processor_get_node_for(const Transform &transform) {
TiledWall2D *t = memnew(TiledWall2D);
t->set_width(get_width());
t->set_heigth(get_heigth());
@ -89,29 +89,29 @@ Node *PropDataTiledWall::_processor_get_node_for(const Transform &transform) {
return t;
}
PropDataTiledWall::PropDataTiledWall() {
PropDataTiledWall2D::PropDataTiledWall2D() {
_width = 1;
_height = 1;
_collision = true;
}
PropDataTiledWall::~PropDataTiledWall() {
PropDataTiledWall2D::~PropDataTiledWall2D() {
_data.unref();
}
void PropDataTiledWall::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_width"), &PropDataTiledWall::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &PropDataTiledWall::set_width);
void PropDataTiledWall2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_width"), &PropDataTiledWall2D::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &PropDataTiledWall2D::set_width);
ADD_PROPERTY(PropertyInfo(Variant::INT, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_heigth"), &PropDataTiledWall::get_heigth);
ClassDB::bind_method(D_METHOD("set_heigth", "value"), &PropDataTiledWall::set_heigth);
ClassDB::bind_method(D_METHOD("get_heigth"), &PropDataTiledWall2D::get_heigth);
ClassDB::bind_method(D_METHOD("set_heigth", "value"), &PropDataTiledWall2D::set_heigth);
ADD_PROPERTY(PropertyInfo(Variant::INT, "heigth"), "set_heigth", "get_heigth");
ClassDB::bind_method(D_METHOD("get_data"), &PropDataTiledWall::get_data);
ClassDB::bind_method(D_METHOD("set_data", "value"), &PropDataTiledWall::set_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "TiledWallData"), "set_data", "get_data");
ClassDB::bind_method(D_METHOD("get_data"), &PropDataTiledWall2D::get_data);
ClassDB::bind_method(D_METHOD("set_data", "value"), &PropDataTiledWall2D::set_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "TiledWall2DData"), "set_data", "get_data");
ClassDB::bind_method(D_METHOD("get_collision"), &PropDataTiledWall::get_collision);
ClassDB::bind_method(D_METHOD("set_collision", "value"), &PropDataTiledWall::set_collision);
ClassDB::bind_method(D_METHOD("get_collision"), &PropDataTiledWall2D::get_collision);
ClassDB::bind_method(D_METHOD("set_collision", "value"), &PropDataTiledWall2D::set_collision);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision"), "set_collision", "get_collision");
}

View File

@ -26,10 +26,10 @@ SOFTWARE.
#include "core/math/vector3.h"
#include "prop_data_entry_2d.h"
class TiledWallData;
class TiledWallData2D;
class PropDataTiledWall : public PropDataEntry {
GDCLASS(PropDataTiledWall, PropDataEntry);
class PropDataTiledWall2D : public PropDataEntry2D {
GDCLASS(PropDataTiledWall2D, PropDataEntry2D);
public:
int get_width() const;
@ -38,18 +38,18 @@ public:
int get_heigth() const;
void set_heigth(const int value);
Ref<TiledWallData> get_data();
void set_data(const Ref<TiledWallData> &data);
Ref<TiledWallData2D> get_data();
void set_data(const Ref<TiledWallData2D> &data);
bool get_collision() const;
void set_collision(const int value);
bool _processor_handles(Node *node);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataTiledWall();
~PropDataTiledWall();
PropDataTiledWall2D();
~PropDataTiledWall2D();
protected:
static void _bind_methods();
@ -59,7 +59,7 @@ private:
int _height;
bool _collision;
Ref<TiledWallData> _data;
Ref<TiledWallData2D> _data;
};
#endif

View File

@ -74,77 +74,77 @@ SOFTWARE.
#include "material_cache/prop_material_cache_pcm_2d.h"
#endif
static PropUtils *prop_utils = NULL;
static PropCache *prop_texture_cache = NULL;
static PropUtils2D *prop_utils = NULL;
static PropCache2D *prop_texture_cache = NULL;
void register_props_2d_types() {
ClassDB::register_class<TiledWall>();
ClassDB::register_class<TiledWallData>();
ClassDB::register_class<TiledWall2D>();
ClassDB::register_class<TiledWallData2D>();
ClassDB::register_class<PropLight>();
ClassDB::register_class<PropLight2D>();
ClassDB::register_class<PropData>();
ClassDB::register_class<PropDataEntry>();
ClassDB::register_class<PropDataScene>();
ClassDB::register_class<PropDataLight>();
ClassDB::register_class<PropDataProp>();
ClassDB::register_class<PropDataTiledWall>();
ClassDB::register_class<PropData2D>();
ClassDB::register_class<PropDataEntry2D>();
ClassDB::register_class<PropDataScene2D>();
ClassDB::register_class<PropDataLight2D>();
ClassDB::register_class<PropDataProp2D>();
ClassDB::register_class<PropDataTiledWall2D>();
#if VERSION_MINOR >= 4
ClassDB::register_class<PropDataPortal>();
ClassDB::register_class<PropDataPortal2D>();
#endif
ClassDB::register_class<GroundClutter>();
ClassDB::register_class<GroundClutterFoliage>();
ClassDB::register_class<GroundClutter2D>();
ClassDB::register_class<GroundClutterFoliage2D>();
ClassDB::register_class<PropMesher>();
ClassDB::register_class<PropMesherJobStep>();
ClassDB::register_class<PropMesher2D>();
ClassDB::register_class<PropMesherJobStep2D>();
ClassDB::register_class<PropInstance>();
ClassDB::register_class<PropInstanceMerger>();
ClassDB::register_class<PropInstance2D>();
ClassDB::register_class<PropInstanceMerger2D>();
ClassDB::register_class<PropESSEntity>();
ClassDB::register_class<PropESSEntity2D>();
ClassDB::register_class<PropInstanceJob>();
ClassDB::register_class<PropInstancePropJob>();
ClassDB::register_class<PropInstanceJob2D>();
ClassDB::register_class<PropInstancePropJob2D>();
ClassDB::register_class<PropTextureJob>();
ClassDB::register_class<PropTextureJob2D>();
ClassDB::register_class<PropSceneInstance>();
ClassDB::register_class<PropSceneInstance2D>();
ClassDB::register_class<PropMaterialCache>();
ClassDB::register_class<PropMaterialCache2D>();
#ifdef TEXTURE_PACKER_PRESENT
ClassDB::register_class<PropMaterialCachePCM>();
ClassDB::register_class<PropMaterialCachePCM2D>();
#endif
prop_utils = memnew(PropUtils);
ClassDB::register_class<PropUtils>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton()));
prop_utils = memnew(PropUtils2D);
ClassDB::register_class<PropUtils2D>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils2D", PropUtils2D::get_singleton()));
prop_texture_cache = memnew(PropCache);
ClassDB::register_class<PropCache>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton()));
prop_texture_cache = memnew(PropCache2D);
ClassDB::register_class<PropCache2D>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache2D", PropCache2D::get_singleton()));
Ref<PropDataLight> light_processor = Ref<PropDataLight>(memnew(PropDataLight));
PropUtils::add_processor(light_processor);
Ref<PropDataLight2D> light_processor = Ref<PropDataLight2D>(memnew(PropDataLight2D));
PropUtils2D::add_processor(light_processor);
Ref<PropDataProp> prop_processor = Ref<PropDataProp>(memnew(PropDataProp));
PropUtils::add_processor(prop_processor);
Ref<PropDataProp2D> prop_processor = Ref<PropDataProp2D>(memnew(PropDataProp2D));
PropUtils2D::add_processor(prop_processor);
Ref<PropDataScene> scene_processor = Ref<PropDataScene>(memnew(PropDataScene));
PropUtils::add_processor(scene_processor);
Ref<PropDataScene2D> scene_processor = Ref<PropDataScene2D>(memnew(PropDataScene2D));
PropUtils2D::add_processor(scene_processor);
#if VERSION_MINOR >= 4
Ref<PropDataPortal> portal_processor = Ref<PropDataPortal>(memnew(PropDataPortal));
PropUtils::add_processor(portal_processor);
Ref<PropDataPortal2D> portal_processor = Ref<PropDataPortal2D>(memnew(PropDataPortal2D));
PropUtils2D::add_processor(portal_processor);
#endif
Ref<PropDataTiledWall> tiled_wall_processor = Ref<PropDataTiledWall>(memnew(PropDataTiledWall));
PropUtils::add_processor(tiled_wall_processor);
Ref<PropDataTiledWall2D> tiled_wall_processor = Ref<PropDataTiledWall2D>(memnew(PropDataTiledWall2D));
PropUtils2D::add_processor(tiled_wall_processor);
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<PropEditorPlugin>();
EditorPlugins::add_by_type<PropEditorPlugin2D>();
#endif
}

View File

@ -66,94 +66,94 @@ SOFTWARE.
#endif
PropCache *PropCache::_instance;
PropCache2D *PropCache2D::_instance;
PropCache *PropCache::get_singleton() {
PropCache2D *PropCache2D::get_singleton() {
return _instance;
}
StringName PropCache::get_default_prop_material_cache_class() {
StringName PropCache2D::get_default_prop_material_cache_class() {
return _default_prop_material_cache_class;
}
void PropCache::set_default_prop_material_cache_class(const StringName &cls_name) {
void PropCache2D::set_default_prop_material_cache_class(const StringName &cls_name) {
_default_prop_material_cache_class = cls_name;
}
#ifdef TEXTURE_PACKER_PRESENT
int PropCache::get_texture_flags() const {
int PropCache2D::get_texture_flags() const {
return _texture_flags;
}
void PropCache::set_texture_flags(const int flags) {
void PropCache2D::set_texture_flags(const int flags) {
_texture_flags = flags;
}
int PropCache::get_max_atlas_size() const {
int PropCache2D::get_max_atlas_size() const {
return _max_atlas_size;
}
void PropCache::set_max_atlas_size(const int size) {
void PropCache2D::set_max_atlas_size(const int size) {
_max_atlas_size = size;
}
bool PropCache::get_keep_original_atlases() const {
bool PropCache2D::get_keep_original_atlases() const {
return _keep_original_atlases;
}
void PropCache::set_keep_original_atlases(const bool value) {
void PropCache2D::set_keep_original_atlases(const bool value) {
_keep_original_atlases = value;
}
Color PropCache::get_background_color() const {
Color PropCache2D::get_background_color() const {
return _background_color;
}
void PropCache::set_background_color(const Color &color) {
void PropCache2D::set_background_color(const Color &color) {
_background_color = color;
}
int PropCache::get_margin() const {
int PropCache2D::get_margin() const {
return _margin;
}
void PropCache::set_margin(const int margin) {
void PropCache2D::set_margin(const int margin) {
_margin = margin;
}
#endif
PoolStringArray PropCache::material_paths_get() const {
PoolStringArray PropCache2D::material_paths_get() const {
return _material_paths;
}
void PropCache::material_paths_set(const PoolStringArray &value) {
void PropCache2D::material_paths_set(const PoolStringArray &value) {
_material_paths = value;
}
void PropCache::material_add(const Ref<Material> &value) {
void PropCache2D::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
Ref<Material> PropCache::material_get(const int index) {
Ref<Material> PropCache2D::material_get(const int index) {
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>());
return _materials[index];
}
void PropCache::material_set(const int index, const Ref<Material> &value) {
void PropCache2D::material_set(const int index, const Ref<Material> &value) {
ERR_FAIL_INDEX(index, _materials.size());
_materials.set(index, value);
}
void PropCache::material_remove(const int index) {
void PropCache2D::material_remove(const int index) {
_materials.remove(index);
}
int PropCache::material_get_num() const {
int PropCache2D::material_get_num() const {
return _materials.size();
}
void PropCache::materials_clear() {
void PropCache2D::materials_clear() {
_materials.clear();
}
void PropCache::materials_load() {
void PropCache2D::materials_load() {
_materials.clear();
for (int i = 0; i < _material_paths.size(); ++i) {
@ -169,17 +169,17 @@ void PropCache::materials_load() {
}
}
void PropCache::ensure_materials_loaded() {
void PropCache2D::ensure_materials_loaded() {
if (_materials.size() != _material_paths.size()) {
materials_load();
}
}
Vector<Variant> PropCache::materials_get() {
Vector<Variant> PropCache2D::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void PropCache::materials_set(const Vector<Variant> &materials) {
void PropCache2D::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
@ -189,16 +189,16 @@ void PropCache::materials_set(const Vector<Variant> &materials) {
}
}
Ref<PropMaterialCache> PropCache::material_cache_get(const Ref<PropData> &prop) {
ERR_FAIL_COND_V(!prop.is_valid(), Ref<PropMaterialCache>());
Ref<PropMaterialCache2D> PropCache2D::material_cache_get(const Ref<PropData2D> &prop) {
ERR_FAIL_COND_V(!prop.is_valid(), Ref<PropMaterialCache2D>());
//get pointer's value as uint64
uint64_t k = make_uint64_t<const PropData *>(*prop);
uint64_t k = make_uint64_t<const PropData2D *>(*prop);
_material_cache_mutex.lock();
if (_material_cache.has(k)) {
Ref<PropMaterialCache> m = _material_cache[k];
Ref<PropMaterialCache2D> m = _material_cache[k];
m->inc_ref_count();
@ -207,13 +207,13 @@ 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));
PropMaterialCache2D *p = Object::cast_to<PropMaterialCache2D>(ClassDB::instance(_default_prop_material_cache_class));
if (!p) {
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class));
}
Ref<PropMaterialCache> m(p);
Ref<PropMaterialCache2D> m(p);
_material_cache[k] = m;
@ -221,21 +221,21 @@ Ref<PropMaterialCache> PropCache::material_cache_get(const Ref<PropData> &prop)
return m;
}
void PropCache::material_cache_unref(const Ref<PropData> &prop) {
void PropCache2D::material_cache_unref(const Ref<PropData2D> &prop) {
//get pointer's value as uint64
uint64_t k = make_uint64_t<const PropData *>(*prop);
uint64_t k = make_uint64_t<const PropData2D *>(*prop);
_material_cache_mutex.lock();
if (!_material_cache.has(k)) {
_material_cache_mutex.unlock();
ERR_PRINT("PropCache::material_cache_unref: can't find cache!");
ERR_PRINT("PropCache2D::material_cache_unref: can't find cache!");
return;
}
Ref<PropMaterialCache> m = _material_cache[k];
Ref<PropMaterialCache2D> m = _material_cache[k];
m->dec_ref_count();
if (m->get_ref_count() <= 0) {
@ -245,16 +245,16 @@ void PropCache::material_cache_unref(const Ref<PropData> &prop) {
_material_cache_mutex.unlock();
}
Ref<PropMaterialCache> PropCache::tiled_wall_material_cache_get(const Ref<TiledWallData> &twd) {
ERR_FAIL_COND_V(!twd.is_valid(), Ref<PropMaterialCache>());
Ref<PropMaterialCache2D> PropCache2D::tiled_wall_material_cache_get(const Ref<TiledWallData2D> &twd) {
ERR_FAIL_COND_V(!twd.is_valid(), Ref<PropMaterialCache2D>());
//get pointer's value as uint64
uint64_t k = make_uint64_t<const TiledWallData *>(*twd);
uint64_t k = make_uint64_t<const TiledWallData2D *>(*twd);
_tiled_wall_material_cache_mutex.lock();
if (_tiled_wall_material_cache.has(k)) {
Ref<PropMaterialCache> m = _tiled_wall_material_cache[k];
Ref<PropMaterialCache2D> m = _tiled_wall_material_cache[k];
m->inc_ref_count();
@ -263,13 +263,13 @@ 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));
PropMaterialCache2D *p = Object::cast_to<PropMaterialCache2D>(ClassDB::instance(_default_prop_material_cache_class));
if (!p) {
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class));
}
Ref<PropMaterialCache> m(p);
Ref<PropMaterialCache2D> m(p);
_tiled_wall_material_cache[k] = m;
@ -277,21 +277,21 @@ Ref<PropMaterialCache> PropCache::tiled_wall_material_cache_get(const Ref<TiledW
return m;
}
void PropCache::tiled_wall_material_cache_unref(const Ref<TiledWallData> &twd) {
void PropCache2D::tiled_wall_material_cache_unref(const Ref<TiledWallData2D> &twd) {
//get pointer's value as uint64
uint64_t k = make_uint64_t<const TiledWallData *>(*twd);
uint64_t k = make_uint64_t<const TiledWallData2D *>(*twd);
_tiled_wall_material_cache_mutex.lock();
if (!_tiled_wall_material_cache.has(k)) {
_tiled_wall_material_cache_mutex.unlock();
ERR_PRINT("PropCache::material_cache_unref: can't find cache!");
ERR_PRINT("PropCache2D::material_cache_unref: can't find cache!");
return;
}
Ref<PropMaterialCache> m = _tiled_wall_material_cache[k];
Ref<PropMaterialCache2D> m = _tiled_wall_material_cache[k];
m->dec_ref_count();
if (m->get_ref_count() <= 0) {
@ -301,11 +301,11 @@ void PropCache::tiled_wall_material_cache_unref(const Ref<TiledWallData> &twd) {
_tiled_wall_material_cache_mutex.unlock();
}
Ref<PropMaterialCache> PropCache::material_cache_custom_key_get(const uint64_t key) {
Ref<PropMaterialCache2D> PropCache2D::material_cache_custom_key_get(const uint64_t key) {
_custom_keyed_material_cache_mutex.lock();
if (_custom_keyed_material_cache.has(key)) {
Ref<PropMaterialCache> m = _custom_keyed_material_cache[key];
Ref<PropMaterialCache2D> m = _custom_keyed_material_cache[key];
m->inc_ref_count();
@ -314,13 +314,13 @@ 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));
PropMaterialCache2D *p = Object::cast_to<PropMaterialCache2D>(ClassDB::instance(_default_prop_material_cache_class));
if (!p) {
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class));
}
Ref<PropMaterialCache> m(p);
Ref<PropMaterialCache2D> m(p);
_custom_keyed_material_cache[key] = m;
@ -328,18 +328,18 @@ Ref<PropMaterialCache> PropCache::material_cache_custom_key_get(const uint64_t k
return m;
}
void PropCache::material_cache_custom_key_unref(const uint64_t key) {
void PropCache2D::material_cache_custom_key_unref(const uint64_t key) {
_custom_keyed_material_cache_mutex.lock();
if (!_material_cache.has(key)) {
_custom_keyed_material_cache_mutex.unlock();
ERR_PRINT("PropCache::material_cache_custom_key_unref: can't find cache!");
ERR_PRINT("PropCache2D::material_cache_custom_key_unref: can't find cache!");
return;
}
Ref<PropMaterialCache> m = _custom_keyed_material_cache[key];
Ref<PropMaterialCache2D> m = _custom_keyed_material_cache[key];
m->dec_ref_count();
if (m->get_ref_count() <= 0) {
@ -349,7 +349,7 @@ void PropCache::material_cache_custom_key_unref(const uint64_t key) {
_custom_keyed_material_cache_mutex.unlock();
}
Ref<Resource> PropCache::load_resource(const String &path, const String &type_hint) {
Ref<Resource> PropCache2D::load_resource(const String &path, const String &type_hint) {
_ResourceLoader *rl = _ResourceLoader::get_singleton();
#if VERSION_MAJOR < 4
@ -365,13 +365,13 @@ Ref<Resource> PropCache::load_resource(const String &path, const String &type_hi
#endif
}
PropCache::PropCache() {
PropCache2D::PropCache2D() {
_instance = this;
#if TEXTURE_PACKER_PRESENT
_default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCachePCM");
_default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache2DPCM");
#else
_default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache");
_default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache2D");
#endif
#ifdef TEXTURE_PACKER_PRESENT
@ -390,62 +390,62 @@ PropCache::PropCache() {
_material_paths = GLOBAL_DEF("props/material_paths", PoolStringArray());
}
PropCache::~PropCache() {
PropCache2D::~PropCache2D() {
_instance = NULL;
}
void PropCache::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_default_prop_material_cache_class"), &PropCache::get_default_prop_material_cache_class);
ClassDB::bind_method(D_METHOD("set_default_prop_material_cache_class", "cls_name"), &PropCache::set_default_prop_material_cache_class);
void PropCache2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_default_prop_material_cache_class"), &PropCache2D::get_default_prop_material_cache_class);
ClassDB::bind_method(D_METHOD("set_default_prop_material_cache_class", "cls_name"), &PropCache2D::set_default_prop_material_cache_class);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "default_prop_material_cache_class"), "set_default_prop_material_cache_class", "get_default_prop_material_cache_class");
#ifdef TEXTURE_PACKER_PRESENT
ClassDB::bind_method(D_METHOD("get_texture_flags"), &PropCache::get_texture_flags);
ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropCache::set_texture_flags);
ClassDB::bind_method(D_METHOD("get_texture_flags"), &PropCache2D::get_texture_flags);
ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropCache2D::set_texture_flags);
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_texture_flags", "get_texture_flags");
ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &PropCache::get_max_atlas_size);
ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropCache::set_max_atlas_size);
ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &PropCache2D::get_max_atlas_size);
ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropCache2D::set_max_atlas_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_atlas_size"), "set_max_atlas_size", "get_max_atlas_size");
ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &PropCache::get_keep_original_atlases);
ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropCache::set_keep_original_atlases);
ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &PropCache2D::get_keep_original_atlases);
ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropCache2D::set_keep_original_atlases);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases");
ClassDB::bind_method(D_METHOD("get_background_color"), &PropCache::get_background_color);
ClassDB::bind_method(D_METHOD("set_background_color", "color"), &PropCache::set_background_color);
ClassDB::bind_method(D_METHOD("get_background_color"), &PropCache2D::get_background_color);
ClassDB::bind_method(D_METHOD("set_background_color", "color"), &PropCache2D::set_background_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color");
ClassDB::bind_method(D_METHOD("get_margin"), &PropCache::get_margin);
ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropCache::set_margin);
ClassDB::bind_method(D_METHOD("get_margin"), &PropCache2D::get_margin);
ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropCache2D::set_margin);
ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin");
#endif
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);
ClassDB::bind_method(D_METHOD("material_paths_get"), &PropCache2D::material_paths_get);
ClassDB::bind_method(D_METHOD("material_paths_set", "value"), &PropCache2D::material_paths_set);
ADD_PROPERTY(PropertyInfo(Variant::POOL_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);
ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropCache::material_set);
ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropCache::material_remove);
ClassDB::bind_method(D_METHOD("material_get_num"), &PropCache::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &PropCache::materials_clear);
ClassDB::bind_method(D_METHOD("materials_load"), &PropCache::materials_load);
ClassDB::bind_method(D_METHOD("ensure_materials_loaded"), &PropCache::ensure_materials_loaded);
ClassDB::bind_method(D_METHOD("material_add", "value"), &PropCache2D::material_add);
ClassDB::bind_method(D_METHOD("material_get", "index"), &PropCache2D::material_get);
ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropCache2D::material_set);
ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropCache2D::material_remove);
ClassDB::bind_method(D_METHOD("material_get_num"), &PropCache2D::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &PropCache2D::materials_clear);
ClassDB::bind_method(D_METHOD("materials_load"), &PropCache2D::materials_load);
ClassDB::bind_method(D_METHOD("ensure_materials_loaded"), &PropCache2D::ensure_materials_loaded);
ClassDB::bind_method(D_METHOD("materials_get"), &PropCache::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropCache::materials_set);
ClassDB::bind_method(D_METHOD("materials_get"), &PropCache2D::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropCache2D::materials_set);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
ClassDB::bind_method(D_METHOD("material_cache_get", "prop"), &PropCache::material_cache_get);
ClassDB::bind_method(D_METHOD("material_cache_unref", "prop"), &PropCache::material_cache_unref);
ClassDB::bind_method(D_METHOD("material_cache_get", "prop"), &PropCache2D::material_cache_get);
ClassDB::bind_method(D_METHOD("material_cache_unref", "prop"), &PropCache2D::material_cache_unref);
ClassDB::bind_method(D_METHOD("tiled_wall_material_cache_get", "twd"), &PropCache::tiled_wall_material_cache_get);
ClassDB::bind_method(D_METHOD("tiled_wall_material_cache_unref", "twd"), &PropCache::tiled_wall_material_cache_unref);
ClassDB::bind_method(D_METHOD("tiled_wall_material_cache_get", "twd"), &PropCache2D::tiled_wall_material_cache_get);
ClassDB::bind_method(D_METHOD("tiled_wall_material_cache_unref", "twd"), &PropCache2D::tiled_wall_material_cache_unref);
ClassDB::bind_method(D_METHOD("material_cache_custom_key_get", "key"), &PropCache::material_cache_custom_key_get);
ClassDB::bind_method(D_METHOD("material_cache_custom_key_unref", "key"), &PropCache::material_cache_custom_key_unref);
ClassDB::bind_method(D_METHOD("material_cache_custom_key_get", "key"), &PropCache2D::material_cache_custom_key_get);
ClassDB::bind_method(D_METHOD("material_cache_custom_key_unref", "key"), &PropCache2D::material_cache_custom_key_unref);
ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &PropCache::load_resource, "");
ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &PropCache2D::load_resource, "");
}

View File

@ -47,14 +47,14 @@ SOFTWARE.
#include "../props/prop_data_2d.h"
class PropMaterialCache;
class TiledWallData;
class PropMaterialCache2D;
class TiledWallData2D;
class PropCache : public Object {
GDCLASS(PropCache, Object);
class PropCache2D : public Object {
GDCLASS(PropCache2D, Object);
public:
static PropCache *get_singleton();
static PropCache2D *get_singleton();
StringName get_default_prop_material_cache_class();
void set_default_prop_material_cache_class(const StringName &cls_name);
@ -91,32 +91,32 @@ public:
Vector<Variant> materials_get();
void materials_set(const Vector<Variant> &materials);
Ref<PropMaterialCache> material_cache_get(const Ref<PropData> &prop);
void material_cache_unref(const Ref<PropData> &prop);
Ref<PropMaterialCache2D> material_cache_get(const Ref<PropData2D> &prop);
void material_cache_unref(const Ref<PropData2D> &prop);
Ref<PropMaterialCache> tiled_wall_material_cache_get(const Ref<TiledWallData> &twd);
void tiled_wall_material_cache_unref(const Ref<TiledWallData> &twd);
Ref<PropMaterialCache2D> tiled_wall_material_cache_get(const Ref<TiledWallData2D> &twd);
void tiled_wall_material_cache_unref(const Ref<TiledWallData2D> &twd);
Ref<PropMaterialCache> material_cache_custom_key_get(const uint64_t key);
Ref<PropMaterialCache2D> material_cache_custom_key_get(const uint64_t key);
void material_cache_custom_key_unref(const uint64_t key);
Ref<Resource> load_resource(const String &path, const String &type_hint = "");
private:
static PropCache *_instance;
static PropCache2D *_instance;
public:
PropCache();
~PropCache();
PropCache2D();
~PropCache2D();
protected:
static void _bind_methods();
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;
Map<uint64_t, Ref<PropMaterialCache2D>> _material_cache;
Map<uint64_t, Ref<PropMaterialCache2D>> _tiled_wall_material_cache;
Map<uint64_t, Ref<PropMaterialCache2D>> _custom_keyed_material_cache;
Mutex _material_cache_mutex;
Mutex _tiled_wall_material_cache_mutex;

View File

@ -46,19 +46,19 @@ SOFTWARE.
#include "core/engine.h"
#endif
PropUtils *PropUtils::_instance;
Vector<Ref<PropDataEntry> > PropUtils::_processors;
PropUtils2D *PropUtils2D::_instance;
Vector<Ref<PropDataEntry2D> > PropUtils2D::_processors;
PropUtils *PropUtils::get_singleton() {
PropUtils2D *PropUtils2D::get_singleton() {
return _instance;
}
Ref<PropData> PropUtils::convert_tree(Node *root) {
Ref<PropData2D> PropUtils2D::convert_tree(Node *root) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref<PropData>());
ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref<PropData2D>());
#endif
Ref<PropData> data;
Ref<PropData2D> data;
data.instance();
Transform t;
@ -67,13 +67,13 @@ Ref<PropData> PropUtils::convert_tree(Node *root) {
return data;
}
void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transform &transform) {
void PropUtils2D::_convert_tree(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND(!ObjectDB::instance_validate(node));
#endif
for (int i = 0; i < PropUtils::_processors.size(); ++i) {
Ref<PropDataEntry> proc = PropUtils::_processors.get(i);
for (int i = 0; i < PropUtils2D::_processors.size(); ++i) {
Ref<PropDataEntry2D> proc = PropUtils2D::_processors.get(i);
ERR_CONTINUE(!proc.is_valid());
@ -138,7 +138,7 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
}
#if VERSION_MINOR >= 4
bool PropUtils::generate_room_points_node(Node *node) {
bool PropUtils2D::generate_room_points_node(Node *node) {
ERR_FAIL_COND_V(!ObjectDB::instance_validate(node), false);
Room *r = Object::cast_to<Room>(node);
@ -158,7 +158,7 @@ bool PropUtils::generate_room_points_node(Node *node) {
return false;
}
void PropUtils::generate_room_points(Room *room) {
void PropUtils2D::generate_room_points(Room *room) {
ERR_FAIL_COND(!ObjectDB::instance_validate(room));
Vector<PoolVector<Vector3> > mesh_arrays;
@ -281,7 +281,7 @@ void PropUtils::generate_room_points(Room *room) {
}
//based on Room::SimplifyInfo::add_plane_if_unique
bool PropUtils::is_plane_unique(const PoolVector<Plane> &planes, const Plane &p) {
bool PropUtils2D::is_plane_unique(const PoolVector<Plane> &planes, const Plane &p) {
for (int n = 0; n < planes.size(); n++) {
const Plane &o = planes[n];
@ -306,7 +306,7 @@ bool PropUtils::is_plane_unique(const PoolVector<Plane> &planes, const Plane &p)
return true;
}
void PropUtils::get_mesh_arrays(Node *node, Vector<PoolVector<Vector3> > *arrs) {
void PropUtils2D::get_mesh_arrays(Node *node, Vector<PoolVector<Vector3> > *arrs) {
ERR_FAIL_COND(!ObjectDB::instance_validate(node));
for (int i = 0; i < node->get_child_count(); ++i) {
@ -462,67 +462,67 @@ void PropUtils::get_mesh_arrays(Node *node, Vector<PoolVector<Vector3> > *arrs)
#endif
int PropUtils::add_processor(const Ref<PropDataEntry> &processor) {
int PropUtils2D::add_processor(const Ref<PropDataEntry2D> &processor) {
ERR_FAIL_COND_V(!processor.is_valid(), 0);
PropUtils::_processors.push_back(processor);
PropUtils2D::_processors.push_back(processor);
return PropUtils::_processors.size() - 1;
return PropUtils2D::_processors.size() - 1;
}
Ref<PropDataEntry> PropUtils::get_processor(const int index) {
ERR_FAIL_INDEX_V(index, PropUtils::_processors.size(), Ref<PropDataEntry>());
Ref<PropDataEntry2D> PropUtils2D::get_processor(const int index) {
ERR_FAIL_INDEX_V(index, PropUtils2D::_processors.size(), Ref<PropDataEntry2D>());
return PropUtils::_processors[index];
return PropUtils2D::_processors[index];
}
void PropUtils::swap_processors(const int index1, const int index2) {
ERR_FAIL_INDEX(index1, PropUtils::_processors.size());
ERR_FAIL_INDEX(index2, PropUtils::_processors.size());
void PropUtils2D::swap_processors(const int index1, const int index2) {
ERR_FAIL_INDEX(index1, PropUtils2D::_processors.size());
ERR_FAIL_INDEX(index2, PropUtils2D::_processors.size());
Ref<PropDataEntry> a = PropUtils::_processors.get(index1);
PropUtils::_processors.set(index1, PropUtils::_processors.get(index2));
PropUtils::_processors.set(index2, a);
Ref<PropDataEntry2D> a = PropUtils2D::_processors.get(index1);
PropUtils2D::_processors.set(index1, PropUtils2D::_processors.get(index2));
PropUtils2D::_processors.set(index2, a);
}
void PropUtils::remove_processor(const int index) {
ERR_FAIL_INDEX(index, PropUtils::_processors.size());
void PropUtils2D::remove_processor(const int index) {
ERR_FAIL_INDEX(index, PropUtils2D::_processors.size());
PropUtils::_processors.remove(index);
PropUtils2D::_processors.remove(index);
}
int PropUtils::get_processor_count() {
return PropUtils::_processors.size();
int PropUtils2D::get_processor_count() {
return PropUtils2D::_processors.size();
}
PropUtils::PropUtils() {
PropUtils2D::PropUtils2D() {
_instance = this;
}
PropUtils::~PropUtils() {
PropUtils2D::~PropUtils2D() {
_instance = NULL;
PropUtils::_processors.clear();
PropUtils2D::_processors.clear();
}
void PropUtils::_bind_methods() {
ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils::convert_tree);
void PropUtils2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils2D::convert_tree);
ClassDB::bind_method(D_METHOD("add_processor", "processor"), &PropUtils::_add_processor_bind);
ClassDB::bind_method(D_METHOD("get_processor", "index"), &PropUtils::_get_processor_bind);
ClassDB::bind_method(D_METHOD("swap_processors", "index1", "index2"), &PropUtils::_swap_processors_bind);
ClassDB::bind_method(D_METHOD("remove_processor", "index"), &PropUtils::_remove_processor_bind);
ClassDB::bind_method(D_METHOD("get_processor_count"), &PropUtils::_get_processor_count_bind);
ClassDB::bind_method(D_METHOD("add_processor", "processor"), &PropUtils2D::_add_processor_bind);
ClassDB::bind_method(D_METHOD("get_processor", "index"), &PropUtils2D::_get_processor_bind);
ClassDB::bind_method(D_METHOD("swap_processors", "index1", "index2"), &PropUtils2D::_swap_processors_bind);
ClassDB::bind_method(D_METHOD("remove_processor", "index"), &PropUtils2D::_remove_processor_bind);
ClassDB::bind_method(D_METHOD("get_processor_count"), &PropUtils2D::_get_processor_count_bind);
}
int PropUtils::_add_processor_bind(const Ref<PropDataEntry> &processor) {
return PropUtils::add_processor(processor);
int PropUtils2D::_add_processor_bind(const Ref<PropDataEntry2D> &processor) {
return PropUtils2D::add_processor(processor);
}
Ref<PropDataEntry> PropUtils::_get_processor_bind(const int index) {
return PropUtils::get_processor(index);
Ref<PropDataEntry2D> PropUtils2D::_get_processor_bind(const int index) {
return PropUtils2D::get_processor(index);
}
void PropUtils::_swap_processors_bind(const int index1, const int index2) {
PropUtils::swap_processors(index1, index2);
void PropUtils2D::_swap_processors_bind(const int index1, const int index2) {
PropUtils2D::swap_processors(index1, index2);
}
void PropUtils::_remove_processor_bind(const int index) {
PropUtils::remove_processor(index);
void PropUtils2D::_remove_processor_bind(const int index) {
PropUtils2D::remove_processor(index);
}
int PropUtils::_get_processor_count_bind() {
return PropUtils::get_processor_count();
int PropUtils2D::_get_processor_count_bind() {
return PropUtils2D::get_processor_count();
}

View File

@ -39,21 +39,21 @@ SOFTWARE.
#include "scene/main/node.h"
class PropData;
class PropDataEntry;
class PropData2D;
class PropDataEntry2D;
#if VERSION_MINOR >= 4
class Room;
#endif
class PropUtils : public Object {
GDCLASS(PropUtils, Object);
class PropUtils2D : public Object {
GDCLASS(PropUtils2D, Object);
public:
static PropUtils *get_singleton();
static PropUtils2D *get_singleton();
Ref<PropData> convert_tree(Node *root);
void _convert_tree(Ref<PropData> prop_data, Node *node, const Transform &transform);
Ref<PropData2D> convert_tree(Node *root);
void _convert_tree(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
#if VERSION_MINOR >= 4
bool generate_room_points_node(Node *node);
@ -62,27 +62,27 @@ public:
bool is_plane_unique(const PoolVector<Plane> &planes, const Plane &p);
#endif
static int add_processor(const Ref<PropDataEntry> &processor);
static Ref<PropDataEntry> get_processor(const int index);
static int add_processor(const Ref<PropDataEntry2D> &processor);
static Ref<PropDataEntry2D> get_processor(const int index);
static void swap_processors(const int index1, const int index2);
static void remove_processor(const int index);
static int get_processor_count();
PropUtils();
~PropUtils();
PropUtils2D();
~PropUtils2D();
protected:
static void _bind_methods();
private:
int _add_processor_bind(const Ref<PropDataEntry> &processor);
Ref<PropDataEntry> _get_processor_bind(const int index);
int _add_processor_bind(const Ref<PropDataEntry2D> &processor);
Ref<PropDataEntry2D> _get_processor_bind(const int index);
void _swap_processors_bind(const int index1, const int index2);
void _remove_processor_bind(const int index);
int _get_processor_count_bind();
static Vector<Ref<PropDataEntry>> _processors;
static PropUtils *_instance;
static Vector<Ref<PropDataEntry2D>> _processors;
static PropUtils2D *_instance;
};
#endif

View File

@ -25,30 +25,30 @@
#include "core/core_string_names.h"
#include "tiled_wall_data_2d.h"
int TiledWall::get_width() const {
int TiledWall2D::get_width() const {
return _width;
}
void TiledWall::set_width(const int value) {
void TiledWall2D::set_width(const int value) {
_width = value;
clear_mesh();
generate_mesh();
}
int TiledWall::get_heigth() const {
int TiledWall2D::get_heigth() const {
return _height;
}
void TiledWall::set_heigth(const int value) {
void TiledWall2D::set_heigth(const int value) {
_height = value;
clear_mesh();
generate_mesh();
}
Ref<TiledWallData> TiledWall::get_data() {
Ref<TiledWallData2D> TiledWall2D::get_data() {
return _data;
}
void TiledWall::set_data(const Ref<TiledWallData> &data) {
void TiledWall2D::set_data(const Ref<TiledWallData2D> &data) {
if (_data.is_valid()) {
_data->disconnect(CoreStringNames::get_singleton()->changed, this, "refresh");
}
@ -62,10 +62,10 @@ void TiledWall::set_data(const Ref<TiledWallData> &data) {
call_deferred("refresh");
}
bool TiledWall::get_collision() const {
bool TiledWall2D::get_collision() const {
return _collision;
}
void TiledWall::set_collision(const int value) {
void TiledWall2D::set_collision(const int value) {
_collision = value;
/*
@ -80,11 +80,11 @@ void TiledWall::set_collision(const int value) {
}*/
}
uint32_t TiledWall::get_collision_layer() const {
uint32_t TiledWall2D::get_collision_layer() const {
return _collision_layer;
}
void TiledWall::set_collision_layer(uint32_t p_layer) {
void TiledWall2D::set_collision_layer(uint32_t p_layer) {
_collision_layer = p_layer;
if (_physics_body_rid != RID()) {
@ -92,11 +92,11 @@ void TiledWall::set_collision_layer(uint32_t p_layer) {
}
}
uint32_t TiledWall::get_collision_mask() const {
uint32_t TiledWall2D::get_collision_mask() const {
return _collision_mask;
}
void TiledWall::set_collision_mask(uint32_t p_mask) {
void TiledWall2D::set_collision_mask(uint32_t p_mask) {
_collision_mask = p_mask;
if (_physics_body_rid != RID()) {
@ -104,11 +104,11 @@ void TiledWall::set_collision_mask(uint32_t p_mask) {
}
}
AABB TiledWall::get_aabb() const {
AABB TiledWall2D::get_aabb() const {
return AABB();
}
PoolVector<Face3> TiledWall::get_faces(uint32_t p_usage_flags) const {
PoolVector<Face3> TiledWall2D::get_faces(uint32_t p_usage_flags) const {
PoolVector<Face3> faces;
if (_mesh_array.size() != Mesh::ARRAY_MAX) {
@ -138,7 +138,7 @@ PoolVector<Face3> TiledWall::get_faces(uint32_t p_usage_flags) const {
return faces;
}
void TiledWall::refresh() {
void TiledWall2D::refresh() {
if (!is_inside_tree()) {
return;
}
@ -163,14 +163,14 @@ void TiledWall::refresh() {
VS::get_singleton()->instance_set_base(get_instance(), _mesh_rid);
}
Ref<PropMaterialCache> old_cache;
Ref<PropMaterialCache2D> old_cache;
old_cache = _cache;
_cache = PropCache::get_singleton()->tiled_wall_material_cache_get(_data);
_cache = PropCache2D::get_singleton()->tiled_wall_material_cache_get(_data);
if (old_cache.is_valid() && old_cache != _cache) {
PropCache::get_singleton()->tiled_wall_material_cache_unref(old_cache);
PropCache2D::get_singleton()->tiled_wall_material_cache_unref(old_cache);
}
if (!_cache->get_initialized()) {
@ -192,7 +192,7 @@ void TiledWall::refresh() {
generate_mesh();
}
void TiledWall::generate_mesh() {
void TiledWall2D::generate_mesh() {
if (!_data.is_valid()) {
return;
}
@ -234,7 +234,7 @@ void TiledWall::generate_mesh() {
_aabb.size = Vector3(_width, _height, 0);
}
void TiledWall::clear_mesh() {
void TiledWall2D::clear_mesh() {
_mesher->reset();
_aabb = AABB();
_mesh_array.clear();
@ -249,7 +249,7 @@ void TiledWall::clear_mesh() {
}
}
void TiledWall::free_mesh() {
void TiledWall2D::free_mesh() {
if (_mesh_rid != RID()) {
VS::get_singleton()->instance_set_base(get_instance(), RID());
VS::get_singleton()->free(_mesh_rid);
@ -257,7 +257,7 @@ void TiledWall::free_mesh() {
}
}
void TiledWall::create_colliders() {
void TiledWall2D::create_colliders() {
if (!is_inside_tree()) {
return;
}
@ -272,7 +272,7 @@ void TiledWall::create_colliders() {
PhysicsServer::get_singleton()->body_add_shape(_physics_body_rid, _physics_shape_rid);
}
void TiledWall::free_colliders() {
void TiledWall2D::free_colliders() {
if (_physics_shape_rid != RID()) {
PhysicsServer::get_singleton()->free(_physics_shape_rid);
@ -280,7 +280,7 @@ void TiledWall::free_colliders() {
}
}
TiledWall::TiledWall() {
TiledWall2D::TiledWall2D() {
_width = 1;
_height = 1;
_collision = true;
@ -296,7 +296,7 @@ TiledWall::TiledWall() {
_mesher.instance();
}
TiledWall::~TiledWall() {
TiledWall2D::~TiledWall2D() {
_data.unref();
_cache.unref();
_mesher.unref();
@ -309,7 +309,7 @@ TiledWall::~TiledWall() {
free_colliders();
}
void TiledWall::_notification(int p_what) {
void TiledWall2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
Transform t = get_global_transform();
@ -341,38 +341,38 @@ void TiledWall::_notification(int p_what) {
}
}
void TiledWall::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_width"), &TiledWall::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &TiledWall::set_width);
void TiledWall2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_width"), &TiledWall2D::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &TiledWall2D::set_width);
ADD_PROPERTY(PropertyInfo(Variant::INT, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_heigth"), &TiledWall::get_heigth);
ClassDB::bind_method(D_METHOD("set_heigth", "value"), &TiledWall::set_heigth);
ClassDB::bind_method(D_METHOD("get_heigth"), &TiledWall2D::get_heigth);
ClassDB::bind_method(D_METHOD("set_heigth", "value"), &TiledWall2D::set_heigth);
ADD_PROPERTY(PropertyInfo(Variant::INT, "heigth"), "set_heigth", "get_heigth");
ClassDB::bind_method(D_METHOD("get_data"), &TiledWall::get_data);
ClassDB::bind_method(D_METHOD("set_data", "value"), &TiledWall::set_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "TiledWallData"), "set_data", "get_data");
ClassDB::bind_method(D_METHOD("get_data"), &TiledWall2D::get_data);
ClassDB::bind_method(D_METHOD("set_data", "value"), &TiledWall2D::set_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "TiledWallData2D"), "set_data", "get_data");
ClassDB::bind_method(D_METHOD("get_collision"), &TiledWall::get_collision);
ClassDB::bind_method(D_METHOD("set_collision", "value"), &TiledWall::set_collision);
ClassDB::bind_method(D_METHOD("get_collision"), &TiledWall2D::get_collision);
ClassDB::bind_method(D_METHOD("set_collision", "value"), &TiledWall2D::set_collision);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision"), "set_collision", "get_collision");
ClassDB::bind_method(D_METHOD("get_collision_layer"), &TiledWall::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_layer", "value"), &TiledWall::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &TiledWall2D::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_layer", "value"), &TiledWall2D::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &TiledWall::get_collision_mask);
ClassDB::bind_method(D_METHOD("set_collision_mask", "value"), &TiledWall::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &TiledWall2D::get_collision_mask);
ClassDB::bind_method(D_METHOD("set_collision_mask", "value"), &TiledWall2D::set_collision_mask);
ADD_GROUP("Collision", "collision_");
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");
ClassDB::bind_method(D_METHOD("refresh"), &TiledWall::refresh);
ClassDB::bind_method(D_METHOD("generate_mesh"), &TiledWall::generate_mesh);
ClassDB::bind_method(D_METHOD("clear_mesh"), &TiledWall::clear_mesh);
ClassDB::bind_method(D_METHOD("free_mesh"), &TiledWall::free_mesh);
ClassDB::bind_method(D_METHOD("refresh"), &TiledWall2D::refresh);
ClassDB::bind_method(D_METHOD("generate_mesh"), &TiledWall2D::generate_mesh);
ClassDB::bind_method(D_METHOD("clear_mesh"), &TiledWall2D::clear_mesh);
ClassDB::bind_method(D_METHOD("free_mesh"), &TiledWall2D::free_mesh);
ClassDB::bind_method(D_METHOD("create_colliders"), &TiledWall::create_colliders);
ClassDB::bind_method(D_METHOD("free_colliders"), &TiledWall::free_colliders);
ClassDB::bind_method(D_METHOD("create_colliders"), &TiledWall2D::create_colliders);
ClassDB::bind_method(D_METHOD("free_colliders"), &TiledWall2D::free_colliders);
}

View File

@ -38,12 +38,12 @@ SOFTWARE.
#include "core/math/vector3.h"
class TiledWallData;
class PropMaterialCache;
class PropMesher;
class TiledWallData2D;
class PropMaterialCache2D;
class PropMesher2D;
class TiledWall : public GeometryInstance {
GDCLASS(TiledWall, GeometryInstance);
class TiledWall2D : public GeometryInstance {
GDCLASS(TiledWall2D, GeometryInstance);
public:
int get_width() const;
@ -52,8 +52,8 @@ public:
int get_heigth() const;
void set_heigth(const int value);
Ref<TiledWallData> get_data();
void set_data(const Ref<TiledWallData> &data);
Ref<TiledWallData2D> get_data();
void set_data(const Ref<TiledWallData2D> &data);
bool get_collision() const;
void set_collision(const int value);
@ -75,8 +75,8 @@ public:
void create_colliders();
void free_colliders();
TiledWall();
~TiledWall();
TiledWall2D();
~TiledWall2D();
protected:
void _notification(int p_what);
@ -90,9 +90,9 @@ private:
uint32_t _collision_layer;
uint32_t _collision_mask;
Ref<TiledWallData> _data;
Ref<PropMaterialCache> _cache;
Ref<PropMesher> _mesher;
Ref<TiledWallData2D> _data;
Ref<PropMaterialCache2D> _cache;
Ref<PropMesher2D> _mesher;
AABB _aabb;
RID _mesh_rid;

View File

@ -59,33 +59,33 @@ SOFTWARE.
#include "../material_cache/prop_material_cache_2d.h"
const String TiledWallData::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both";
const String TiledWallData2D::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both";
TiledWallData::TiledWallTilingType TiledWallData::get_tiling_type() const {
TiledWallData2D::TiledWallTilingType TiledWallData2D::get_tiling_type() const {
return _tiling_type;
}
void TiledWallData::set_tiling_type(const TiledWallData::TiledWallTilingType value) {
void TiledWallData2D::set_tiling_type(const TiledWallData2D::TiledWallTilingType value) {
_tiling_type = value;
emit_changed();
}
Ref<Texture> TiledWallData::get_texture(const int index) const {
Ref<Texture> TiledWallData2D::get_texture(const int index) const {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture>());
return _textures.get(index);
}
void TiledWallData::set_texture(const int index, const Ref<Texture> &texture) {
void TiledWallData2D::set_texture(const int index, const Ref<Texture> &texture) {
ERR_FAIL_INDEX(index, _textures.size());
_textures.set(index, texture);
emit_changed();
}
void TiledWallData::add_texture(const Ref<Texture> &texture) {
void TiledWallData2D::add_texture(const Ref<Texture> &texture) {
_textures.push_back(texture);
}
void TiledWallData::remove_texture(const int index) {
void TiledWallData2D::remove_texture(const int index) {
ERR_FAIL_INDEX(index, _textures.size());
_textures.remove(index);
@ -93,11 +93,11 @@ void TiledWallData::remove_texture(const int index) {
emit_changed();
}
int TiledWallData::get_texture_count() const {
int TiledWallData2D::get_texture_count() const {
return _textures.size();
}
Vector<Variant> TiledWallData::get_textures() {
Vector<Variant> TiledWallData2D::get_textures() {
Vector<Variant> r;
for (int i = 0; i < _textures.size(); i++) {
#if VERSION_MAJOR < 4
@ -108,7 +108,7 @@ Vector<Variant> TiledWallData::get_textures() {
}
return r;
}
void TiledWallData::set_textures(const Vector<Variant> &textures) {
void TiledWallData2D::set_textures(const Vector<Variant> &textures) {
_textures.clear();
for (int i = 0; i < textures.size(); i++) {
Ref<Texture> tex = Ref<Texture>(textures[i]);
@ -118,22 +118,22 @@ void TiledWallData::set_textures(const Vector<Variant> &textures) {
}
//flavour_textures
Ref<Texture> TiledWallData::get_flavour_texture(const int index) const {
Ref<Texture> TiledWallData2D::get_flavour_texture(const int index) const {
ERR_FAIL_INDEX_V(index, _flavour_textures.size(), Ref<Texture>());
return _flavour_textures.get(index);
}
void TiledWallData::set_flavour_texture(const int index, const Ref<Texture> &texture) {
void TiledWallData2D::set_flavour_texture(const int index, const Ref<Texture> &texture) {
ERR_FAIL_INDEX(index, _flavour_textures.size());
_flavour_textures.set(index, texture);
emit_changed();
}
void TiledWallData::add_flavour_texture(const Ref<Texture> &texture) {
void TiledWallData2D::add_flavour_texture(const Ref<Texture> &texture) {
_flavour_textures.push_back(texture);
}
void TiledWallData::remove_flavour_texture(const int index) {
void TiledWallData2D::remove_flavour_texture(const int index) {
ERR_FAIL_INDEX(index, _flavour_textures.size());
_flavour_textures.remove(index);
@ -141,11 +141,11 @@ void TiledWallData::remove_flavour_texture(const int index) {
emit_changed();
}
int TiledWallData::get_flavour_texture_count() const {
int TiledWallData2D::get_flavour_texture_count() const {
return _flavour_textures.size();
}
Vector<Variant> TiledWallData::get_flavour_textures() {
Vector<Variant> TiledWallData2D::get_flavour_textures() {
Vector<Variant> r;
for (int i = 0; i < _flavour_textures.size(); i++) {
#if VERSION_MAJOR < 4
@ -156,7 +156,7 @@ Vector<Variant> TiledWallData::get_flavour_textures() {
}
return r;
}
void TiledWallData::set_flavour_textures(const Vector<Variant> &textures) {
void TiledWallData2D::set_flavour_textures(const Vector<Variant> &textures) {
_flavour_textures.clear();
for (int i = 0; i < textures.size(); i++) {
Ref<Texture> tex = Ref<Texture>(textures[i]);
@ -167,21 +167,21 @@ void TiledWallData::set_flavour_textures(const Vector<Variant> &textures) {
emit_changed();
}
float TiledWallData::get_flavour_chance() const {
float TiledWallData2D::get_flavour_chance() const {
return _flavour_chance;
}
void TiledWallData::set_flavour_chance(const float value) {
void TiledWallData2D::set_flavour_chance(const float value) {
_flavour_chance = value;
}
//materials
void TiledWallData::material_add(const Ref<Material> &value) {
void TiledWallData2D::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
void TiledWallData::material_set(const int index, const Ref<Material> &value) {
void TiledWallData2D::material_set(const int index, const Ref<Material> &value) {
ERR_FAIL_INDEX(index, _materials.size());
_materials.set(index, value);
@ -189,25 +189,25 @@ void TiledWallData::material_set(const int index, const Ref<Material> &value) {
emit_changed();
}
void TiledWallData::material_remove(const int index) {
void TiledWallData2D::material_remove(const int index) {
_materials.remove(index);
emit_changed();
}
int TiledWallData::material_get_num() const {
int TiledWallData2D::material_get_num() const {
return _materials.size();
}
void TiledWallData::materials_clear() {
void TiledWallData2D::materials_clear() {
_materials.clear();
}
Vector<Variant> TiledWallData::materials_get() {
Vector<Variant> TiledWallData2D::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void TiledWallData::materials_set(const Vector<Variant> &materials) {
void TiledWallData2D::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
@ -220,7 +220,7 @@ void TiledWallData::materials_set(const Vector<Variant> &materials) {
}
#if TEXTURE_PACKER_PRESENT
void TiledWallData::add_textures_into(Ref<TexturePacker> texture_packer) {
void TiledWallData2D::add_textures_into(Ref<TexturePacker> texture_packer) {
ERR_FAIL_COND(!texture_packer.is_valid());
for (int i = 0; i < _textures.size(); ++i) {
@ -241,12 +241,12 @@ void TiledWallData::add_textures_into(Ref<TexturePacker> texture_packer) {
}
#endif
void TiledWallData::setup_cache(Ref<PropMaterialCache> cache) {
void TiledWallData2D::setup_cache(Ref<PropMaterialCache2D> cache) {
//Note: the caller should lock and unlock the cache!
call("_setup_cache", cache);
}
void TiledWallData::_setup_cache(Ref<PropMaterialCache> cache) {
void TiledWallData2D::_setup_cache(Ref<PropMaterialCache2D> cache) {
if (cache->material_get_num() == 0) {
for (int i = 0; i < _materials.size(); ++i) {
const Ref<Material> &m = _materials[i];
@ -276,7 +276,7 @@ void TiledWallData::_setup_cache(Ref<PropMaterialCache> cache) {
}
}
void TiledWallData::copy_from(const Ref<TiledWallData> &tiled_wall_data) {
void TiledWallData2D::copy_from(const Ref<TiledWallData2D> &tiled_wall_data) {
ERR_FAIL_COND(!tiled_wall_data.is_valid());
_tiling_type = tiled_wall_data->_tiling_type;
@ -296,70 +296,70 @@ void TiledWallData::copy_from(const Ref<TiledWallData> &tiled_wall_data) {
emit_changed();
}
TiledWallData::TiledWallData() {
TiledWallData2D::TiledWallData2D() {
_tiling_type = TILED_WALL_TILING_TYPE_NONE;
_flavour_chance = 0.15;
}
TiledWallData::~TiledWallData() {
TiledWallData2D::~TiledWallData2D() {
_textures.clear();
_flavour_textures.clear();
_materials.clear();
}
void TiledWallData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tiling_type"), &TiledWallData::get_tiling_type);
ClassDB::bind_method(D_METHOD("set_tiling_type", "texture"), &TiledWallData::set_tiling_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "tiling_type", PROPERTY_HINT_ENUM, TiledWallData::BINDING_STRING_TILED_WALL_TILING_TYPE), "set_tiling_type", "get_tiling_type");
void TiledWallData2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_tiling_type"), &TiledWallData2D::get_tiling_type);
ClassDB::bind_method(D_METHOD("set_tiling_type", "texture"), &TiledWallData2D::set_tiling_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "tiling_type", PROPERTY_HINT_ENUM, TiledWallData2D::BINDING_STRING_TILED_WALL_TILING_TYPE), "set_tiling_type", "get_tiling_type");
//textures
ClassDB::bind_method(D_METHOD("get_texture", "index"), &TiledWallData::get_texture);
ClassDB::bind_method(D_METHOD("set_texture", "index", "texture"), &TiledWallData::set_texture);
ClassDB::bind_method(D_METHOD("add_texture", "texture"), &TiledWallData::add_texture);
ClassDB::bind_method(D_METHOD("remove_texture", "index"), &TiledWallData::remove_texture);
ClassDB::bind_method(D_METHOD("get_texture", "index"), &TiledWallData2D::get_texture);
ClassDB::bind_method(D_METHOD("set_texture", "index", "texture"), &TiledWallData2D::set_texture);
ClassDB::bind_method(D_METHOD("add_texture", "texture"), &TiledWallData2D::add_texture);
ClassDB::bind_method(D_METHOD("remove_texture", "index"), &TiledWallData2D::remove_texture);
ClassDB::bind_method(D_METHOD("get_texture_count"), &TiledWallData::get_texture_count);
ClassDB::bind_method(D_METHOD("get_texture_count"), &TiledWallData2D::get_texture_count);
ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData::get_textures);
ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData::set_textures);
ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData2D::get_textures);
ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData2D::set_textures);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "17/17:Texture", PROPERTY_USAGE_DEFAULT, "Texture"), "set_textures", "get_textures");
//flavour_textures
ClassDB::bind_method(D_METHOD("get_flavour_texture", "index"), &TiledWallData::get_flavour_texture);
ClassDB::bind_method(D_METHOD("set_flavour_texture", "index", "texture"), &TiledWallData::set_flavour_texture);
ClassDB::bind_method(D_METHOD("add_tflavour_exture", "texture"), &TiledWallData::add_flavour_texture);
ClassDB::bind_method(D_METHOD("remove_flavour_texture", "index"), &TiledWallData::remove_flavour_texture);
ClassDB::bind_method(D_METHOD("get_flavour_texture", "index"), &TiledWallData2D::get_flavour_texture);
ClassDB::bind_method(D_METHOD("set_flavour_texture", "index", "texture"), &TiledWallData2D::set_flavour_texture);
ClassDB::bind_method(D_METHOD("add_tflavour_exture", "texture"), &TiledWallData2D::add_flavour_texture);
ClassDB::bind_method(D_METHOD("remove_flavour_texture", "index"), &TiledWallData2D::remove_flavour_texture);
ClassDB::bind_method(D_METHOD("get_flavour_texture_count"), &TiledWallData::get_flavour_texture_count);
ClassDB::bind_method(D_METHOD("get_flavour_texture_count"), &TiledWallData2D::get_flavour_texture_count);
ClassDB::bind_method(D_METHOD("get_flavour_textures"), &TiledWallData::get_flavour_textures);
ClassDB::bind_method(D_METHOD("set_flavour_textures", "textures"), &TiledWallData::set_flavour_textures);
ClassDB::bind_method(D_METHOD("get_flavour_textures"), &TiledWallData2D::get_flavour_textures);
ClassDB::bind_method(D_METHOD("set_flavour_textures", "textures"), &TiledWallData2D::set_flavour_textures);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "flavour_textures", PROPERTY_HINT_NONE, "17/17:Texture", PROPERTY_USAGE_DEFAULT, "Texture"), "set_flavour_textures", "get_flavour_textures");
ClassDB::bind_method(D_METHOD("get_flavour_chance"), &TiledWallData::get_flavour_chance);
ClassDB::bind_method(D_METHOD("set_flavour_chance", "texture"), &TiledWallData::set_flavour_chance);
ClassDB::bind_method(D_METHOD("get_flavour_chance"), &TiledWallData2D::get_flavour_chance);
ClassDB::bind_method(D_METHOD("set_flavour_chance", "texture"), &TiledWallData2D::set_flavour_chance);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "flavour_chance"), "set_flavour_chance", "get_flavour_chance");
//materials
ClassDB::bind_method(D_METHOD("material_add", "value"), &TiledWallData::material_add);
ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &TiledWallData::material_set);
ClassDB::bind_method(D_METHOD("material_remove", "index"), &TiledWallData::material_remove);
ClassDB::bind_method(D_METHOD("material_get_num"), &TiledWallData::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &TiledWallData::materials_clear);
ClassDB::bind_method(D_METHOD("material_add", "value"), &TiledWallData2D::material_add);
ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &TiledWallData2D::material_set);
ClassDB::bind_method(D_METHOD("material_remove", "index"), &TiledWallData2D::material_remove);
ClassDB::bind_method(D_METHOD("material_get_num"), &TiledWallData2D::material_get_num);
ClassDB::bind_method(D_METHOD("materials_clear"), &TiledWallData2D::materials_clear);
ClassDB::bind_method(D_METHOD("materials_get"), &TiledWallData::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &TiledWallData::materials_set);
ClassDB::bind_method(D_METHOD("materials_get"), &TiledWallData2D::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &TiledWallData2D::materials_set);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
#if TEXTURE_PACKER_PRESENT
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWallData::add_textures_into);
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWallData2D::add_textures_into);
#endif
BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache")));
BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache2D")));
ClassDB::bind_method(D_METHOD("setup_cache", "cache"), &TiledWallData::setup_cache);
ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWallData::_setup_cache);
ClassDB::bind_method(D_METHOD("setup_cache", "cache"), &TiledWallData2D::setup_cache);
ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWallData2D::_setup_cache);
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData::copy_from);
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData2D::copy_from);
BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_NONE);
BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_HORIZONTAL);

View File

@ -47,11 +47,11 @@ SOFTWARE.
#include "../../texture_packer/texture_packer.h"
#endif
class PropMaterialCache;
class PropMesher;
class PropMaterialCache2D;
class PropMesher2D;
class TiledWallData : public Resource {
GDCLASS(TiledWallData, Resource);
class TiledWallData2D : public Resource {
GDCLASS(TiledWallData2D, Resource);
public:
enum TiledWallTilingType {
@ -106,15 +106,15 @@ public:
void add_textures_into(Ref<TexturePacker> texture_packer);
#endif
void setup_cache(Ref<PropMaterialCache> cache);
void _setup_cache(Ref<PropMaterialCache> cache);
void setup_cache(Ref<PropMaterialCache2D> cache);
void _setup_cache(Ref<PropMaterialCache2D> cache);
void copy_from(const Ref<TiledWallData> &tiled_wall_data);
void copy_from(const Ref<TiledWallData2D> &tiled_wall_data);
//Ref<Shape> get_collider_shape();
TiledWallData();
~TiledWallData();
TiledWallData2D();
~TiledWallData2D();
protected:
static void _bind_methods();
@ -129,6 +129,6 @@ private:
Vector<Ref<Material>> _materials;
};
VARIANT_ENUM_CAST(TiledWallData::TiledWallTilingType);
VARIANT_ENUM_CAST(TiledWallData2D::TiledWallTilingType);
#endif