Started over. Added everythong from the props module again.

This commit is contained in:
Relintai 2022-02-21 17:09:00 +01:00
parent 6f802fcf68
commit b95db8d786
85 changed files with 3466 additions and 1885 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

56
SCsub
View File

@ -6,8 +6,8 @@ module_env = env.Clone()
import version
#if os.path.isdir('../mesh_data_resource'):
#module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT'])
if os.path.isdir('../mesh_data_resource'):
module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT'])
has_texture_packer = False
@ -29,48 +29,48 @@ sources = [
"register_types.cpp",
"lights/prop_light_2d.cpp",
"lights/prop_light.cpp",
"tiled_wall/tiled_wall_2d.cpp",
"tiled_wall/tiled_wall_data_2d.cpp",
"tiled_wall/tiled_wall.cpp",
"tiled_wall/tiled_wall_data.cpp",
"props/prop_data_2d.cpp",
"props/prop_data_entry_2d.cpp",
"props/prop_data_scene_2d.cpp",
"props/prop_data_light_2d.cpp",
"props/prop_data_prop_2d.cpp",
"props/prop_data_tiled_wall_2d.cpp",
"props/prop_data.cpp",
"props/prop_data_entry.cpp",
"props/prop_data_scene.cpp",
"props/prop_data_light.cpp",
"props/prop_data_prop.cpp",
"props/prop_data_tiled_wall.cpp",
"clutter/ground_clutter_2d.cpp",
"clutter/ground_clutter_foliage_2d.cpp",
"clutter/ground_clutter.cpp",
"clutter/ground_clutter_foliage.cpp",
"prop_instance_2d.cpp",
"prop_instance_merger_2d.cpp",
"prop_ess_entity_2d.cpp",
"prop_instance_job_2d.cpp",
"prop_instance_prop_job_2d.cpp",
"prop_instance.cpp",
"prop_instance_merger.cpp",
"prop_ess_entity.cpp",
"prop_instance_job.cpp",
"prop_instance_prop_job.cpp",
"prop_scene_instance_2d.cpp",
"prop_scene_instance.cpp",
"singleton/prop_utils_2d.cpp",
"singleton/prop_cache_2d.cpp",
"singleton/prop_utils.cpp",
"singleton/prop_cache.cpp",
"editor/prop_editor_plugin_2d.cpp",
"editor/prop_editor_plugin.cpp",
"prop_mesher_2d.cpp",
"prop_mesher.cpp",
"jobs/prop_texture_job_2d.cpp",
"jobs/prop_texture_job.cpp",
"jobs/prop_mesher_job_step_2d.cpp",
"jobs/prop_mesher_job_step.cpp",
"material_cache/prop_material_cache_2d.cpp"
"material_cache/prop_material_cache.cpp"
]
if version.minor >= 4:
sources.append("props/prop_data_portal_2d.cpp")
sources.append("props/prop_data_portal.cpp")
if has_texture_packer:
sources.append("material_cache/prop_material_cache_pcm_2d.cpp")
sources.append("material_cache/prop_material_cache_pcm.cpp")
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
# Shared lib compilation

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,50 +20,50 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "ground_clutter_2d.h"
#include "ground_clutter.h"
#ifdef VOXELMAN_PRESENT
#include "../../voxelman/world/voxel_chunk.h"
bool GroundClutter2D::should_spawn(Ref<VoxelChunk> chunk, int x, int y, int z) {
bool GroundClutter::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 GroundClutter2D::add_meshes_to(Ref<VoxelMesher> mesher, Ref<VoxelChunk> chunk, int x, int y, int z) {
void GroundClutter::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 GroundClutter2D::add_textures_to(Ref<TexturePacker> packer) {
void GroundClutter::add_textures_to(Ref<TexturePacker> packer) {
if (has_method("_add_textures_to"))
call("_add_textures_to", packer);
}
#endif
GroundClutter2D::GroundClutter2D() {
GroundClutter::GroundClutter() {
}
GroundClutter2D::~GroundClutter2D() {
GroundClutter::~GroundClutter() {
}
void GroundClutter2D::_bind_methods() {
void GroundClutter::_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"), &GroundClutter2D::add_textures_to);
ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter::add_textures_to);
#endif
#ifdef VOXELMAN_PRESENT
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "should"), "_should_spawn", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
BIND_VMETHOD(MethodInfo("_add_meshes_to", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z")));
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);
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);
#endif
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef GROUND_CLUTTER_2D_H
#define GROUND_CLUTTER_2D_H
#ifndef GROUND_CLUTTER_H
#define GROUND_CLUTTER_H
#include "core/version.h"
@ -42,8 +42,8 @@ SOFTWARE.
class VoxelChunk;
class VoxelMesher;
class GroundClutter2D : public Resource {
GDCLASS(GroundClutter2D, Resource);
class GroundClutter : public Resource {
GDCLASS(GroundClutter, Resource);
public:
#ifdef VOXELMAN_PRESENT
@ -56,8 +56,8 @@ public:
void add_textures_to(Ref<TexturePacker> packer);
#endif
GroundClutter2D();
~GroundClutter2D();
GroundClutter();
~GroundClutter();
private:
static void _bind_methods();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,35 +20,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "ground_clutter_foliage_2d.h"
#include "ground_clutter_foliage.h"
int GroundClutterFoliage2D::get_texture_count() const {
int GroundClutterFoliage::get_texture_count() const {
return _textures.size();
}
Ref<Texture> GroundClutterFoliage2D::get_texture(const int index) {
Ref<Texture> GroundClutterFoliage::get_texture(const int index) {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture>());
return _textures.get(index);
}
void GroundClutterFoliage2D::remove_texture(const int index) {
void GroundClutterFoliage::remove_texture(const int index) {
ERR_FAIL_INDEX(index, _textures.size());
_textures.remove(index);
}
void GroundClutterFoliage2D::add_texture(Ref<Texture> texture) {
void GroundClutterFoliage::add_texture(Ref<Texture> texture) {
_textures.push_back(texture);
}
GroundClutterFoliage2D::GroundClutterFoliage2D() {
GroundClutterFoliage::GroundClutterFoliage() {
}
GroundClutterFoliage2D::~GroundClutterFoliage2D() {
GroundClutterFoliage::~GroundClutterFoliage() {
_textures.clear();
}
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);
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);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef GROUND_CLUTTER_FOLIAGE_2D_H
#define GROUND_CLUTTER_FOLIAGE_2D_H
#ifndef GROUND_CLUTTER_FOLIAGE_H
#define GROUND_CLUTTER_FOLIAGE_H
#include "core/version.h"
@ -31,12 +31,12 @@ SOFTWARE.
#include "core/vector.h"
#endif
#include "ground_clutter_2d.h"
#include "ground_clutter.h"
#include "scene/resources/texture.h"
class GroundClutterFoliage2D : public GroundClutter2D {
GDCLASS(GroundClutterFoliage2D, GroundClutter2D);
class GroundClutterFoliage : public GroundClutter {
GDCLASS(GroundClutterFoliage, GroundClutter);
public:
int get_texture_count() const;
@ -44,8 +44,8 @@ public:
void remove_texture(const int index);
void add_texture(Ref<Texture> texture);
GroundClutterFoliage2D();
~GroundClutterFoliage2D();
GroundClutterFoliage();
~GroundClutterFoliage();
private:
static void _bind_methods();

View File

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

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GroundClutter" inherits="Resource" version="3.2">
<class name="GroundClutter" inherits="Resource" version="3.5">
<brief_description>
</brief_description>
<description>
@ -7,79 +7,15 @@
<tutorials>
</tutorials>
<methods>
<method name="_add_meshes_to" qualifiers="virtual">
<return type="void">
</return>
<argument index="0" name="mesher" type="VoxelMesher">
</argument>
<argument index="1" name="chunk" type="VoxelChunk">
</argument>
<argument index="2" name="x" type="int">
</argument>
<argument index="3" name="y" type="int">
</argument>
<argument index="4" name="z" type="int">
</argument>
<description>
</description>
</method>
<method name="_add_textures_to" qualifiers="virtual">
<return type="void">
</return>
<argument index="0" name="packer" type="TexturePacker">
</argument>
<description>
</description>
</method>
<method name="_should_spawn" qualifiers="virtual">
<return type="bool">
</return>
<argument index="0" name="chunk" type="VoxelChunk">
</argument>
<argument index="1" name="x" type="int">
</argument>
<argument index="2" name="y" type="int">
</argument>
<argument index="3" name="z" type="int">
</argument>
<description>
</description>
</method>
<method name="add_meshes_to">
<return type="void">
</return>
<argument index="0" name="mesher" type="VoxelMesher">
</argument>
<argument index="1" name="chunk" type="VoxelChunk">
</argument>
<argument index="2" name="x" type="int">
</argument>
<argument index="3" name="y" type="int">
</argument>
<argument index="4" name="z" type="int">
</argument>
<return type="void" />
<argument index="0" name="packer" type="TexturePacker" />
<description>
</description>
</method>
<method name="add_textures_to">
<return type="void">
</return>
<argument index="0" name="packer" type="TexturePacker">
</argument>
<description>
</description>
</method>
<method name="should_spawn">
<return type="bool">
</return>
<argument index="0" name="chunk" type="VoxelChunk">
</argument>
<argument index="1" name="x" type="int">
</argument>
<argument index="2" name="y" type="int">
</argument>
<argument index="3" name="z" type="int">
</argument>
<return type="void" />
<argument index="0" name="packer" type="TexturePacker" />
<description>
</description>
</method>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GroundClutterFoliage" inherits="GroundClutter" version="3.2">
<class name="GroundClutterFoliage" inherits="GroundClutter" version="3.5">
<brief_description>
</brief_description>
<description>
@ -8,32 +8,25 @@
</tutorials>
<methods>
<method name="add_texture">
<return type="void">
</return>
<argument index="0" name="texture" type="Texture">
</argument>
<return type="void" />
<argument index="0" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="get_texture">
<return type="Texture">
</return>
<argument index="0" name="index" type="int">
</argument>
<return type="Texture" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="get_texture_count" qualifiers="const">
<return type="int">
</return>
<return type="int" />
<description>
</description>
</method>
<method name="remove_texture">
<return type="void">
</return>
<argument index="0" name="index" type="int">
</argument>
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>

119
doc_classes/PropCache.xml Normal file
View File

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropCache" inherits="Object" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="ensure_materials_loaded">
<return type="void" />
<description>
</description>
</method>
<method name="load_resource">
<return type="Resource" />
<argument index="0" name="path" type="String" />
<argument index="1" name="type_hint" type="String" default="&quot;&quot;" />
<description>
</description>
</method>
<method name="material_add">
<return type="void" />
<argument index="0" name="value" type="Material" />
<description>
</description>
</method>
<method name="material_cache_custom_key_get">
<return type="PropMaterialCache" />
<argument index="0" name="key" type="int" />
<description>
</description>
</method>
<method name="material_cache_custom_key_unref">
<return type="void" />
<argument index="0" name="key" type="int" />
<description>
</description>
</method>
<method name="material_cache_get">
<return type="PropMaterialCache" />
<argument index="0" name="prop" type="PropData" />
<description>
</description>
</method>
<method name="material_cache_unref">
<return type="void" />
<argument index="0" name="prop" type="PropData" />
<description>
</description>
</method>
<method name="material_get">
<return type="Material" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="material_get_num" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="material_remove">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="material_set">
<return type="void" />
<argument index="0" name="index" type="int" />
<argument index="1" name="value" type="Material" />
<description>
</description>
</method>
<method name="materials_clear">
<return type="void" />
<description>
</description>
</method>
<method name="materials_load">
<return type="void" />
<description>
</description>
</method>
<method name="tiled_wall_material_cache_get">
<return type="PropMaterialCache" />
<argument index="0" name="twd" type="TiledWallData" />
<description>
</description>
</method>
<method name="tiled_wall_material_cache_unref">
<return type="void" />
<argument index="0" name="twd" type="TiledWallData" />
<description>
</description>
</method>
</methods>
<members>
<member name="background_color" type="Color" setter="set_background_color" getter="get_background_color" default="Color( 0, 0, 0, 1 )">
</member>
<member name="default_prop_material_cache_class" type="String" setter="set_default_prop_material_cache_class" getter="get_default_prop_material_cache_class" default="&quot;PropMaterialCachePCM&quot;">
</member>
<member name="keep_original_atlases" type="bool" setter="set_keep_original_atlases" getter="get_keep_original_atlases" default="false">
</member>
<member name="margin" type="int" setter="set_margin" getter="get_margin" default="0">
</member>
<member name="material_paths" type="PoolStringArray" setter="material_paths_set" getter="material_paths_get" default="PoolStringArray( )">
</member>
<member name="materials" type="Array" setter="materials_set" getter="materials_get" default="[ ]">
</member>
<member name="max_atlas_size" type="int" setter="set_max_atlas_size" getter="get_max_atlas_size" default="1024">
</member>
<member name="texture_flags" type="int" setter="set_texture_flags" getter="get_texture_flags" default="5">
</member>
</members>
<constants>
</constants>
</class>

67
doc_classes/PropData.xml Normal file
View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropData" inherits="Resource" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_prop">
<return type="void" />
<argument index="0" name="prop" type="PropDataEntry" />
<description>
</description>
</method>
<method name="add_textures_into">
<return type="void" />
<argument index="0" name="texture_packer" type="TexturePacker" />
<description>
</description>
</method>
<method name="copy_from">
<return type="void" />
<argument index="0" name="prop_data" type="PropData" />
<description>
</description>
</method>
<method name="get_prop" qualifiers="const">
<return type="PropDataEntry" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="get_prop_count" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="remove_prop">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="set_prop">
<return type="void" />
<argument index="0" name="index" type="int" />
<argument index="1" name="spell" type="PropDataEntry" />
<description>
</description>
</method>
</methods>
<members>
<member name="is_room" type="bool" setter="set_is_room" getter="get_is_room" default="false">
</member>
<member name="props" type="Array" setter="set_props" getter="get_props" default="[ ]">
</member>
<member name="room_bounds" type="PoolVector3Array" setter="set_room_bounds" getter="get_room_bounds" default="PoolVector3Array( )">
</member>
<member name="snap_axis" type="Vector3" setter="set_snap_axis" getter="get_snap_axis" default="Vector3( 0, -1, 0 )">
</member>
<member name="snap_to_mesh" type="bool" setter="set_snap_to_mesh" getter="get_snap_to_mesh" default="false">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropDataEntry" inherits="Resource" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="_add_textures_into" qualifiers="virtual">
<return type="void" />
<argument index="0" name="texture_packer" type="TexturePacker" />
<description>
</description>
</method>
<method name="_processor_evaluate_children" qualifiers="virtual">
<return type="bool" />
<description>
</description>
</method>
<method name="_processor_get_node_for" qualifiers="virtual">
<return type="Node" />
<argument index="0" name="transform" type="Transform" />
<description>
</description>
</method>
<method name="_processor_handles" qualifiers="virtual">
<return type="bool" />
<description>
</description>
</method>
<method name="_processor_process" qualifiers="virtual">
<return type="void" />
<argument index="0" name="prop_data" type="PropData" />
<argument index="1" name="node" type="Node" />
<argument index="2" name="transform" type="Transform" />
<description>
</description>
</method>
<method name="add_textures_into">
<return type="void" />
<argument index="0" name="texture_packer" type="TexturePacker" />
<description>
</description>
</method>
<method name="processor_evaluate_children">
<return type="bool" />
<description>
</description>
</method>
<method name="processor_get_node_for">
<return type="Node" />
<argument index="0" name="prop_data" type="Transform" />
<description>
</description>
</method>
<method name="processor_handles">
<return type="bool" />
<argument index="0" name="node" type="Node" />
<description>
</description>
</method>
<method name="processor_process">
<return type="void" />
<argument index="0" name="prop_data" type="PropData" />
<argument index="1" name="node" type="Node" />
<argument index="2" name="transform" type="Transform" />
<description>
</description>
</method>
</methods>
<members>
<member name="transform" type="Transform" setter="set_transform" getter="get_transform" default="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropDataLight" inherits="PropDataEntry" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="light_color" type="Color" setter="set_light_color" getter="get_light_color" default="Color( 0, 0, 0, 1 )">
</member>
<member name="light_size" type="int" setter="set_light_size" getter="get_light_size" default="0">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropDataPortal" inherits="PropDataEntry" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="is_active" type="bool" setter="set_is_active" getter="get_is_active" default="true">
</member>
<member name="is_two_way" type="bool" setter="set_is_two_way" getter="get_is_two_way" default="true">
</member>
<member name="points" type="PoolVector2Array" setter="set_points" getter="get_points" default="PoolVector2Array( )">
</member>
<member name="portal_margin" type="float" setter="set_portal_margin" getter="get_portal_margin" default="1.0">
</member>
<member name="use_default_margin" type="bool" setter="set_use_default_margin" getter="get_use_default_margin" default="true">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropDataProp" inherits="PropDataEntry" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="prop" type="PropData" setter="set_prop" getter="get_prop">
</member>
<member name="snap_axis" type="Vector3" setter="set_snap_axis" getter="get_snap_axis" default="Vector3( 0, 1, 0 )">
</member>
<member name="snap_to_mesh" type="bool" setter="set_snap_to_mesh" getter="get_snap_to_mesh" default="false">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropDataScene" inherits="PropDataEntry" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="scene" type="PackedScene" setter="set_scene" getter="get_scene">
</member>
<member name="snap_axis" type="Vector3" setter="set_snap_axis" getter="get_snap_axis" default="Vector3( 0, 1, 0 )">
</member>
<member name="snap_to_mesh" type="bool" setter="set_snap_to_mesh" getter="get_snap_to_mesh" default="true">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropDataTiledWall" inherits="PropDataEntry" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="collision" type="bool" setter="set_collision" getter="get_collision" default="true">
</member>
<member name="data" type="TiledWallData" setter="set_data" getter="get_data">
</member>
<member name="heigth" type="int" setter="set_heigth" getter="get_heigth" default="1">
</member>
<member name="width" type="int" setter="set_width" getter="get_width" default="1">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropESSEntity" inherits="Spatial" version="3.2">
<class name="PropESSEntity" inherits="Spatial" version="3.5">
<brief_description>
</brief_description>
<description>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropInstance" inherits="Spatial" version="3.2">
<class name="PropInstance" inherits="Spatial" version="3.5">
<brief_description>
</brief_description>
<description>
@ -7,11 +7,64 @@
<tutorials>
</tutorials>
<methods>
<method name="_build" qualifiers="virtual">
<return type="void" />
<description>
</description>
</method>
<method name="_build_finished" qualifiers="virtual">
<return type="void" />
<description>
</description>
</method>
<method name="_init_materials" qualifiers="virtual">
<return type="void" />
<description>
</description>
</method>
<method name="_prop_preprocess" qualifiers="virtual">
<return type="void" />
<argument index="0" name="tarnsform" type="Transform" />
<argument index="1" name="prop_data" type="PropData" />
<description>
</description>
</method>
<method name="build">
<return type="void" />
<description>
</description>
</method>
<method name="build_finished">
<return type="void" />
<description>
</description>
</method>
<method name="init_materials">
<return type="void" />
<description>
</description>
</method>
<method name="prop_preprocess">
<return type="void" />
<argument index="0" name="tarnsform" type="Transform" />
<argument index="1" name="prop" type="PropData" />
<description>
</description>
</method>
<method name="queue_build">
<return type="void" />
<description>
</description>
</method>
</methods>
<members>
<member name="snap_axis" type="Vector3" setter="set_snap_axis" getter="get_snap_axis" default="Vector3( 0, -1, 0 )">
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
</member>
<member name="snap_to_mesh" type="bool" setter="set_snap_to_mesh" getter="get_snap_to_mesh" default="false">
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
</member>
<member name="material" type="Material" setter="set_material" getter="get_material">
</member>
<member name="prop_data" type="PropData" setter="set_prop_data" getter="get_prop_data">
</member>
</members>
<constants>

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropInstanceJob" inherits="ThreadPoolJob" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="_execute_phase" qualifiers="virtual">
<return type="void" />
<description>
</description>
</method>
<method name="_physics_process" qualifiers="virtual">
<return type="void" />
<argument index="0" name="delta" type="float" />
<description>
</description>
</method>
<method name="_process" qualifiers="virtual">
<return type="void" />
<argument index="0" name="delta" type="float" />
<description>
</description>
</method>
<method name="_reset" qualifiers="virtual">
<return type="void" />
<description>
</description>
</method>
<method name="execute_phase">
<return type="void" />
<description>
</description>
</method>
<method name="finished">
<return type="void" />
<description>
</description>
</method>
<method name="get_build_done">
<return type="bool" />
<description>
</description>
</method>
<method name="get_phase">
<return type="int" />
<description>
</description>
</method>
<method name="next_phase">
<return type="void" />
<description>
</description>
</method>
<method name="prop_instance_exit_tree">
<return type="void" />
<description>
</description>
</method>
<method name="reset">
<return type="void" />
<description>
</description>
</method>
<method name="set_build_done">
<return type="void" />
<argument index="0" name="val" type="bool" />
<description>
</description>
</method>
<method name="set_phase">
<return type="void" />
<argument index="0" name="phase" type="int" />
<description>
</description>
</method>
<method name="set_prop">
<return type="void" />
<argument index="0" name="prop" type="PropData" />
<description>
</description>
</method>
<method name="set_prop_instance">
<return type="void" />
<argument index="0" name="instance" type="Node" />
<description>
</description>
</method>
</methods>
<members>
<member name="build_phase_type" type="int" setter="set_build_phase_type" getter="get_build_phase_type" enum="PropInstanceJob.ActiveBuildPhaseType" default="0">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,191 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropInstanceMerger" inherits="PropInstance" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="apply_lod_level">
<return type="void" />
<description>
</description>
</method>
<method name="check_auto_lod">
<return type="void" />
<description>
</description>
</method>
<method name="collider_add">
<return type="int" />
<argument index="0" name="local_transform" type="Transform" />
<argument index="1" name="shape" type="Shape" />
<argument index="2" name="shape_rid" type="RID" />
<argument index="3" name="body" type="RID" />
<argument index="4" name="arg4" type="bool" />
<description>
</description>
</method>
<method name="collider_body_get">
<return type="RID" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="collider_get_num" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="collider_local_transform_get">
<return type="Transform" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="collider_shape_get">
<return type="Shape" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="collider_shape_rid_get">
<return type="RID" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="colliders_clear">
<return type="void" />
<description>
</description>
</method>
<method name="debug_mesh_add_vertices_to">
<return type="void" />
<argument index="0" name="arr" type="PoolVector3Array" />
<description>
</description>
</method>
<method name="debug_mesh_allocate">
<return type="void" />
<description>
</description>
</method>
<method name="debug_mesh_array_clear">
<return type="void" />
<description>
</description>
</method>
<method name="debug_mesh_clear">
<return type="void" />
<description>
</description>
</method>
<method name="debug_mesh_free">
<return type="void" />
<description>
</description>
</method>
<method name="debug_mesh_has">
<return type="bool" />
<description>
</description>
</method>
<method name="debug_mesh_send">
<return type="void" />
<description>
</description>
</method>
<method name="draw_debug_mdr_colliders">
<return type="void" />
<description>
</description>
</method>
<method name="free_colliders">
<return type="void" />
<description>
</description>
</method>
<method name="free_meshes">
<return type="void" />
<description>
</description>
</method>
<method name="material_add">
<return type="void" />
<argument index="0" name="value" type="Material" />
<description>
</description>
</method>
<method name="material_get">
<return type="Material" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="material_get_num" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="materials_clear">
<return type="void" />
<description>
</description>
</method>
<method name="mesh_add">
<return type="void" />
<argument index="0" name="mesh_instance" type="RID" />
<argument index="1" name="mesh" type="RID" />
<description>
</description>
</method>
<method name="mesh_get">
<return type="RID" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="mesh_get_num" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="mesh_instance_get">
<return type="RID" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="meshes_clear">
<return type="void" />
<description>
</description>
</method>
<method name="meshes_create">
<return type="void" />
<argument index="0" name="num" type="int" />
<description>
</description>
</method>
</methods>
<members>
<member name="auto_lod" type="bool" setter="set_auto_lod" getter="get_auto_lod" default="true">
</member>
<member name="first_lod_distance_squared" type="float" setter="set_first_lod_distance_squared" getter="get_first_lod_distance_squared" default="1000.0">
</member>
<member name="job" type="PropInstanceJob" setter="set_job" getter="get_job">
</member>
<member name="lod_level" type="int" setter="set_lod_level" getter="get_lod_level" default="0">
</member>
<member name="lod_reduction_distance_squared" type="float" setter="set_lod_reduction_distance_squared" getter="get_lod_reduction_distance_squared" default="600.0">
</member>
<member name="materials" type="Array" setter="materials_set" getter="materials_get" default="[ ]">
</member>
<member name="meshes" type="Array" setter="meshes_set" getter="meshes_get">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropInstancePropJob" inherits="PropInstanceJob" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_jobs_step">
<return type="void" />
<argument index="0" name="mesher" type="PropMesherJobStep" />
<description>
</description>
</method>
<method name="add_light">
<return type="void" />
<argument index="0" name="light" type="PropLight" />
<description>
</description>
</method>
<method name="clear_lights">
<return type="void" />
<description>
</description>
</method>
<method name="get_jobs_step" qualifiers="const">
<return type="PropMesherJobStep" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="get_jobs_step_count" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="remove_jobs_step">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="set_jobs_step">
<return type="void" />
<argument index="0" name="index" type="int" />
<argument index="1" name="mesher" type="PropMesherJobStep" />
<description>
</description>
</method>
</methods>
<members>
<member name="build_phase_type" type="int" setter="set_build_phase_type" getter="get_build_phase_type" overrides="PropInstanceJob" enum="PropInstanceJob.ActiveBuildPhaseType" default="2" />
<member name="material_cache" type="PropMaterialCache" setter="set_material_cache" getter="get_material_cache">
</member>
<member name="prop_mesher" type="PropMesher" setter="set_prop_mesher" getter="get_prop_mesher">
</member>
</members>
<constants>
</constants>
</class>

21
doc_classes/PropLight.xml Normal file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropLight" inherits="Reference" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )">
</member>
<member name="size" type="float" setter="set_size" getter="get_size" default="0.0">
</member>
<member name="world_position" type="Vector3" setter="set_position" getter="get_position" default="Vector3( 0, 0, 0 )">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropMaterialCache" inherits="Resource" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="_setup_material_albedo" qualifiers="virtual">
<return type="void" />
<argument index="0" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="dec_ref_count">
<return type="void" />
<description>
</description>
</method>
<method name="inc_ref_count">
<return type="void" />
<description>
</description>
</method>
<method name="material_add">
<return type="void" />
<argument index="0" name="value" type="Material" />
<description>
</description>
</method>
<method name="material_get">
<return type="Material" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="material_get_num" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="material_lod_get">
<return type="Material" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="material_remove">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="material_set">
<return type="void" />
<argument index="0" name="index" type="int" />
<argument index="1" name="value" type="Material" />
<description>
</description>
</method>
<method name="materials_clear">
<return type="void" />
<description>
</description>
</method>
<method name="mutex_lock">
<return type="void" />
<description>
</description>
</method>
<method name="mutex_locked">
<return type="bool" />
<description>
</description>
</method>
<method name="mutex_unlock">
<return type="void" />
<description>
</description>
</method>
<method name="prop_add_textures">
<return type="void" />
<argument index="0" name="prop" type="PropData" />
<description>
</description>
</method>
<method name="prop_remove_textures">
<return type="void" />
<argument index="0" name="prop" type="PropData" />
<description>
</description>
</method>
<method name="refresh_rects">
<return type="void" />
<description>
</description>
</method>
<method name="setup_material_albedo">
<return type="void" />
<argument index="0" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="texture_add">
<return type="void" />
<argument index="0" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="texture_count">
<return type="int" />
<description>
</description>
</method>
<method name="texture_get">
<return type="Texture" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="texture_get_atlas">
<return type="AtlasTexture" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="texture_get_atlas_tex">
<return type="AtlasTexture" />
<argument index="0" name="index" type="Texture" />
<description>
</description>
</method>
<method name="texture_get_uv_rect">
<return type="Rect2" />
<argument index="0" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="texture_remove">
<return type="void" />
<argument index="0" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="texture_remove_index">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="textures_clear">
<return type="void" />
<description>
</description>
</method>
</methods>
<members>
<member name="initialized" type="bool" setter="set_initialized" getter="get_initialized" default="false">
</member>
<member name="mat_ref_count" type="int" setter="set_ref_count" getter="get_ref_count" default="0">
</member>
<member name="materials" type="Array" setter="materials_set" getter="materials_get" default="[ ]">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropMaterialCachePCM" inherits="PropMaterialCache" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="background_color" type="Color" setter="set_background_color" getter="get_background_color" default="Color( 0, 0, 0, 1 )">
</member>
<member name="keep_original_atlases" type="bool" setter="set_keep_original_atlases" getter="get_keep_original_atlases" default="false">
</member>
<member name="margin" type="int" setter="set_margin" getter="get_margin" default="0">
</member>
<member name="max_atlas_size" type="int" setter="set_max_atlas_size" getter="get_max_atlas_size" default="1024">
</member>
<member name="texture_flags" type="int" setter="set_texture_flags" getter="get_texture_flags" default="5">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropMeshUtils" inherits="Reference" version="3.2">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<constants>
</constants>
</class>

326
doc_classes/PropMesher.xml Normal file
View File

@ -0,0 +1,326 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropMesher" inherits="Reference" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="_add_mesher" qualifiers="virtual">
<return type="void" />
<argument index="0" name="mesher" type="PropMesher" />
<description>
</description>
</method>
<method name="add_color">
<return type="void" />
<argument index="0" name="color" type="Color" />
<description>
</description>
</method>
<method name="add_indices">
<return type="void" />
<argument index="0" name="indice" type="int" />
<description>
</description>
</method>
<method name="add_light">
<return type="void" />
<argument index="0" name="light" type="PropLight" />
<description>
</description>
</method>
<method name="add_mesh_data_resource">
<return type="void" />
<argument index="0" name="mesh" type="MeshDataResource" />
<argument index="1" name="position" type="Vector3" default="Rect2( 0, 0, 1, 1 )" />
<argument index="2" name="rotation" type="Vector3" default="Vector3( 1, 1, 1 )" />
<argument index="3" name="scale" type="Vector3" default="Vector3( 0, 0, 0 )" />
<argument index="4" name="uv_rect" type="Rect2" default="Vector3( 0, 0, 0 )" />
<description>
</description>
</method>
<method name="add_mesh_data_resource_transform">
<return type="void" />
<argument index="0" name="mesh" type="MeshDataResource" />
<argument index="1" name="transform" type="Transform" />
<argument index="2" name="uv_rect" type="Rect2" default="Rect2( 0, 0, 1, 1 )" />
<description>
</description>
</method>
<method name="add_mesh_data_resource_transform_colored">
<return type="void" />
<argument index="0" name="mesh" type="MeshDataResource" />
<argument index="1" name="transform" type="Transform" />
<argument index="2" name="colors" type="PoolColorArray" />
<argument index="3" name="uv_rect" type="Rect2" default="Rect2( 0, 0, 1, 1 )" />
<description>
</description>
</method>
<method name="add_mesher">
<return type="void" />
<argument index="0" name="mesher" type="PropMesher" />
<description>
</description>
</method>
<method name="add_normal">
<return type="void" />
<argument index="0" name="normal" type="Vector3" />
<description>
</description>
</method>
<method name="add_tiled_wall_mesh_rect_simple">
<return type="void" />
<argument index="0" name="x" type="int" />
<argument index="1" name="y" type="int" />
<argument index="2" name="transform" type="Transform" />
<argument index="3" name="texture_rect" type="Rect2" />
<description>
</description>
</method>
<method name="add_tiled_wall_simple">
<return type="void" />
<argument index="0" name="width" type="int" />
<argument index="1" name="height" type="int" />
<argument index="2" name="transform" type="Transform" />
<argument index="3" name="tiled_wall_data" type="TiledWallData" />
<argument index="4" name="cache" type="PropMaterialCache" />
<description>
</description>
</method>
<method name="add_uv">
<return type="void" />
<argument index="0" name="uv" type="Vector2" />
<description>
</description>
</method>
<method name="add_uv2">
<return type="void" />
<argument index="0" name="uv" type="Vector2" />
<description>
</description>
</method>
<method name="add_vertex">
<return type="void" />
<argument index="0" name="vertex" type="Vector3" />
<description>
</description>
</method>
<method name="bake_colors">
<return type="void" />
<description>
</description>
</method>
<method name="build_collider" qualifiers="const">
<return type="PoolVector3Array" />
<description>
</description>
</method>
<method name="build_mesh">
<return type="Array" />
<description>
</description>
</method>
<method name="build_mesh_into">
<return type="void" />
<argument index="0" name="mesh_rid" type="RID" />
<description>
</description>
</method>
<method name="clear_lights">
<return type="void" />
<description>
</description>
</method>
<method name="generate_ao">
<return type="void" />
<description>
</description>
</method>
<method name="generate_normals">
<return type="void" />
<argument index="0" name="flip" type="bool" default="false" />
<description>
</description>
</method>
<method name="get_color" qualifiers="const">
<return type="Color" />
<argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_colors" qualifiers="const">
<return type="PoolColorArray" />
<description>
</description>
</method>
<method name="get_index" qualifiers="const">
<return type="int" />
<argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_indices" qualifiers="const">
<return type="PoolIntArray" />
<description>
</description>
</method>
<method name="get_indices_count" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="get_normal" qualifiers="const">
<return type="Vector3" />
<argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_normals" qualifiers="const">
<return type="PoolVector3Array" />
<description>
</description>
</method>
<method name="get_random_ao">
<return type="float" />
<argument index="0" name="position" type="Vector3" />
<description>
</description>
</method>
<method name="get_uv" qualifiers="const">
<return type="Vector2" />
<argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_uv2" qualifiers="const">
<return type="Vector2" />
<argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_uv2s" qualifiers="const">
<return type="PoolVector2Array" />
<description>
</description>
</method>
<method name="get_uvs" qualifiers="const">
<return type="PoolVector2Array" />
<description>
</description>
</method>
<method name="get_vertex" qualifiers="const">
<return type="Vector3" />
<argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="get_vertex_count" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="get_vertices" qualifiers="const">
<return type="PoolVector3Array" />
<description>
</description>
</method>
<method name="remove_doubles">
<return type="void" />
<description>
</description>
</method>
<method name="remove_doubles_hashed">
<return type="void" />
<description>
</description>
</method>
<method name="remove_index">
<return type="void" />
<argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="remove_vertex">
<return type="void" />
<argument index="0" name="idx" type="int" />
<description>
</description>
</method>
<method name="reset">
<return type="void" />
<description>
</description>
</method>
<method name="set_colors">
<return type="void" />
<argument index="0" name="values" type="PoolColorArray" />
<description>
</description>
</method>
<method name="set_indices">
<return type="void" />
<argument index="0" name="values" type="PoolIntArray" />
<description>
</description>
</method>
<method name="set_normals">
<return type="void" />
<argument index="0" name="values" type="PoolVector3Array" />
<description>
</description>
</method>
<method name="set_uv2s">
<return type="void" />
<argument index="0" name="values" type="PoolVector2Array" />
<description>
</description>
</method>
<method name="set_uvs">
<return type="void" />
<argument index="0" name="values" type="PoolVector2Array" />
<description>
</description>
</method>
<method name="set_vertices">
<return type="void" />
<argument index="0" name="values" type="PoolVector3Array" />
<description>
</description>
</method>
<method name="transform_uv" qualifiers="const">
<return type="Vector2" />
<argument index="0" name="uv" type="Vector2" />
<argument index="1" name="rect" type="Rect2" />
<description>
</description>
</method>
</methods>
<members>
<member name="ao_strength" type="float" setter="set_ao_strength" getter="get_ao_strength" default="0.25">
</member>
<member name="base_light_value" type="float" setter="set_base_light_value" getter="get_base_light_value" default="0.5">
</member>
<member name="build_flags" type="int" setter="set_build_flags" getter="get_build_flags" default="0">
</member>
<member name="channel_index_isolevel" type="int" setter="set_channel_index_isolevel" getter="get_channel_index_isolevel" default="0">
</member>
<member name="channel_index_type" type="int" setter="set_channel_index_type" getter="get_channel_index_type" default="0">
</member>
<member name="format" type="int" setter="set_format" getter="get_format" default="18">
</member>
<member name="material" type="Material" setter="set_material" getter="get_material">
</member>
<member name="mesher_index" type="int" setter="set_mesher_index" getter="get_mesher_index" default="0">
</member>
<member name="texture_scale" type="int" setter="set_texture_scale" getter="get_texture_scale" default="1">
</member>
<member name="uv_margin" type="Rect2" setter="set_uv_margin" getter="get_uv_margin" default="Rect2( 0, 0, 1, 1 )">
</member>
<member name="voxel_scale" type="float" setter="set_voxel_scale" getter="get_voxel_scale" default="1.0">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropMesherJobStep" inherits="Reference" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="fqms" type="FastQuadraticMeshSimplifier" setter="set_fqms" getter="get_fqms">
</member>
<member name="job_type" type="int" setter="set_job_type" getter="get_job_type" enum="PropMesherJobStep.PropMesherJobStepType" default="0">
</member>
<member name="lod_index" type="int" setter="set_lod_index" getter="get_lod_index" default="0">
</member>
<member name="simplification_agressiveness" type="float" setter="set_simplification_agressiveness" getter="get_simplification_agressiveness" default="7.0">
</member>
<member name="simplification_step_ratio" type="float" setter="set_simplification_step_ratio" getter="get_simplification_step_ratio" default="0.8">
</member>
<member name="simplification_steps" type="int" setter="set_simplification_steps" getter="get_simplification_steps" default="2">
</member>
</members>
<constants>
<constant name="TYPE_NORMAL" value="0" enum="PropMesherJobStepType">
</constant>
<constant name="TYPE_NORMAL_LOD" value="1" enum="PropMesherJobStepType">
</constant>
<constant name="TYPE_DROP_UV2" value="2" enum="PropMesherJobStepType">
</constant>
<constant name="TYPE_MERGE_VERTS" value="3" enum="PropMesherJobStepType">
</constant>
<constant name="TYPE_BAKE_TEXTURE" value="4" enum="PropMesherJobStepType">
</constant>
<constant name="TYPE_SIMPLIFY_MESH" value="5" enum="PropMesherJobStepType">
</constant>
<constant name="TYPE_OTHER" value="6" enum="PropMesherJobStepType">
</constant>
</constants>
</class>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropSceneInstance" inherits="Spatial" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="build">
<return type="void" />
<description>
</description>
</method>
</methods>
<members>
<member name="scene" type="PackedScene" setter="set_scene" getter="get_scene">
</member>
<member name="snap_axis" type="Vector3" setter="set_snap_axis" getter="get_snap_axis" default="Vector3( 0, -1, 0 )">
</member>
<member name="snap_to_mesh" type="bool" setter="set_snap_to_mesh" getter="get_snap_to_mesh" default="false">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropMeshDataInstance" inherits="Spatial" version="3.2">
<class name="PropTextureJob" inherits="ThreadPoolJob" version="3.5">
<brief_description>
</brief_description>
<description>
@ -8,6 +8,10 @@
</tutorials>
<methods>
</methods>
<members>
<member name="merger" type="TexturePacker" setter="set_merger" getter="get_merger">
</member>
</members>
<constants>
</constants>
</class>

49
doc_classes/PropUtils.xml Normal file
View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropUtils" inherits="Object" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_processor">
<return type="int" />
<argument index="0" name="processor" type="PropDataEntry" />
<description>
</description>
</method>
<method name="convert_tree">
<return type="PropData" />
<argument index="0" name="root" type="Node" />
<description>
</description>
</method>
<method name="get_processor">
<return type="PropDataEntry" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="get_processor_count">
<return type="int" />
<description>
</description>
</method>
<method name="remove_processor">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="swap_processors">
<return type="void" />
<argument index="0" name="index1" type="int" />
<argument index="1" name="index2" type="int" />
<description>
</description>
</method>
</methods>
<constants>
</constants>
</class>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PropVoxelmanLight" inherits="Spatial" version="3.2">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<constants>
</constants>
</class>

57
doc_classes/TiledWall.xml Normal file
View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TiledWall" inherits="GeometryInstance" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="clear_mesh">
<return type="void" />
<description>
</description>
</method>
<method name="create_colliders">
<return type="void" />
<description>
</description>
</method>
<method name="free_colliders">
<return type="void" />
<description>
</description>
</method>
<method name="free_mesh">
<return type="void" />
<description>
</description>
</method>
<method name="generate_mesh">
<return type="void" />
<description>
</description>
</method>
<method name="refresh">
<return type="void" />
<description>
</description>
</method>
</methods>
<members>
<member name="collision" type="bool" setter="set_collision" getter="get_collision" default="true">
</member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
</member>
<member name="data" type="TiledWallData" setter="set_data" getter="get_data">
</member>
<member name="heigth" type="int" setter="set_heigth" getter="get_heigth" default="1">
</member>
<member name="width" type="int" setter="set_width" getter="get_width" default="1">
</member>
</members>
<constants>
</constants>
</class>

View File

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="TiledWallData" inherits="Resource" version="3.5">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="_setup_cache" qualifiers="virtual">
<return type="void" />
<argument index="0" name="cache" type="PropMaterialCache" />
<description>
</description>
</method>
<method name="add_texture">
<return type="void" />
<argument index="0" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="add_textures_into">
<return type="void" />
<argument index="0" name="texture_packer" type="TexturePacker" />
<description>
</description>
</method>
<method name="add_tflavour_exture">
<return type="void" />
<argument index="0" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="copy_from">
<return type="void" />
<argument index="0" name="prop_data" type="TiledWallData" />
<description>
</description>
</method>
<method name="get_flavour_texture" qualifiers="const">
<return type="Texture" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="get_flavour_texture_count" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="get_texture" qualifiers="const">
<return type="Texture" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="get_texture_count" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="material_add">
<return type="void" />
<argument index="0" name="value" type="Material" />
<description>
</description>
</method>
<method name="material_get_num" qualifiers="const">
<return type="int" />
<description>
</description>
</method>
<method name="material_remove">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="material_set">
<return type="void" />
<argument index="0" name="index" type="int" />
<argument index="1" name="value" type="Material" />
<description>
</description>
</method>
<method name="materials_clear">
<return type="void" />
<description>
</description>
</method>
<method name="remove_flavour_texture">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="remove_texture">
<return type="void" />
<argument index="0" name="index" type="int" />
<description>
</description>
</method>
<method name="set_flavour_texture">
<return type="void" />
<argument index="0" name="index" type="int" />
<argument index="1" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="set_texture">
<return type="void" />
<argument index="0" name="index" type="int" />
<argument index="1" name="texture" type="Texture" />
<description>
</description>
</method>
<method name="setup_cache">
<return type="void" />
<argument index="0" name="cache" type="PropMaterialCache" />
<description>
</description>
</method>
</methods>
<members>
<member name="flavour_chance" type="float" setter="set_flavour_chance" getter="get_flavour_chance" default="0.15">
</member>
<member name="flavour_textures" type="Array" setter="set_flavour_textures" getter="get_flavour_textures" default="[ ]">
</member>
<member name="materials" type="Array" setter="materials_set" getter="materials_get" default="[ ]">
</member>
<member name="textures" type="Array" setter="set_textures" getter="get_textures" default="[ ]">
</member>
<member name="tiling_type" type="int" setter="set_tiling_type" getter="get_tiling_type" enum="TiledWallData.TiledWallTilingType" default="0">
</member>
</members>
<constants>
<constant name="TILED_WALL_TILING_TYPE_NONE" value="0" enum="TiledWallTilingType">
</constant>
<constant name="TILED_WALL_TILING_TYPE_HORIZONTAL" value="1" enum="TiledWallTilingType">
</constant>
<constant name="TILED_WALL_TILING_TYPE_VERTICAL" value="2" enum="TiledWallTilingType">
</constant>
<constant name="TILED_WALL_TILING_TYPE_BOTH" value="3" enum="TiledWallTilingType">
</constant>
</constants>
</class>

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2020 Péter Magyar
Copyright (c) 2020-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_editor_plugin_2d.h"
#include "prop_editor_plugin.h"
#include "../props/prop_data_2d.h"
#include "../singleton/prop_utils_2d.h"
#include "../props/prop_data.h"
#include "../singleton/prop_utils.h"
#include "core/os/keyboard.h"
#include "core/version.h"
@ -41,7 +41,7 @@ SOFTWARE.
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method))
#endif
void PropEditorPlugin2D::convert_active_scene_to_prop_data() {
void PropEditorPlugin::convert_active_scene_to_prop_data() {
SceneTree *st = SceneTree::get_singleton();
if (st) {
@ -55,17 +55,17 @@ void PropEditorPlugin2D::convert_active_scene_to_prop_data() {
}
}
}
void PropEditorPlugin2D::convert_selected_scene_to_prop_data() {
void PropEditorPlugin::convert_selected_scene_to_prop_data() {
}
void PropEditorPlugin2D::convert_scene(Node *root, const String &path) {
Ref<PropData2D> data = PropUtils2D::get_singleton()->convert_tree(root);
void PropEditorPlugin::convert_scene(Node *root, const String &path) {
Ref<PropData> data = PropUtils::get_singleton()->convert_tree(root);
ERR_FAIL_COND(!data.is_valid());
ResourceLoader l;
if (l.exists(path)) {
Ref<PropData2D> res = l.load(path, "PropData");
Ref<PropData> res = l.load(path, "PropData");
ERR_FAIL_COND(!res.is_valid());
@ -81,7 +81,7 @@ void PropEditorPlugin2D::convert_scene(Node *root, const String &path) {
}
}
void PropEditorPlugin2D::find_room_points(Variant param) {
void PropEditorPlugin::find_room_points(Variant param) {
#if VERSION_MINOR >= 4
SceneTree *st = SceneTree::get_singleton();
@ -89,24 +89,24 @@ void PropEditorPlugin2D::find_room_points(Variant param) {
Node *scene = st->get_edited_scene_root();
if (scene) {
PropUtils2D::get_singleton()->generate_room_points_node(scene);
PropUtils::get_singleton()->generate_room_points_node(scene);
}
}
#endif
}
void PropEditorPlugin2D::_quick_convert_button_pressed() {
void PropEditorPlugin::_quick_convert_button_pressed() {
convert_active_scene_to_prop_data();
}
void PropEditorPlugin2D::_convert_active_scene_to_prop_data(Variant param) {
void PropEditorPlugin::_convert_active_scene_to_prop_data(Variant param) {
convert_active_scene_to_prop_data();
}
void PropEditorPlugin2D::_convert_selected_scene_to_prop_data(Variant param) {
void PropEditorPlugin::_convert_selected_scene_to_prop_data(Variant param) {
convert_selected_scene_to_prop_data();
}
PropEditorPlugin2D::PropEditorPlugin2D(EditorNode *p_node) {
PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) {
editor = p_node;
#if VERSION_MAJOR < 4
@ -126,21 +126,21 @@ PropEditorPlugin2D::PropEditorPlugin2D(EditorNode *p_node) {
container->add_child(b);
b->set_flat(true);
b->CONNECT("pressed", this, PropEditorPlugin2D, _quick_convert_button_pressed);
b->CONNECT("pressed", this, PropEditorPlugin, _quick_convert_button_pressed);
b->set_text("To Prop");
b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to PropData.", KEY_MASK_ALT + KEY_U));
add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, container);
}
PropEditorPlugin2D::~PropEditorPlugin2D() {
PropEditorPlugin::~PropEditorPlugin() {
}
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);
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);
ClassDB::bind_method(D_METHOD("find_room_points"), &PropEditorPlugin2D::find_room_points);
ClassDB::bind_method(D_METHOD("find_room_points"), &PropEditorPlugin::find_room_points);
ClassDB::bind_method(D_METHOD("_quick_convert_button_pressed"), &PropEditorPlugin2D::_quick_convert_button_pressed);
ClassDB::bind_method(D_METHOD("_quick_convert_button_pressed"), &PropEditorPlugin::_quick_convert_button_pressed);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2020 Péter Magyar
Copyright (c) 2020-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,24 +20,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_EDITOR_PLUGIN_2D_H
#define PROP_EDITOR_PLUGIN_2D_H
#ifndef PROP_EDITOR_PLUGIN_H
#define PROP_EDITOR_PLUGIN_H
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "core/version.h"
class PropEditorPlugin2D : public EditorPlugin {
class PropEditorPlugin : public EditorPlugin {
GDCLASS(PropEditorPlugin2D, EditorPlugin);
GDCLASS(PropEditorPlugin, EditorPlugin);
EditorNode *editor;
protected:
static void _bind_methods();
public:
virtual String get_name() const { return "PropEditorPlugin2D"; }
virtual String get_name() const { return "PropEditorPlugin"; }
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();
PropEditorPlugin2D(EditorNode *p_node);
~PropEditorPlugin2D();
PropEditorPlugin(EditorNode *p_node);
~PropEditorPlugin();
};
#endif

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,56 +20,56 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_mesher_job_step_2d.h"
#include "prop_mesher_job_step.h"
const String PropMesherJobStep2D::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh";
const String PropMesherJobStep::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh";
PropMesherJobStep2D::PropMesherJobStepType2D PropMesherJobStep2D::get_job_type() const {
PropMesherJobStep::PropMesherJobStepType PropMesherJobStep::get_job_type() const {
return _job_type;
}
void PropMesherJobStep2D::set_job_type(const PropMesherJobStep2D::PropMesherJobStepType2D value) {
void PropMesherJobStep::set_job_type(const PropMesherJobStep::PropMesherJobStepType value) {
_job_type = value;
}
int PropMesherJobStep2D::get_lod_index() const {
int PropMesherJobStep::get_lod_index() const {
return _lod_index;
}
void PropMesherJobStep2D::set_lod_index(const int value) {
void PropMesherJobStep::set_lod_index(const int value) {
_lod_index = value;
}
#ifdef MESH_UTILS_PRESENT
Ref<FastQuadraticMeshSimplifier> PropMesherJobStep2D::get_fqms() {
Ref<FastQuadraticMeshSimplifier> PropMesherJobStep::get_fqms() {
return _fqms;
}
void PropMesherJobStep2D::set_fqms(const Ref<FastQuadraticMeshSimplifier> &val) {
void PropMesherJobStep::set_fqms(const Ref<FastQuadraticMeshSimplifier> &val) {
_fqms = val;
}
float PropMesherJobStep2D::get_simplification_step_ratio() const {
float PropMesherJobStep::get_simplification_step_ratio() const {
return _simplification_step_ratio;
}
void PropMesherJobStep2D::set_simplification_step_ratio(const float value) {
void PropMesherJobStep::set_simplification_step_ratio(const float value) {
_simplification_step_ratio = value;
}
int PropMesherJobStep2D::get_simplification_steps() const {
int PropMesherJobStep::get_simplification_steps() const {
return _simplification_steps;
}
void PropMesherJobStep2D::set_simplification_steps(const int value) {
void PropMesherJobStep::set_simplification_steps(const int value) {
_simplification_steps = value;
}
float PropMesherJobStep2D::get_simplification_agressiveness() const {
float PropMesherJobStep::get_simplification_agressiveness() const {
return _simplification_agressiveness;
}
void PropMesherJobStep2D::set_simplification_agressiveness(const float value) {
void PropMesherJobStep::set_simplification_agressiveness(const float value) {
_simplification_agressiveness = value;
}
#endif
PropMesherJobStep2D::PropMesherJobStep2D() {
PropMesherJobStep::PropMesherJobStep() {
_job_type = TYPE_NORMAL;
_lod_index = 0;
@ -80,36 +80,36 @@ PropMesherJobStep2D::PropMesherJobStep2D() {
#endif
}
PropMesherJobStep2D::~PropMesherJobStep2D() {
PropMesherJobStep::~PropMesherJobStep() {
#ifdef MESH_UTILS_PRESENT
_fqms.unref();
#endif
}
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");
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");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_index"), "set_lod_index", "get_lod_index");
#ifdef MESH_UTILS_PRESENT
ClassDB::bind_method(D_METHOD("get_fqms"), &PropMesherJobStep2D::get_fqms);
ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep2D::set_fqms);
ClassDB::bind_method(D_METHOD("get_fqms"), &PropMesherJobStep::get_fqms);
ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep::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"), &PropMesherJobStep2D::get_simplification_step_ratio);
ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &PropMesherJobStep2D::set_simplification_step_ratio);
ClassDB::bind_method(D_METHOD("get_simplification_step_ratio"), &PropMesherJobStep::get_simplification_step_ratio);
ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &PropMesherJobStep::set_simplification_step_ratio);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_step_ratio"), "set_simplification_step_ratio", "get_simplification_step_ratio");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "simplification_steps"), "set_simplification_steps", "get_simplification_steps");
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);
ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &PropMesherJobStep::get_simplification_agressiveness);
ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &PropMesherJobStep::set_simplification_agressiveness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_agressiveness"), "set_simplification_agressiveness", "get_simplification_agressiveness");
#endif

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_MESHER_JOB_STEP_2D_H
#define PROP_MESHER_JOB_STEP_2D_H
#ifndef PROP_MESHER_JOB_STEP_H
#define PROP_MESHER_JOB_STEP_H
#include "core/version.h"
@ -35,15 +35,15 @@ SOFTWARE.
#include "../../mesh_utils/fast_quadratic_mesh_simplifier.h"
#endif
class PropMesherJobStep2D : public Reference {
GDCLASS(PropMesherJobStep2D, Reference);
class PropMesherJobStep : public Reference {
GDCLASS(PropMesherJobStep, 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 PropMesherJobStepType2D {
enum PropMesherJobStepType {
TYPE_NORMAL = 0,
TYPE_NORMAL_LOD,
TYPE_DROP_UV2,
@ -55,8 +55,8 @@ public:
static const String BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE;
PropMesherJobStepType2D get_job_type() const;
void set_job_type(const PropMesherJobStepType2D value);
PropMesherJobStepType get_job_type() const;
void set_job_type(const PropMesherJobStepType 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
PropMesherJobStep2D();
~PropMesherJobStep2D();
PropMesherJobStep();
~PropMesherJobStep();
protected:
static void _bind_methods();
PropMesherJobStepType2D _job_type;
PropMesherJobStepType _job_type;
int _lod_index;
#ifdef MESH_UTILS_PRESENT
@ -92,6 +92,6 @@ protected:
#endif
};
VARIANT_ENUM_CAST(PropMesherJobStep2D::PropMesherJobStepType2D);
VARIANT_ENUM_CAST(PropMesherJobStep::PropMesherJobStepType);
#endif

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,23 +20,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_texture_job_2d.h"
#include "prop_texture_job.h"
#if TEXTURE_PACKER_PRESENT
#include "../../texture_packer/texture_packer.h"
#endif
#if TEXTURE_PACKER_PRESENT
Ref<TexturePacker> PropTextureJob2D::get_merger() {
Ref<TexturePacker> PropTextureJob::get_merger() {
return _merger;
}
void PropTextureJob2D::set_merger(const Ref<TexturePacker> &merger) {
void PropTextureJob::set_merger(const Ref<TexturePacker> &merger) {
_merger = merger;
}
#endif
void PropTextureJob2D::_execute() {
void PropTextureJob::_execute() {
#if TEXTURE_PACKER_PRESENT
if (!_merger.is_valid()) {
set_complete(true);
@ -49,7 +49,7 @@ void PropTextureJob2D::_execute() {
set_complete(true);
}
PropTextureJob2D::PropTextureJob2D() {
PropTextureJob::PropTextureJob() {
#if !THREAD_POOL_PRESENT
_complete = true;
_cancelled = false;
@ -62,110 +62,110 @@ PropTextureJob2D::PropTextureJob2D() {
#endif
}
PropTextureJob2D::~PropTextureJob2D() {
PropTextureJob::~PropTextureJob() {
}
void PropTextureJob2D::_bind_methods() {
void PropTextureJob::_bind_methods() {
#if TEXTURE_PACKER_PRESENT
ClassDB::bind_method(D_METHOD("get_merger"), &PropTextureJob2D::get_merger);
ClassDB::bind_method(D_METHOD("set_merger", "value"), &PropTextureJob2D::set_merger);
ClassDB::bind_method(D_METHOD("get_merger"), &PropTextureJob::get_merger);
ClassDB::bind_method(D_METHOD("set_merger", "value"), &PropTextureJob::set_merger);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "merger", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"), "set_merger", "get_merger");
#endif
ClassDB::bind_method(D_METHOD("_execute"), &PropTextureJob2D::_execute);
ClassDB::bind_method(D_METHOD("_execute"), &PropTextureJob::_execute);
#if !THREAD_POOL_PRESENT
ClassDB::bind_method(D_METHOD("get_complete"), &PropTextureJob2D::get_complete);
ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropTextureJob2D::set_complete);
ClassDB::bind_method(D_METHOD("get_complete"), &PropTextureJob::get_complete);
ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropTextureJob::set_complete);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage");
ClassDB::bind_method(D_METHOD("get_stage"), &PropTextureJob2D::get_stage);
ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropTextureJob2D::set_stage);
ClassDB::bind_method(D_METHOD("get_stage"), &PropTextureJob::get_stage);
ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropTextureJob::set_stage);
ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage");
ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropTextureJob2D::get_current_execution_time);
ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropTextureJob::get_current_execution_time);
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob2D::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob2D::should_return);
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob::should_return);
BIND_VMETHOD(MethodInfo("_execute"));
ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob2D::execute);
ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob::execute);
ADD_SIGNAL(MethodInfo("completed"));
#endif
}
#if !THREAD_POOL_PRESENT
bool PropTextureJob2D::get_complete() const {
bool PropTextureJob::get_complete() const {
return _complete;
}
void PropTextureJob2D::set_complete(const bool value) {
void PropTextureJob::set_complete(const bool value) {
_complete = value;
}
bool PropTextureJob2D::get_cancelled() const {
bool PropTextureJob::get_cancelled() const {
return _cancelled;
}
void PropTextureJob2D::set_cancelled(const bool value) {
void PropTextureJob::set_cancelled(const bool value) {
_cancelled = value;
}
float PropTextureJob2D::get_max_allocated_time() const {
float PropTextureJob::get_max_allocated_time() const {
return _max_allocated_time;
}
void PropTextureJob2D::set_max_allocated_time(const float value) {
void PropTextureJob::set_max_allocated_time(const float value) {
_max_allocated_time = value;
}
int PropTextureJob2D::get_start_time() const {
int PropTextureJob::get_start_time() const {
return _start_time;
}
void PropTextureJob2D::set_start_time(const int value) {
void PropTextureJob::set_start_time(const int value) {
_start_time = value;
}
int PropTextureJob2D::get_current_run_stage() const {
int PropTextureJob::get_current_run_stage() const {
return _current_run_stage;
}
void PropTextureJob2D::set_current_run_stage(const int value) {
void PropTextureJob::set_current_run_stage(const int value) {
_current_run_stage = value;
}
int PropTextureJob2D::get_stage() const {
int PropTextureJob::get_stage() const {
return _stage;
}
void PropTextureJob2D::set_stage(const int value) {
void PropTextureJob::set_stage(const int value) {
_stage = value;
}
void PropTextureJob2D::reset_stages() {
void PropTextureJob::reset_stages() {
_current_run_stage = 0;
_stage = 0;
}
float PropTextureJob2D::get_current_execution_time() {
float PropTextureJob::get_current_execution_time() {
return 0;
}
bool PropTextureJob2D::should_do(const bool just_check) {
bool PropTextureJob::should_do(const bool just_check) {
return true;
}
bool PropTextureJob2D::should_return() {
bool PropTextureJob::should_return() {
if (_cancelled)
return true;
return false;
}
void PropTextureJob2D::execute() {
void PropTextureJob::execute() {
ERR_FAIL_COND(!has_method("_execute"));
call("_execute");

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_TEXTURE_JOB_2D_H
#define PROP_TEXTURE_JOB_2D_H
#ifndef PROP_TEXTURE_JOB
#define PROP_TEXTURE_JOB
#include "scene/resources/texture.h"
@ -43,11 +43,11 @@ class TexturePacker;
#endif
#if THREAD_POOL_PRESENT
class PropTextureJob2D : public ThreadPoolJob {
GDCLASS(PropTextureJob2D, ThreadPoolJob);
class PropTextureJob : public ThreadPoolJob {
GDCLASS(PropTextureJob, ThreadPoolJob);
#else
class PropTextureJob2D : public Reference {
GDCLASS(PropTextureJob2D, Reference);
class PropTextureJob : public Reference {
GDCLASS(PropTextureJob, Reference);
#endif
public:
@ -58,8 +58,8 @@ public:
void _execute();
PropTextureJob2D();
~PropTextureJob2D();
PropTextureJob();
~PropTextureJob();
protected:
static void _bind_methods();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,46 +20,46 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_light_2d.h"
#include "prop_light.h"
Vector3 PropLight2D::get_position() {
Vector3 PropLight::get_position() {
return _position;
}
void PropLight2D::set_position(const Vector3 &pos) {
void PropLight::set_position(const Vector3 &pos) {
_position = pos;
}
Color PropLight2D::get_color() const {
Color PropLight::get_color() const {
return _color;
}
void PropLight2D::set_color(const Color &color) {
void PropLight::set_color(const Color &color) {
_color = color;
}
float PropLight2D::get_size() const {
float PropLight::get_size() const {
return _size;
}
void PropLight2D::set_size(const float size) {
void PropLight::set_size(const float size) {
_size = size;
}
PropLight2D::PropLight2D() {
PropLight::PropLight() {
_size = 0;
}
PropLight2D::~PropLight2D() {
PropLight::~PropLight() {
}
void PropLight2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_position"), &PropLight2D::get_position);
ClassDB::bind_method(D_METHOD("set_position"), &PropLight2D::set_position);
void PropLight::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_position"), &PropLight::get_position);
ClassDB::bind_method(D_METHOD("set_position"), &PropLight::set_position);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "world_position"), "set_position", "get_position");
ClassDB::bind_method(D_METHOD("get_color"), &PropLight2D::get_color);
ClassDB::bind_method(D_METHOD("set_color"), &PropLight2D::set_color);
ClassDB::bind_method(D_METHOD("get_color"), &PropLight::get_color);
ClassDB::bind_method(D_METHOD("set_color"), &PropLight::set_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ClassDB::bind_method(D_METHOD("get_size"), &PropLight2D::get_size);
ClassDB::bind_method(D_METHOD("set_size"), &PropLight2D::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &PropLight::get_size);
ClassDB::bind_method(D_METHOD("set_size"), &PropLight::set_size);
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_LIGHT_2D_H
#define PROP_LIGHT_2D_H
#ifndef PROP_LIGHT_H
#define PROP_LIGHT_H
#include "core/version.h"
@ -35,8 +35,8 @@ SOFTWARE.
#include "core/color.h"
#endif
class PropLight2D : public Reference {
GDCLASS(PropLight2D, Reference);
class PropLight : public Reference {
GDCLASS(PropLight, Reference);
public:
Vector3 get_position();
@ -48,8 +48,8 @@ public:
float get_size() const;
void set_size(const float strength);
PropLight2D();
~PropLight2D();
PropLight();
~PropLight();
private:
static void _bind_methods();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,18 +20,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_material_cache_2d.h"
#include "prop_material_cache.h"
#include "../props/prop_data_2d.h"
#include "../props/prop_data_prop_2d.h"
#include "../props/prop_data_tiled_wall_2d.h"
#include "../singleton/prop_cache_2d.h"
#include "../tiled_wall/tiled_wall_data_2d.h"
#include "../props/prop_data.h"
#include "../props/prop_data_prop.h"
#include "../props/prop_data_tiled_wall.h"
#include "../singleton/prop_cache.h"
#include "../tiled_wall/tiled_wall_data.h"
#if MESH_DATA_RESOURCE_PRESENT
#define PROPS_PRESENT 1
#include "../../mesh_data_resource/props/prop_data_mesh_data.h"
#undef PROPS_PRESENT
//define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling,
//but not when included from here.
#define PROPS_2D_PRESENT 1
#include "../../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h"
#endif
#if VERSION_MAJOR > 3
@ -54,44 +55,44 @@ SOFTWARE.
#endif
bool PropMaterialCache2D::get_initialized() {
bool PropMaterialCache::get_initialized() {
return _initialized;
}
void PropMaterialCache2D::set_initialized(const bool value) {
void PropMaterialCache::set_initialized(const bool value) {
_initialized = value;
}
bool PropMaterialCache2D::mutex_locked() {
bool PropMaterialCache::mutex_locked() {
return _locked;
}
void PropMaterialCache2D::mutex_lock() {
void PropMaterialCache::mutex_lock() {
_mutex.lock();
}
void PropMaterialCache2D::mutex_unlock() {
void PropMaterialCache::mutex_unlock() {
_mutex.unlock();
}
int PropMaterialCache2D::get_ref_count() {
int PropMaterialCache::get_ref_count() {
return _ref_count;
}
void PropMaterialCache2D::set_ref_count(const int value) {
void PropMaterialCache::set_ref_count(const int value) {
_ref_count = value;
}
void PropMaterialCache2D::inc_ref_count() {
void PropMaterialCache::inc_ref_count() {
_ref_count += 1;
}
void PropMaterialCache2D::dec_ref_count() {
void PropMaterialCache::dec_ref_count() {
_ref_count -= 1;
}
//Materials
Ref<Material> PropMaterialCache2D::material_get(const int index) {
Ref<Material> PropMaterialCache::material_get(const int index) {
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
return _materials[index];
}
Ref<Material> PropMaterialCache2D::material_lod_get(const int index) {
Ref<Material> PropMaterialCache::material_lod_get(const int index) {
ERR_FAIL_COND_V(_materials.size() == 0, Ref<Material>(NULL));
if (index < 0) {
@ -105,35 +106,35 @@ Ref<Material> PropMaterialCache2D::material_lod_get(const int index) {
return _materials[index];
}
void PropMaterialCache2D::material_add(const Ref<Material> &value) {
void PropMaterialCache::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
void PropMaterialCache2D::material_set(const int index, const Ref<Material> &value) {
void PropMaterialCache::material_set(const int index, const Ref<Material> &value) {
ERR_FAIL_INDEX(index, _materials.size());
_materials.set(index, value);
}
void PropMaterialCache2D::material_remove(const int index) {
void PropMaterialCache::material_remove(const int index) {
_materials.remove(index);
}
int PropMaterialCache2D::material_get_num() const {
int PropMaterialCache::material_get_num() const {
return _materials.size();
}
void PropMaterialCache2D::materials_clear() {
void PropMaterialCache::materials_clear() {
_materials.clear();
}
Vector<Variant> PropMaterialCache2D::materials_get() {
Vector<Variant> PropMaterialCache::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void PropMaterialCache2D::materials_set(const Vector<Variant> &materials) {
void PropMaterialCache::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
@ -143,10 +144,10 @@ void PropMaterialCache2D::materials_set(const Vector<Variant> &materials) {
}
}
void PropMaterialCache2D::texture_add(const Ref<Texture> &texture) {
void PropMaterialCache::texture_add(const Ref<Texture> &texture) {
_textures.push_back(texture);
}
void PropMaterialCache2D::texture_remove(const Ref<Texture> &texture) {
void PropMaterialCache::texture_remove(const Ref<Texture> &texture) {
for (int i = 0; i < _textures.size(); ++i) {
if (_textures[i] == texture) {
_textures.remove(i);
@ -154,42 +155,42 @@ void PropMaterialCache2D::texture_remove(const Ref<Texture> &texture) {
}
}
}
void PropMaterialCache2D::texture_remove_index(const int index) {
void PropMaterialCache::texture_remove_index(const int index) {
ERR_FAIL_INDEX(index, _textures.size());
_textures.remove(index);
}
void PropMaterialCache2D::textures_clear() {
void PropMaterialCache::textures_clear() {
_textures.clear();
}
int PropMaterialCache2D::texture_count() {
int PropMaterialCache::texture_count() {
return _textures.size();
}
Ref<Texture> PropMaterialCache2D::texture_get(const int index) {
Ref<Texture> PropMaterialCache::texture_get(const int index) {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture>());
return _textures[index];
}
Ref<AtlasTexture> PropMaterialCache2D::texture_get_atlas(const int index) {
Ref<AtlasTexture> PropMaterialCache::texture_get_atlas(const int index) {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<AtlasTexture>());
return texture_get_atlas_tex(_textures[index]);
}
Ref<AtlasTexture> PropMaterialCache2D::texture_get_atlas_tex(const Ref<Texture> &texture) {
Ref<AtlasTexture> PropMaterialCache::texture_get_atlas_tex(const Ref<Texture> &texture) {
return Ref<AtlasTexture>();
}
Rect2 PropMaterialCache2D::texture_get_uv_rect(const Ref<Texture> &texture) {
Rect2 PropMaterialCache::texture_get_uv_rect(const Ref<Texture> &texture) {
return Rect2(0, 0, 1, 1);
}
void PropMaterialCache2D::prop_add_textures(const Ref<PropData2D> &prop) {
void PropMaterialCache::prop_add_textures(const Ref<PropData> &prop) {
if (!prop.is_valid()) {
return;
}
for (int i = 0; i < prop->get_prop_count(); ++i) {
#if MESH_DATA_RESOURCE_PRESENT
Ref<PropData2DMeshData> pdm = prop->get_prop(i);
Ref<Prop2DDataMeshData> pdm = prop->get_prop(i);
if (pdm.is_valid()) {
Ref<Texture> tex = pdm->get_texture();
@ -203,34 +204,34 @@ void PropMaterialCache2D::prop_add_textures(const Ref<PropData2D> &prop) {
}
#endif
Ref<PropDataTiledWall2D> pdtw = prop->get_prop(i);
Ref<PropDataTiledWall> pdtw = prop->get_prop(i);
if (pdtw.is_valid()) {
Ref<TiledWallData2D> twd = pdtw->get_data();
Ref<TiledWallData> twd = pdtw->get_data();
if (!twd.is_valid())
continue;
twd->setup_cache(Ref<PropMaterialCache2D>(this));
twd->setup_cache(Ref<PropMaterialCache>(this));
continue;
}
Ref<PropDataProp2D> pdp = prop->get_prop(i);
Ref<PropDataProp> pdp = prop->get_prop(i);
if (pdp.is_valid()) {
prop_add_textures(pdp->get_prop());
}
}
}
void PropMaterialCache2D::prop_remove_textures(const Ref<PropData2D> &prop) {
void PropMaterialCache::prop_remove_textures(const Ref<PropData> &prop) {
if (!prop.is_valid()) {
return;
}
for (int i = 0; i < prop->get_prop_count(); ++i) {
#if MESH_DATA_RESOURCE_PRESENT
Ref<PropData2DMeshData> pdm = prop->get_prop(i);
Ref<Prop2DDataMeshData> pdm = prop->get_prop(i);
if (pdm.is_valid()) {
Ref<Texture> tex = pdm->get_texture();
@ -242,10 +243,10 @@ void PropMaterialCache2D::prop_remove_textures(const Ref<PropData2D> &prop) {
}
#endif
Ref<PropDataTiledWall2D> pdtw = prop->get_prop(i);
Ref<PropDataTiledWall> pdtw = prop->get_prop(i);
if (pdtw.is_valid()) {
Ref<TiledWallData2D> twd = pdtw->get_data();
Ref<TiledWallData> twd = pdtw->get_data();
if (!twd.is_valid())
continue;
@ -269,7 +270,7 @@ void PropMaterialCache2D::prop_remove_textures(const Ref<PropData2D> &prop) {
continue;
}
Ref<PropDataProp2D> pdp = prop->get_prop(i);
Ref<PropDataProp> pdp = prop->get_prop(i);
if (pdp.is_valid()) {
prop_remove_textures(pdp);
@ -277,14 +278,14 @@ void PropMaterialCache2D::prop_remove_textures(const Ref<PropData2D> &prop) {
}
}
void PropMaterialCache2D::refresh_rects() {
void PropMaterialCache::refresh_rects() {
_initialized = true;
}
void PropMaterialCache2D::initial_setup_default() {
void PropMaterialCache::initial_setup_default() {
//Note: call only on the main thread! Shader->duplicate() can crash if done from an another thread!
PropCache2D *pc = PropCache2D::get_singleton();
PropCache *pc = PropCache::get_singleton();
pc->ensure_materials_loaded();
@ -300,64 +301,64 @@ void PropMaterialCache2D::initial_setup_default() {
}
}
void PropMaterialCache2D::setup_material_albedo(Ref<Texture> texture) {
void PropMaterialCache::setup_material_albedo(Ref<Texture> texture) {
if (has_method("_setup_material_albedo"))
call("_setup_material_albedo", texture);
}
PropMaterialCache2D::PropMaterialCache2D() {
PropMaterialCache::PropMaterialCache() {
_ref_count = 0;
_initialized = false;
_locked = false;
}
PropMaterialCache2D::~PropMaterialCache2D() {
PropMaterialCache::~PropMaterialCache() {
_materials.clear();
}
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized"), "set_initialized", "get_initialized");
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("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("get_ref_count"), &PropMaterialCache2D::get_ref_count);
ClassDB::bind_method(D_METHOD("set_ref_count", "value"), &PropMaterialCache2D::set_ref_count);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "mat_ref_count"), "set_ref_count", "get_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);
ClassDB::bind_method(D_METHOD("inc_ref_count"), &PropMaterialCache::inc_ref_count);
ClassDB::bind_method(D_METHOD("dec_ref_count"), &PropMaterialCache::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"), &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("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("materials_get"), &PropMaterialCache2D::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropMaterialCache2D::materials_set);
ClassDB::bind_method(D_METHOD("materials_get"), &PropMaterialCache::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropMaterialCache::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"), &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("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("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("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("refresh_rects"), &PropMaterialCache2D::refresh_rects);
ClassDB::bind_method(D_METHOD("refresh_rects"), &PropMaterialCache::refresh_rects);
ClassDB::bind_method(D_METHOD("setup_material_albedo", "texture"), &PropMaterialCache2D::setup_material_albedo);
ClassDB::bind_method(D_METHOD("setup_material_albedo", "texture"), &PropMaterialCache::setup_material_albedo);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_MATERIAL_CACHE_2D_H
#define PROP_MATERIAL_CACHE_2D_H
#ifndef PROP_MATERIAL_CACHE_H
#define PROP_MATERIAL_CACHE_H
#include "core/version.h"
@ -39,10 +39,10 @@ SOFTWARE.
#include "scene/resources/material.h"
#include "core/os/mutex.h"
class PropData2D;
class PropData;
class PropMaterialCache2D : public Resource {
GDCLASS(PropMaterialCache2D, Resource)
class PropMaterialCache : public Resource {
GDCLASS(PropMaterialCache, 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<PropData2D> &prop);
void prop_remove_textures(const Ref<PropData2D> &prop);
void prop_add_textures(const Ref<PropData> &prop);
void prop_remove_textures(const Ref<PropData> &prop);
virtual void refresh_rects();
@ -87,8 +87,8 @@ public:
void setup_material_albedo(Ref<Texture> texture);
PropMaterialCache2D();
~PropMaterialCache2D();
PropMaterialCache();
~PropMaterialCache();
protected:
static void _bind_methods();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,55 +20,55 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_material_cache_pcm_2d.h"
#include "prop_material_cache_pcm.h"
#include "../../texture_packer/texture_packer.h"
#include "../singleton/prop_cache_2d.h"
#include "../singleton/prop_cache.h"
#include "scene/resources/texture.h"
int PropMaterialCachePCM2D::get_texture_flags() const {
int PropMaterialCachePCM::get_texture_flags() const {
return _packer->get_texture_flags();
}
void PropMaterialCachePCM2D::set_texture_flags(const int flags) {
void PropMaterialCachePCM::set_texture_flags(const int flags) {
_packer->set_texture_flags(flags);
}
int PropMaterialCachePCM2D::get_max_atlas_size() const {
int PropMaterialCachePCM::get_max_atlas_size() const {
return _packer->get_max_atlas_size();
}
void PropMaterialCachePCM2D::set_max_atlas_size(const int size) {
void PropMaterialCachePCM::set_max_atlas_size(const int size) {
_packer->set_max_atlas_size(size);
}
bool PropMaterialCachePCM2D::get_keep_original_atlases() const {
bool PropMaterialCachePCM::get_keep_original_atlases() const {
return _packer->get_keep_original_atlases();
}
void PropMaterialCachePCM2D::set_keep_original_atlases(const bool value) {
void PropMaterialCachePCM::set_keep_original_atlases(const bool value) {
_packer->set_keep_original_atlases(value);
}
Color PropMaterialCachePCM2D::get_background_color() const {
Color PropMaterialCachePCM::get_background_color() const {
return _packer->get_background_color();
}
void PropMaterialCachePCM2D::set_background_color(const Color &color) {
void PropMaterialCachePCM::set_background_color(const Color &color) {
_packer->set_background_color(color);
}
int PropMaterialCachePCM2D::get_margin() const {
int PropMaterialCachePCM::get_margin() const {
return _packer->get_margin();
}
void PropMaterialCachePCM2D::set_margin(const int margin) {
void PropMaterialCachePCM::set_margin(const int margin) {
_packer->set_margin(margin);
}
Ref<AtlasTexture> PropMaterialCachePCM2D::texture_get_atlas_tex(const Ref<Texture> &texture) {
Ref<AtlasTexture> PropMaterialCachePCM::texture_get_atlas_tex(const Ref<Texture> &texture) {
if (!_packer->contains_texture(texture)) {
return Ref<AtlasTexture>();
}
return _packer->get_texture(texture);
}
Rect2 PropMaterialCachePCM2D::texture_get_uv_rect(const Ref<Texture> &texture) {
Rect2 PropMaterialCachePCM::texture_get_uv_rect(const Ref<Texture> &texture) {
if (!texture.is_valid()) {
return Rect2(0, 0, 1, 1);
}
@ -93,8 +93,8 @@ Rect2 PropMaterialCachePCM2D::texture_get_uv_rect(const Ref<Texture> &texture) {
return Rect2(0, 0, 1, 1);
}
float w = image->get_width();
float h = image->get_height();
float w = tex->get_width();
float h = tex->get_height();
region.position = Size2(region.position.x / w, region.position.y / h);
region.size = Size2(region.size.x / w, region.size.y / h);
@ -102,7 +102,7 @@ Rect2 PropMaterialCachePCM2D::texture_get_uv_rect(const Ref<Texture> &texture) {
return region;
}
void PropMaterialCachePCM2D::refresh_rects() {
void PropMaterialCachePCM::refresh_rects() {
bool texture_added = false;
for (int i = 0; i < _textures.size(); i++) {
@ -129,10 +129,10 @@ void PropMaterialCachePCM2D::refresh_rects() {
_initialized = true;
}
void PropMaterialCachePCM2D::initial_setup_default() {
PropMaterialCache2D::initial_setup_default();
void PropMaterialCachePCM::initial_setup_default() {
PropMaterialCache::initial_setup_default();
PropCache2D *pc = PropCache2D::get_singleton();
PropCache *pc = PropCache::get_singleton();
set_texture_flags(pc->get_texture_flags());
set_max_atlas_size(pc->get_max_atlas_size());
@ -141,7 +141,7 @@ void PropMaterialCachePCM2D::initial_setup_default() {
set_margin(pc->get_margin());
}
void PropMaterialCachePCM2D::_setup_material_albedo(Ref<Texture> texture) {
void PropMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
int count = material_get_num();
for (int i = 0; i < count; ++i) {
@ -151,7 +151,7 @@ void PropMaterialCachePCM2D::_setup_material_albedo(Ref<Texture> texture) {
if (spmat.is_valid()) {
spmat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture);
return;
continue;
}
Ref<ShaderMaterial> shmat = m;
@ -162,7 +162,7 @@ void PropMaterialCachePCM2D::_setup_material_albedo(Ref<Texture> texture) {
}
}
PropMaterialCachePCM2D::PropMaterialCachePCM2D() {
PropMaterialCachePCM::PropMaterialCachePCM() {
_packer.instance();
#if GODOT4
@ -176,31 +176,31 @@ PropMaterialCachePCM2D::PropMaterialCachePCM2D() {
_packer->set_margin(0);
}
PropMaterialCachePCM2D::~PropMaterialCachePCM2D() {
PropMaterialCachePCM::~PropMaterialCachePCM() {
_packer->clear();
_packer.unref();
}
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);
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);
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"), &PropMaterialCachePCM2D::get_max_atlas_size);
ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropMaterialCachePCM2D::set_max_atlas_size);
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);
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"), &PropMaterialCachePCM2D::get_keep_original_atlases);
ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropMaterialCachePCM2D::set_keep_original_atlases);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color");
ClassDB::bind_method(D_METHOD("get_margin"), &PropMaterialCachePCM2D::get_margin);
ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropMaterialCachePCM2D::set_margin);
ClassDB::bind_method(D_METHOD("get_margin"), &PropMaterialCachePCM::get_margin);
ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropMaterialCachePCM::set_margin);
ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin");
ClassDB::bind_method(D_METHOD("_setup_material_albedo", "texture"), &PropMaterialCachePCM2D::_setup_material_albedo);
ClassDB::bind_method(D_METHOD("_setup_material_albedo", "texture"), &PropMaterialCachePCM::_setup_material_albedo);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_MATERIAL_CACHE_PCM_2D_H
#define PROP_MATERIAL_CACHE_PCM_2D_H
#ifndef PROP_MATERIAL_CACHE_PCM_H
#define PROP_MATERIAL_CACHE_PCM_H
#include "prop_material_cache_2d.h"
#include "prop_material_cache.h"
#include "core/version.h"
@ -43,8 +43,8 @@ SOFTWARE.
class TexturePacker;
class PropData;
class PropMaterialCachePCM2D : public PropMaterialCache2D {
GDCLASS(PropMaterialCachePCM2D, PropMaterialCache2D);
class PropMaterialCachePCM : public PropMaterialCache {
GDCLASS(PropMaterialCachePCM, PropMaterialCache);
public:
int get_texture_flags() const;
@ -71,8 +71,8 @@ public:
void _setup_material_albedo(Ref<Texture> texture);
PropMaterialCachePCM2D();
~PropMaterialCachePCM2D();
PropMaterialCachePCM();
~PropMaterialCachePCM();
protected:
static void _bind_methods();

9
prop_ess_entity.cpp Normal file
View File

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

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2020 Péter Magyar
Copyright (c) 2020-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_ESS_ENTITY_2D_H
#define PROP_ESS_ENTITY_2D_H
#ifndef PROP_ESS_ENTITY_H
#define PROP_ESS_ENTITY_H
#include "core/version.h"
@ -35,13 +35,13 @@ SOFTWARE.
#include "core/math/vector3.h"
class PropESSEntity2D : public Spatial {
GDCLASS(PropESSEntity2D, Spatial);
class PropESSEntity : public Spatial {
GDCLASS(PropESSEntity, Spatial);
OBJ_CATEGORY("Props");
public:
PropESSEntity2D();
~PropESSEntity2D();
PropESSEntity();
~PropESSEntity();
protected:
static void _bind_methods();

View File

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

View File

@ -1,4 +1,4 @@
#include "prop_instance_2d.h"
#include "prop_instance.h"
#include "../mesh_data_resource/nodes/mesh_data_instance.h"
@ -15,23 +15,23 @@
#if MESH_DATA_RESOURCE_PRESENT
//define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling,
//but not when included from here.
#define PROPS_PRESENT 1
#include "../mesh_data_resource/props/prop_data_mesh_data.h"
#define PROPS_2D_PRESENT 1
#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h"
#endif
#include "./props/prop_data_entry_2d.h"
#include "./props/prop_data_light_2d.h"
#include "./props/prop_data_prop_2d.h"
#include "./props/prop_data_scene_2d.h"
#include "./props/prop_data_tiled_wall_2d.h"
#include "./props/prop_data_entry.h"
#include "./props/prop_data_light.h"
#include "./props/prop_data_prop.h"
#include "./props/prop_data_scene.h"
#include "./props/prop_data_tiled_wall.h"
#include "tiled_wall/tiled_wall_2d.h"
#include "tiled_wall/tiled_wall_data_2d.h"
#include "tiled_wall/tiled_wall.h"
#include "tiled_wall/tiled_wall_data.h"
Ref<PropData2D> PropInstance2D::get_prop_data() {
Ref<PropData> PropInstance::get_prop_data() {
return _prop_data;
}
void PropInstance2D::set_prop_data(const Ref<PropData2D> &data) {
void PropInstance::set_prop_data(const Ref<PropData> &data) {
if (_prop_data == data)
return;
@ -44,58 +44,58 @@ void PropInstance2D::set_prop_data(const Ref<PropData2D> &data) {
}
}
Ref<Material> PropInstance2D::get_material() {
Ref<Material> PropInstance::get_material() {
return _material;
}
void PropInstance2D::set_material(const Ref<Material> &material) {
void PropInstance::set_material(const Ref<Material> &material) {
_material = material;
}
uint32_t PropInstance2D::get_collision_layer() const {
uint32_t PropInstance::get_collision_layer() const {
return _collision_layer;
}
void PropInstance2D::set_collision_layer(uint32_t p_layer) {
void PropInstance::set_collision_layer(uint32_t p_layer) {
_collision_layer = p_layer;
collision_layer_changed();
}
uint32_t PropInstance2D::get_collision_mask() const {
uint32_t PropInstance::get_collision_mask() const {
return _collision_mask;
}
void PropInstance2D::set_collision_mask(uint32_t p_mask) {
void PropInstance::set_collision_mask(uint32_t p_mask) {
_collision_mask = p_mask;
collision_mask_changed();
}
void PropInstance2D::collision_layer_changed() {
void PropInstance::collision_layer_changed() {
}
void PropInstance2D::collision_mask_changed() {
void PropInstance::collision_mask_changed() {
}
void PropInstance2D::init_materials() {
void PropInstance::init_materials() {
call("_init_materials");
}
void PropInstance2D::_init_materials() {
void PropInstance::_init_materials() {
}
void PropInstance2D::build() {
void PropInstance::build() {
call("_build");
}
void PropInstance2D::queue_build() {
void PropInstance::queue_build() {
_build_queued = true;
}
void PropInstance2D::build_finished() {
void PropInstance::build_finished() {
call("_build_finished");
}
void PropInstance2D::_build() {
void PropInstance::_build() {
_building = true;
_build_queued = false;
@ -118,7 +118,7 @@ void PropInstance2D::_build() {
prop_preprocess(Transform(), _prop_data);
}
void PropInstance2D::_build_finished() {
void PropInstance::_build_finished() {
_building = false;
if (_build_queued) {
@ -126,28 +126,28 @@ void PropInstance2D::_build_finished() {
}
}
void PropInstance2D::prop_preprocess(Transform transform, const Ref<PropData2D> &prop) {
void PropInstance::prop_preprocess(Transform transform, const Ref<PropData> &prop) {
call("_prop_preprocess", transform, prop);
}
void PropInstance2D::_prop_preprocess(Transform transform, const Ref<PropData2D> &prop) {
void PropInstance::_prop_preprocess(Transform transform, const Ref<PropData> &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<PropDataEntry2D> e = prop->get_prop(i);
Ref<PropDataEntry> e = prop->get_prop(i);
if (!e.is_valid())
continue;
Transform t = transform * e->get_transform();
Ref<PropDataProp2D> prop_entry_data = e;
Ref<PropDataProp> prop_entry_data = e;
if (prop_entry_data.is_valid()) {
Ref<PropData2D> p = prop_entry_data->get_prop();
Ref<PropData> p = prop_entry_data->get_prop();
if (!p.is_valid())
continue;
@ -157,10 +157,10 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref<PropData2D>
continue;
}
Ref<PropDataTiledWall2D> tiled_wall_data = e;
Ref<PropDataTiledWall> tiled_wall_data = e;
if (tiled_wall_data.is_valid()) {
TiledWall2D *twn = memnew(TiledWall2D);
TiledWall *twn = memnew(TiledWall);
twn->set_width(tiled_wall_data->get_width());
twn->set_heigth(tiled_wall_data->get_heigth());
@ -174,7 +174,7 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref<PropData2D>
continue;
}
Ref<PropDataScene2D> scene_data = e;
Ref<PropDataScene> scene_data = e;
if (scene_data.is_valid()) {
Ref<PackedScene> sc = scene_data->get_scene();
@ -194,7 +194,7 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref<PropData2D>
continue;
}
Ref<PropDataLight2D> light_data = e;
Ref<PropDataLight> light_data = e;
if (light_data.is_valid()) {
OmniLight *light = memnew(OmniLight);
@ -207,7 +207,7 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref<PropData2D>
}
#if MESH_DATA_RESOURCE_PRESENT
Ref<PropDataMeshData2D> mesh_data = e;
Ref<Prop2DDataMeshData> mesh_data = e;
if (mesh_data.is_valid()) {
Ref<MeshDataResource> mdr = mesh_data->get_mesh();
@ -251,7 +251,7 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref<PropData2D>
}
}
PropInstance2D::PropInstance2D() {
PropInstance::PropInstance() {
_build_queued = false;
_building = false;
@ -259,11 +259,11 @@ PropInstance2D::PropInstance2D() {
_collision_mask = 1;
}
PropInstance2D::~PropInstance2D() {
PropInstance::~PropInstance() {
_prop_data.unref();
}
void PropInstance2D::_notification(int p_what) {
void PropInstance::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (_prop_data.is_valid()) {
@ -275,20 +275,20 @@ void PropInstance2D::_notification(int p_what) {
}
}
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");
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");
ClassDB::bind_method(D_METHOD("get_material"), &PropInstance2D::get_material);
ClassDB::bind_method(D_METHOD("set_material", "material"), &PropInstance2D::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &PropInstance::get_material);
ClassDB::bind_method(D_METHOD("set_material", "material"), &PropInstance::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"), &PropInstance2D::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PropInstance2D::set_collision_layer);
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_mask"), &PropInstance2D::get_collision_mask);
ClassDB::bind_method(D_METHOD("set_collision_mask", "layer"), &PropInstance2D::set_collision_mask);
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);
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 PropInstance2D::_bind_methods() {
BIND_VMETHOD(MethodInfo("_prop_preprocess",
PropertyInfo(Variant::TRANSFORM, "tarnsform"),
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D")));
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance2D::prop_preprocess);
ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance2D::_prop_preprocess);
ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance::prop_preprocess);
ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance::_prop_preprocess);
//---
BIND_VMETHOD(MethodInfo("_init_materials"));
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("init_materials"), &PropInstance::init_materials);
ClassDB::bind_method(D_METHOD("_init_materials"), &PropInstance::_init_materials);
//---
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);
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);
BIND_VMETHOD(MethodInfo("_build"));
BIND_VMETHOD(MethodInfo("_build_finished"));
ClassDB::bind_method(D_METHOD("_build"), &PropInstance2D::_build);
ClassDB::bind_method(D_METHOD("_build_finished"), &PropInstance2D::_build_finished);
ClassDB::bind_method(D_METHOD("_build"), &PropInstance::_build);
ClassDB::bind_method(D_METHOD("_build_finished"), &PropInstance::_build_finished);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2020 Péter Magyar
Copyright (c) 2020-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_INSTANCE_2D_H
#define PROP_INSTANCE_2D_H
#ifndef PROP_INSTANCE_H
#define PROP_INSTANCE_H
#include "core/version.h"
@ -37,14 +37,14 @@ SOFTWARE.
#include "core/math/vector3.h"
#include "props/prop_data_2d.h"
#include "props/prop_data.h"
class PropInstance2D : public Spatial {
GDCLASS(PropInstance2D, Spatial);
class PropInstance : public Spatial {
GDCLASS(PropInstance, Spatial);
public:
Ref<PropData2D> get_prop_data();
void set_prop_data(const Ref<PropData2D> &data);
Ref<PropData> get_prop_data();
void set_prop_data(const Ref<PropData> &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<PropData2D> &prop);
virtual void _prop_preprocess(Transform tarnsform, const Ref<PropData2D> &prop);
void prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
virtual void _prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
PropInstance2D();
~PropInstance2D();
PropInstance();
~PropInstance();
protected:
void _notification(int p_what);
static void _bind_methods();
protected:
Ref<PropData2D> _prop_data;
Ref<PropData> _prop_data;
Ref<Material> _material;
uint32_t _collision_layer;

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,55 +20,55 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_instance_job_2d.h"
#include "prop_instance_job.h"
#include "prop_instance_2d.h"
#include "prop_instance.h"
#include "./props/prop_data_2d.h"
#include "./props/prop_data.h"
#include "../opensimplex/open_simplex_noise.h"
const String PropInstanceJob2D::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process";
const String PropInstanceJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process";
PropInstanceJob2D::ActiveBuildPhaseType PropInstanceJob2D::get_build_phase_type() {
PropInstanceJob::ActiveBuildPhaseType PropInstanceJob::get_build_phase_type() {
return _build_phase_type;
}
void PropInstanceJob2D::set_build_phase_type(PropInstanceJob2D::ActiveBuildPhaseType build_phase_type) {
void PropInstanceJob::set_build_phase_type(PropInstanceJob::ActiveBuildPhaseType build_phase_type) {
_build_phase_type = build_phase_type;
}
void PropInstanceJob2D::set_prop(const Ref<PropData2D> &prop) {
void PropInstanceJob::set_prop(const Ref<PropData> &prop) {
_prop = prop;
_in_tree = true;
}
void PropInstanceJob2D::set_prop_instance(PropInstance2D *instance) {
void PropInstanceJob::set_prop_instance(PropInstance *instance) {
_instance = instance;
}
void PropInstanceJob2D::set_prop_instance_bind(Node *instance) {
set_prop_instance(Object::cast_to<PropInstance2D>(instance));
void PropInstanceJob::set_prop_instance_bind(Node *instance) {
set_prop_instance(Object::cast_to<PropInstance>(instance));
}
int PropInstanceJob2D::get_phase() {
int PropInstanceJob::get_phase() {
return _phase;
}
void PropInstanceJob2D::set_phase(const int phase) {
void PropInstanceJob::set_phase(const int phase) {
_phase = phase;
}
void PropInstanceJob2D::next_phase() {
void PropInstanceJob::next_phase() {
++_phase;
}
bool PropInstanceJob2D::get_build_done() {
bool PropInstanceJob::get_build_done() {
return _build_done;
}
void PropInstanceJob2D::set_build_done(const bool val) {
void PropInstanceJob::set_build_done(const bool val) {
_build_done = val;
}
void PropInstanceJob2D::finished() {
void PropInstanceJob::finished() {
set_build_done(true);
if (_instance) {
@ -76,15 +76,15 @@ void PropInstanceJob2D::finished() {
}
}
void PropInstanceJob2D::reset() {
void PropInstanceJob::reset() {
call("_reset");
}
void PropInstanceJob2D::_reset() {
void PropInstanceJob::_reset() {
_build_done = false;
_phase = 0;
}
void PropInstanceJob2D::_execute() {
void PropInstanceJob::_execute() {
ActiveBuildPhaseType origpt = _build_phase_type;
while (!get_cancelled() && _in_tree && !_build_done && origpt == _build_phase_type && !should_return()) {
@ -92,28 +92,28 @@ void PropInstanceJob2D::_execute() {
}
}
void PropInstanceJob2D::execute_phase() {
void PropInstanceJob::execute_phase() {
call("_execute_phase");
}
void PropInstanceJob2D::_execute_phase() {
void PropInstanceJob::_execute_phase() {
finished();
}
void PropInstanceJob2D::process(const float delta) {
void PropInstanceJob::process(const float delta) {
if (has_method("_process"))
call("_process", delta);
}
void PropInstanceJob2D::physics_process(const float delta) {
void PropInstanceJob::physics_process(const float delta) {
if (has_method("_physics_process"))
call("_physics_process", delta);
}
void PropInstanceJob2D::prop_instance_enter_tree() {
void PropInstanceJob::prop_instance_enter_tree() {
_in_tree = true;
}
void PropInstanceJob2D::prop_instance_exit_tree() {
void PropInstanceJob::prop_instance_exit_tree() {
_in_tree = false;
if (get_complete()) {
@ -123,7 +123,7 @@ void PropInstanceJob2D::prop_instance_exit_tree() {
}
}
PropInstanceJob2D::PropInstanceJob2D() {
PropInstanceJob::PropInstanceJob() {
_instance = NULL;
_in_tree = false;
@ -143,137 +143,137 @@ PropInstanceJob2D::PropInstanceJob2D() {
#endif
}
PropInstanceJob2D::~PropInstanceJob2D() {
PropInstanceJob::~PropInstanceJob() {
_prop.unref();
_instance = NULL;
}
void PropInstanceJob2D::_bind_methods() {
void PropInstanceJob::_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"), &PropInstanceJob2D::get_build_phase_type);
ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &PropInstanceJob2D::set_build_phase_type);
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);
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"), &PropInstanceJob2D::set_prop);
ClassDB::bind_method(D_METHOD("set_prop_instance", "instance"), &PropInstanceJob2D::set_prop_instance_bind);
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("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_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_build_done"), &PropInstanceJob2D::get_build_done);
ClassDB::bind_method(D_METHOD("set_build_done", "val"), &PropInstanceJob2D::set_build_done);
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("finished"), &PropInstanceJob2D::finished);
ClassDB::bind_method(D_METHOD("finished"), &PropInstanceJob::finished);
BIND_VMETHOD(MethodInfo("_reset"));
ClassDB::bind_method(D_METHOD("reset"), &PropInstanceJob2D::reset);
ClassDB::bind_method(D_METHOD("_reset"), &PropInstanceJob2D::_reset);
ClassDB::bind_method(D_METHOD("reset"), &PropInstanceJob::reset);
ClassDB::bind_method(D_METHOD("_reset"), &PropInstanceJob::_reset);
ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob2D::_execute);
ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob::_execute);
BIND_VMETHOD(MethodInfo("_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("execute_phase"), &PropInstanceJob::execute_phase);
ClassDB::bind_method(D_METHOD("_execute_phase"), &PropInstanceJob::_execute_phase);
ClassDB::bind_method(D_METHOD("prop_instance_exit_tree"), &PropInstanceJob2D::prop_instance_exit_tree);
ClassDB::bind_method(D_METHOD("prop_instance_exit_tree"), &PropInstanceJob::prop_instance_exit_tree);
#if !THREAD_POOL_PRESENT
ClassDB::bind_method(D_METHOD("get_complete"), &PropInstanceJob2D::get_complete);
ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropInstanceJob2D::set_complete);
ClassDB::bind_method(D_METHOD("get_complete"), &PropInstanceJob::get_complete);
ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropInstanceJob::set_complete);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage");
ClassDB::bind_method(D_METHOD("get_stage"), &PropInstanceJob2D::get_stage);
ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropInstanceJob2D::set_stage);
ClassDB::bind_method(D_METHOD("get_stage"), &PropInstanceJob::get_stage);
ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropInstanceJob::set_stage);
ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage");
ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropInstanceJob2D::get_current_execution_time);
ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropInstanceJob::get_current_execution_time);
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob2D::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob2D::should_return);
ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob::should_do, DEFVAL(false));
ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob::should_return);
BIND_VMETHOD(MethodInfo("_execute"));
ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob2D::execute);
ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob::execute);
ADD_SIGNAL(MethodInfo("completed"));
#endif
}
#if !THREAD_POOL_PRESENT
bool PropInstanceJob2D::get_complete() const {
bool PropInstanceJob::get_complete() const {
return _complete;
}
void PropInstanceJob2D::set_complete(const bool value) {
void PropInstanceJob::set_complete(const bool value) {
_complete = value;
}
bool PropInstanceJob2D::get_cancelled() const {
bool PropInstanceJob::get_cancelled() const {
return _cancelled;
}
void PropInstanceJob2D::set_cancelled(const bool value) {
void PropInstanceJob::set_cancelled(const bool value) {
_cancelled = value;
}
float PropInstanceJob2D::get_max_allocated_time() const {
float PropInstanceJob::get_max_allocated_time() const {
return _max_allocated_time;
}
void PropInstanceJob2D::set_max_allocated_time(const float value) {
void PropInstanceJob::set_max_allocated_time(const float value) {
_max_allocated_time = value;
}
int PropInstanceJob2D::get_start_time() const {
int PropInstanceJob::get_start_time() const {
return _start_time;
}
void PropInstanceJob2D::set_start_time(const int value) {
void PropInstanceJob::set_start_time(const int value) {
_start_time = value;
}
int PropInstanceJob2D::get_current_run_stage() const {
int PropInstanceJob::get_current_run_stage() const {
return _current_run_stage;
}
void PropInstanceJob2D::set_current_run_stage(const int value) {
void PropInstanceJob::set_current_run_stage(const int value) {
_current_run_stage = value;
}
int PropInstanceJob2D::get_stage() const {
int PropInstanceJob::get_stage() const {
return _stage;
}
void PropInstanceJob2D::set_stage(const int value) {
void PropInstanceJob::set_stage(const int value) {
_stage = value;
}
void PropInstanceJob2D::reset_stages() {
void PropInstanceJob::reset_stages() {
_current_run_stage = 0;
_stage = 0;
}
float PropInstanceJob2D::get_current_execution_time() {
float PropInstanceJob::get_current_execution_time() {
return 0;
}
bool PropInstanceJob2D::should_do(const bool just_check) {
bool PropInstanceJob::should_do(const bool just_check) {
return true;
}
bool PropInstanceJob2D::should_return() {
bool PropInstanceJob::should_return() {
if (_cancelled)
return true;
return false;
}
void PropInstanceJob2D::execute() {
void PropInstanceJob::execute() {
ERR_FAIL_COND(!has_method("_execute"));
call("_execute");

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_INSTANCE_2D_JOB
#define PROP_INSTANCE_2D_JOB
#ifndef PROP_INSTANCE_JOB
#define PROP_INSTANCE_JOB
#include "scene/resources/texture.h"
@ -40,15 +40,15 @@ SOFTWARE.
#endif
class PropData2D;
class PropInstance2D;
class PropData;
class PropInstance;
#if THREAD_POOL_PRESENT
class PropInstanceJob2D : public ThreadPoolJob {
GDCLASS(PropInstanceJob2D, ThreadPoolJob);
class PropInstanceJob : public ThreadPoolJob {
GDCLASS(PropInstanceJob, ThreadPoolJob);
#else
class PropInstanceJob2D : public Reference {
GDCLASS(PropInstanceJob2D, Reference);
class PropInstanceJob : public Reference {
GDCLASS(PropInstanceJob, Reference);
#endif
public:
@ -62,10 +62,10 @@ public:
public:
ActiveBuildPhaseType get_build_phase_type();
void set_build_phase_type(PropInstanceJob2D::ActiveBuildPhaseType build_phase_type);
void set_build_phase_type(PropInstanceJob::ActiveBuildPhaseType build_phase_type);
void set_prop(const Ref<PropData2D> &prop);
void set_prop_instance(PropInstance2D *instance);
void set_prop(const Ref<PropData> &prop);
void set_prop_instance(PropInstance *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();
PropInstanceJob2D();
~PropInstanceJob2D();
PropInstanceJob();
~PropInstanceJob();
protected:
static void _bind_methods();
@ -101,8 +101,8 @@ protected:
bool _build_done;
int _phase;
bool _in_tree;
Ref<PropData2D> _prop;
PropInstance2D *_instance;
Ref<PropData> _prop;
PropInstance *_instance;
public:
#if !THREAD_POOL_PRESENT
@ -145,6 +145,6 @@ private:
#endif
};
VARIANT_ENUM_CAST(PropInstanceJob2D::ActiveBuildPhaseType);
VARIANT_ENUM_CAST(PropInstanceJob::ActiveBuildPhaseType);
#endif

View File

@ -1,4 +1,4 @@
#include "prop_instance_merger_2d.h"
#include "prop_instance_merger.h"
#include "../mesh_data_resource/nodes/mesh_data_instance.h"
@ -40,39 +40,39 @@ typedef class RenderingServer VS;
#if MESH_DATA_RESOURCE_PRESENT
//define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling,
//but not when included from here.
#define PROPS_PRESENT 1
#include "../mesh_data_resource/props/prop_data_mesh_data.h"
#define PROPS_2D_PRESENT 1
#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h"
#endif
#include "./props/prop_data_entry_2d.h"
#include "./props/prop_data_light_2d.h"
#include "./props/prop_data_prop_2d.h"
#include "./props/prop_data_scene_2d.h"
#include "jobs/prop_mesher_job_step_2d.h"
#include "lights/prop_light_2d.h"
#include "material_cache/prop_material_cache_2d.h"
#include "./props/prop_data_entry.h"
#include "./props/prop_data_light.h"
#include "./props/prop_data_prop.h"
#include "./props/prop_data_scene.h"
#include "jobs/prop_mesher_job_step.h"
#include "lights/prop_light.h"
#include "material_cache/prop_material_cache.h"
#include "scene/3d/camera.h"
#if TEXTURE_PACKER_PRESENT
#include "./singleton/prop_cache_2d.h"
#include "./singleton/prop_cache.h"
#endif
#if THREAD_POOL_PRESENT
#include "../thread_pool/thread_pool.h"
#endif
#include "./props/prop_data_tiled_wall_2d.h"
#include "./props/prop_data_tiled_wall.h"
#include "tiled_wall/tiled_wall_data_2d.h"
#include "tiled_wall/tiled_wall_data.h"
#include "scene/resources/box_shape.h"
const float PropInstanceMerger2D::LOD_CHECK_INTERVAL = 2;
const float PropInstanceMerger::LOD_CHECK_INTERVAL = 2;
bool PropInstanceMerger2D::get_building() {
bool PropInstanceMerger::get_building() {
return _building;
}
void PropInstanceMerger2D::set_building(const bool value) {
void PropInstanceMerger::set_building(const bool value) {
_building = value;
set_physics_process_internal(_building);
@ -82,10 +82,10 @@ void PropInstanceMerger2D::set_building(const bool value) {
}
}
int PropInstanceMerger2D::get_lod_level() {
int PropInstanceMerger::get_lod_level() {
return _lod_level;
}
void PropInstanceMerger2D::set_lod_level(const int value) {
void PropInstanceMerger::set_lod_level(const int value) {
_lod_level = value;
if (_lod_level < 0) {
@ -95,62 +95,66 @@ void PropInstanceMerger2D::set_lod_level(const int value) {
apply_lod_level();
}
bool PropInstanceMerger2D::get_auto_lod() {
bool PropInstanceMerger::get_auto_lod() {
return _auto_lod;
}
void PropInstanceMerger2D::set_auto_lod(const bool value) {
void PropInstanceMerger::set_auto_lod(const bool value) {
_auto_lod = value;
check_auto_lod();
}
float PropInstanceMerger2D::get_first_lod_distance_squared() {
float PropInstanceMerger::get_first_lod_distance_squared() {
return _first_lod_distance_squared;
}
void PropInstanceMerger2D::set_first_lod_distance_squared(const float dist) {
void PropInstanceMerger::set_first_lod_distance_squared(const float dist) {
_first_lod_distance_squared = dist;
}
float PropInstanceMerger2D::get_lod_reduction_distance_squared() {
float PropInstanceMerger::get_lod_reduction_distance_squared() {
return _lod_reduction_distance_squared;
}
void PropInstanceMerger2D::set_lod_reduction_distance_squared(const float dist) {
void PropInstanceMerger::set_lod_reduction_distance_squared(const float dist) {
_lod_reduction_distance_squared = dist;
}
Ref<PropInstanceJob2D> PropInstanceMerger2D::get_job() {
Ref<PropInstanceJob> PropInstanceMerger::get_job() {
return _job;
}
void PropInstanceMerger2D::set_job(const Ref<PropInstanceJob2D> &job) {
void PropInstanceMerger::set_job(const Ref<PropInstanceJob> &job) {
_job = job;
if (_job.is_valid() && is_inside_tree()) {
_job->prop_instance_enter_tree();
}
}
//Materials
Ref<Material> PropInstanceMerger2D::material_get(const int index) {
Ref<Material> PropInstanceMerger::material_get(const int index) {
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
return _materials[index];
}
void PropInstanceMerger2D::material_add(const Ref<Material> &value) {
void PropInstanceMerger::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
int PropInstanceMerger2D::material_get_num() const {
int PropInstanceMerger::material_get_num() const {
return _materials.size();
}
void PropInstanceMerger2D::materials_clear() {
void PropInstanceMerger::materials_clear() {
_materials.clear();
}
Vector<Variant> PropInstanceMerger2D::materials_get() {
Vector<Variant> PropInstanceMerger::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void PropInstanceMerger2D::materials_set(const Vector<Variant> &materials) {
void PropInstanceMerger::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
@ -161,19 +165,19 @@ void PropInstanceMerger2D::materials_set(const Vector<Variant> &materials) {
}
//Meshes
RID PropInstanceMerger2D::mesh_get(const int index) {
RID PropInstanceMerger::mesh_get(const int index) {
ERR_FAIL_INDEX_V(index, _meshes.size(), RID());
return _meshes[index].mesh;
}
RID PropInstanceMerger2D::mesh_instance_get(const int index) {
RID PropInstanceMerger::mesh_instance_get(const int index) {
ERR_FAIL_INDEX_V(index, _meshes.size(), RID());
return _meshes[index].mesh_instance;
}
void PropInstanceMerger2D::mesh_add(const RID mesh_instance, const RID mesh) {
void PropInstanceMerger::mesh_add(const RID mesh_instance, const RID mesh) {
MeshEntry e;
e.mesh = mesh;
e.mesh_instance = mesh_instance;
@ -181,15 +185,15 @@ void PropInstanceMerger2D::mesh_add(const RID mesh_instance, const RID mesh) {
_meshes.push_back(e);
}
int PropInstanceMerger2D::mesh_get_num() const {
int PropInstanceMerger::mesh_get_num() const {
return _meshes.size();
}
void PropInstanceMerger2D::meshes_clear() {
void PropInstanceMerger::meshes_clear() {
_meshes.clear();
}
void PropInstanceMerger2D::meshes_create(const int num) {
void PropInstanceMerger::meshes_create(const int num) {
free_meshes();
for (int i = 0; i < num; ++i) {
@ -216,7 +220,7 @@ void PropInstanceMerger2D::meshes_create(const int num) {
apply_lod_level();
}
Vector<Variant> PropInstanceMerger2D::meshes_get() {
Vector<Variant> PropInstanceMerger::meshes_get() {
Vector<Variant> r;
for (int i = 0; i < _meshes.size(); i++) {
Array a;
@ -229,7 +233,7 @@ Vector<Variant> PropInstanceMerger2D::meshes_get() {
return r;
}
void PropInstanceMerger2D::meshes_set(const Vector<Variant> &meshs) {
void PropInstanceMerger::meshes_set(const Vector<Variant> &meshs) {
_meshes.clear();
for (int i = 0; i < _meshes.size(); i++) {
@ -247,31 +251,31 @@ void PropInstanceMerger2D::meshes_set(const Vector<Variant> &meshs) {
//Collider
Transform PropInstanceMerger2D::collider_local_transform_get(const int index) {
Transform PropInstanceMerger::collider_local_transform_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), Transform());
return _colliders[index].transform;
}
RID PropInstanceMerger2D::collider_body_get(const int index) {
RID PropInstanceMerger::collider_body_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), RID());
return _colliders[index].body;
}
Ref<Shape> PropInstanceMerger2D::collider_shape_get(const int index) {
Ref<Shape> PropInstanceMerger::collider_shape_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), Ref<Shape>());
return _colliders[index].shape;
}
RID PropInstanceMerger2D::collider_shape_rid_get(const int index) {
RID PropInstanceMerger::collider_shape_rid_get(const int index) {
ERR_FAIL_INDEX_V(index, _colliders.size(), RID());
return _colliders[index].shape_rid;
}
int PropInstanceMerger2D::collider_add(const Transform &local_transform, const Ref<Shape> &shape, const RID &shape_rid, const RID &body, const bool owns_shape) {
int PropInstanceMerger::collider_add(const Transform &local_transform, const Ref<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 +292,15 @@ int PropInstanceMerger2D::collider_add(const Transform &local_transform, const R
return index;
}
int PropInstanceMerger2D::collider_get_num() const {
int PropInstanceMerger::collider_get_num() const {
return _colliders.size();
}
void PropInstanceMerger2D::colliders_clear() {
void PropInstanceMerger::colliders_clear() {
_colliders.clear();
}
Vector<Variant> PropInstanceMerger2D::colliders_get() {
Vector<Variant> PropInstanceMerger::colliders_get() {
Vector<Variant> r;
for (int i = 0; i < _colliders.size(); i++) {
r.push_back(_colliders[i].body);
@ -304,7 +308,7 @@ Vector<Variant> PropInstanceMerger2D::colliders_get() {
return r;
}
void PropInstanceMerger2D::colliders_set(const Vector<Variant> &colliders) {
void PropInstanceMerger::colliders_set(const Vector<Variant> &colliders) {
_colliders.clear();
for (int i = 0; i < colliders.size(); i++) {
@ -317,7 +321,7 @@ void PropInstanceMerger2D::colliders_set(const Vector<Variant> &colliders) {
}
}
void PropInstanceMerger2D::check_auto_lod() {
void PropInstanceMerger::check_auto_lod() {
if (!_auto_lod) {
_auto_lod_on = false;
return;
@ -337,7 +341,7 @@ void PropInstanceMerger2D::check_auto_lod() {
set_process_internal(true);
}
void PropInstanceMerger2D::apply_lod_level() {
void PropInstanceMerger::apply_lod_level() {
if (_meshes.size() == 0) {
return;
}
@ -377,7 +381,7 @@ void PropInstanceMerger2D::apply_lod_level() {
vs->instance_set_visible(mi, true);
}
void PropInstanceMerger2D::debug_mesh_allocate() {
void PropInstanceMerger::debug_mesh_allocate() {
if (_debug_mesh_rid == RID()) {
_debug_mesh_rid = VisualServer::get_singleton()->mesh_create();
}
@ -393,7 +397,7 @@ void PropInstanceMerger2D::debug_mesh_allocate() {
VS::get_singleton()->instance_set_visible(_debug_mesh_instance, true);
}
}
void PropInstanceMerger2D::debug_mesh_free() {
void PropInstanceMerger::debug_mesh_free() {
if (_debug_mesh_instance != RID()) {
VisualServer::get_singleton()->free(_debug_mesh_instance);
}
@ -402,25 +406,25 @@ void PropInstanceMerger2D::debug_mesh_free() {
VisualServer::get_singleton()->free(_debug_mesh_rid);
}
}
bool PropInstanceMerger2D::debug_mesh_has() {
bool PropInstanceMerger::debug_mesh_has() {
return _debug_mesh_rid != RID();
}
void PropInstanceMerger2D::debug_mesh_clear() {
void PropInstanceMerger::debug_mesh_clear() {
if (_debug_mesh_rid != RID()) {
VisualServer::get_singleton()->mesh_clear(_debug_mesh_rid);
}
}
void PropInstanceMerger2D::debug_mesh_array_clear() {
void PropInstanceMerger::debug_mesh_array_clear() {
_debug_mesh_array.resize(0);
}
void PropInstanceMerger2D::debug_mesh_add_vertices_to(const PoolVector3Array &arr) {
void PropInstanceMerger::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 PropInstanceMerger2D::debug_mesh_send() {
void PropInstanceMerger::debug_mesh_send() {
debug_mesh_allocate();
debug_mesh_clear();
@ -442,7 +446,7 @@ void PropInstanceMerger2D::debug_mesh_send() {
debug_mesh_array_clear();
}
void PropInstanceMerger2D::draw_debug_mdr_colliders() {
void PropInstanceMerger::draw_debug_mdr_colliders() {
if (!debug_mesh_has()) {
debug_mesh_allocate();
}
@ -462,7 +466,7 @@ void PropInstanceMerger2D::draw_debug_mdr_colliders() {
debug_mesh_send();
}
void PropInstanceMerger2D::free_meshes() {
void PropInstanceMerger::free_meshes() {
RID rid;
for (int i = 0; i < _meshes.size(); ++i) {
@ -481,7 +485,7 @@ void PropInstanceMerger2D::free_meshes() {
}
}
void PropInstanceMerger2D::free_colliders() {
void PropInstanceMerger::free_colliders() {
for (int i = 0; i < _colliders.size(); ++i) {
ColliderBody &e = _colliders.write[i];
@ -496,10 +500,10 @@ void PropInstanceMerger2D::free_colliders() {
}
}
void PropInstanceMerger2D::_init_materials() {
void PropInstanceMerger::_init_materials() {
}
void PropInstanceMerger2D::_build() {
void PropInstanceMerger::_build() {
if (_building) {
return;
}
@ -540,8 +544,9 @@ void PropInstanceMerger2D::_build() {
_job->reset();
_job->set_complete(false);
_job->set_cancelled(false);
Ref<PropMaterialCache2D> cache = PropCache2D::get_singleton()->material_cache_get(_prop_data);
Ref<PropMaterialCache> cache = PropCache::get_singleton()->material_cache_get(_prop_data);
if (cache->material_get_num() == 0) {
//lock it!
@ -574,7 +579,7 @@ Don't submit here, as it starts in physics process mode
*/
}
void PropInstanceMerger2D::_build_finished() {
void PropInstanceMerger::_build_finished() {
set_building(false);
apply_lod_level();
@ -587,22 +592,22 @@ void PropInstanceMerger2D::_build_finished() {
}
}
void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref<PropData2D> &prop) {
void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref<PropData> &prop) {
ERR_FAIL_COND(!prop.is_valid());
int count = prop->get_prop_count();
for (int i = 0; i < count; ++i) {
Ref<PropDataEntry2D> e = prop->get_prop(i);
Ref<PropDataEntry> e = prop->get_prop(i);
if (!e.is_valid())
continue;
Transform t = transform * e->get_transform();
Ref<PropDataProp2D> prop_entry_data = e;
Ref<PropDataProp> prop_entry_data = e;
if (prop_entry_data.is_valid()) {
Ref<PropData2D> p = prop_entry_data->get_prop();
Ref<PropData> p = prop_entry_data->get_prop();
if (!p.is_valid())
continue;
@ -612,7 +617,7 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref<PropD
continue;
}
Ref<PropDataTiledWall2D> tiled_wall_data = e;
Ref<PropDataTiledWall> tiled_wall_data = e;
if (tiled_wall_data.is_valid()) {
_job->add_tiled_wall(tiled_wall_data, t);
@ -636,7 +641,7 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref<PropD
continue;
}
Ref<PropDataScene2D> scene_data = e;
Ref<PropDataScene> scene_data = e;
if (scene_data.is_valid()) {
Ref<PackedScene> sc = scene_data->get_scene();
@ -658,11 +663,11 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref<PropD
}
//Will create a Terralight node, and prop
//PropData2DLight could use standard godot light nodes
Ref<PropDataLight2D> light_data = e;
//PropDataLight could use standard godot light nodes
Ref<PropDataLight> light_data = e;
if (light_data.is_valid()) {
Ref<PropLight2D> light;
Ref<PropLight> light;
light.instance();
Vector3 v = t.xform(Vector3());
@ -677,7 +682,7 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref<PropD
}
#if MESH_DATA_RESOURCE_PRESENT
Ref<PropDataMeshData2D> mesh_data = e;
Ref<Prop2DDataMeshData> mesh_data = e;
if (mesh_data.is_valid()) {
Ref<MeshDataResource> mdr = mesh_data->get_mesh();
@ -695,7 +700,7 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref<PropD
}
}
void PropInstanceMerger2D::collision_layer_changed() {
void PropInstanceMerger::collision_layer_changed() {
for (int i = 0; i < _colliders.size(); ++i) {
const ColliderBody &c = _colliders[i];
@ -704,7 +709,7 @@ void PropInstanceMerger2D::collision_layer_changed() {
}
}
}
void PropInstanceMerger2D::collision_mask_changed() {
void PropInstanceMerger::collision_mask_changed() {
for (int i = 0; i < _colliders.size(); ++i) {
const ColliderBody &c = _colliders[i];
@ -714,7 +719,26 @@ void PropInstanceMerger2D::collision_mask_changed() {
}
}
PropInstanceMerger2D::PropInstanceMerger2D() {
void PropInstanceMerger::_create_job() {
_job = Ref<PropInstancePropJob>(memnew(PropInstancePropJob()));
_job->set_prop_instace(this);
Ref<PropMesherJobStep> js;
js.instance();
js->set_job_type(PropMesherJobStep::TYPE_NORMAL);
_job->add_jobs_step(js);
js.instance();
js->set_job_type(PropMesherJobStep::TYPE_MERGE_VERTS);
_job->add_jobs_step(js);
js.instance();
js->set_job_type(PropMesherJobStep::TYPE_BAKE_TEXTURE);
_job->add_jobs_step(js);
}
PropInstanceMerger::PropInstanceMerger() {
_build_queued = false;
_auto_lod = true;
_auto_lod_on = false;
@ -729,39 +753,32 @@ PropInstanceMerger2D::PropInstanceMerger2D() {
_first_lod_distance_squared = 1000;
_lod_reduction_distance_squared = 600;
//todo this should probably be in a virtual method, like in Terraman or Voxelman
_job = Ref<PropInstancePropJob2D>(memnew(PropInstancePropJob2D()));
_job->set_prop_instace(this);
Ref<PropMesherJobStep2D> js;
js.instance();
js->set_job_type(PropMesherJobStep2D::TYPE_NORMAL);
_job->add_jobs_step(js);
js.instance();
js->set_job_type(PropMesherJobStep2D::TYPE_MERGE_VERTS);
_job->add_jobs_step(js);
js.instance();
js->set_job_type(PropMesherJobStep2D::TYPE_BAKE_TEXTURE);
_job->add_jobs_step(js);
}
PropInstanceMerger2D::~PropInstanceMerger2D() {
PropInstanceMerger::~PropInstanceMerger() {
_job.unref();
_prop_data.unref();
_materials.clear();
free_meshes();
free_colliders();
meshes_clear();
colliders_clear();
}
void PropInstanceMerger2D::_notification(int p_what) {
void PropInstanceMerger::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_POSTINITIALIZE: {
call("_create_job");
} break;
case NOTIFICATION_ENTER_TREE: {
if (_prop_data.is_valid()) {
if (_job.is_valid()) {
_job->prop_instance_enter_tree();
}
if (_prop_data.is_valid()) {
call_deferred("build");
}
@ -773,8 +790,13 @@ void PropInstanceMerger2D::_notification(int p_what) {
_job->set_cancelled(true);
}
free_meshes();
free_colliders();
if (!_building) {
free_meshes();
free_colliders();
meshes_clear();
colliders_clear();
}
break;
}
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
@ -783,10 +805,10 @@ void PropInstanceMerger2D::_notification(int p_what) {
return;
}
if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_PHYSICS_PROCESS) {
if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_PHYSICS_PROCESS) {
_job->physics_process(get_physics_process_delta_time());
if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_NORMAL) {
if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_NORMAL) {
#if THREAD_POOL_PRESENT
ThreadPool::get_singleton()->add_job(_job);
#else
@ -804,10 +826,10 @@ void PropInstanceMerger2D::_notification(int p_what) {
return;
}
if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_PROCESS) {
if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_PROCESS) {
_job->process(get_process_delta_time());
if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_NORMAL) {
if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_NORMAL) {
#if THREAD_POOL_PRESENT
ThreadPool::get_singleton()->add_job(_job);
#else
@ -909,72 +931,75 @@ void PropInstanceMerger2D::_notification(int p_what) {
}
}
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");
void PropInstanceMerger::_bind_methods() {
BIND_VMETHOD(MethodInfo("_create_job"));
ClassDB::bind_method(D_METHOD("_create_job"), &PropInstanceMerger::_create_job);
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);
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");
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_level"), "set_lod_level", "get_lod_level");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_lod"), "set_auto_lod", "get_auto_lod");
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);
ClassDB::bind_method(D_METHOD("get_first_lod_distance_squared"), &PropInstanceMerger::get_first_lod_distance_squared);
ClassDB::bind_method(D_METHOD("set_first_lod_distance_squared", "value"), &PropInstanceMerger::set_first_lod_distance_squared);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "first_lod_distance_squared"), "set_first_lod_distance_squared", "get_first_lod_distance_squared");
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);
ClassDB::bind_method(D_METHOD("get_lod_reduction_distance_squared"), &PropInstanceMerger::get_lod_reduction_distance_squared);
ClassDB::bind_method(D_METHOD("set_lod_reduction_distance_squared", "value"), &PropInstanceMerger::set_lod_reduction_distance_squared);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "lod_reduction_distance_squared"), "set_lod_reduction_distance_squared", "get_lod_reduction_distance_squared");
///Materials
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("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("materials_get"), &PropInstanceMerger2D::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropInstanceMerger2D::materials_set);
ClassDB::bind_method(D_METHOD("materials_get"), &PropInstanceMerger::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropInstanceMerger::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"), &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("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("meshes_get"), &PropInstanceMerger2D::meshes_get);
ClassDB::bind_method(D_METHOD("meshes_set"), &PropInstanceMerger2D::meshes_set);
ClassDB::bind_method(D_METHOD("meshes_get"), &PropInstanceMerger::meshes_get);
ClassDB::bind_method(D_METHOD("meshes_set"), &PropInstanceMerger::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"), &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);
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);
//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("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("check_auto_lod"), &PropInstanceMerger2D::check_auto_lod);
ClassDB::bind_method(D_METHOD("apply_lod_level"), &PropInstanceMerger2D::apply_lod_level);
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("free_meshes"), &PropInstanceMerger2D::free_meshes);
ClassDB::bind_method(D_METHOD("free_colliders"), &PropInstanceMerger2D::free_colliders);
ClassDB::bind_method(D_METHOD("free_meshes"), &PropInstanceMerger::free_meshes);
ClassDB::bind_method(D_METHOD("free_colliders"), &PropInstanceMerger::free_colliders);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2020 Péter Magyar
Copyright (c) 2020-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_INSTANCE_MERGER_2D_H
#define PROP_INSTANCE_MERGER_2D_H
#ifndef PROP_INSTANCE_MERGER_H
#define PROP_INSTANCE_MERGER_H
#include "prop_instance_2d.h"
#include "prop_instance.h"
#include "core/version.h"
@ -37,14 +37,14 @@ SOFTWARE.
#include "core/math/vector3.h"
#include "prop_instance_prop_job_2d.h"
#include "prop_instance_prop_job.h"
#include "props/prop_data_2d.h"
#include "props/prop_data.h"
class MeshDataInstance;
class PropInstanceMerger2D : public PropInstance2D {
GDCLASS(PropInstanceMerger2D, PropInstance2D);
class PropInstanceMerger : public PropInstance {
GDCLASS(PropInstanceMerger, PropInstance);
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<PropInstanceJob2D> get_job();
void set_job(const Ref<PropInstanceJob2D> &job);
Ref<PropInstanceJob> get_job();
void set_job(const Ref<PropInstanceJob> &job);
///Materials
Ref<Material> material_get(const int index);
@ -120,13 +120,15 @@ public:
virtual void _build();
virtual void _build_finished();
void _prop_preprocess(Transform tarnsform, const Ref<PropData2D> &prop);
void _prop_preprocess(Transform tarnsform, const Ref<PropData> &prop);
void collision_layer_changed();
void collision_mask_changed();
PropInstanceMerger2D();
~PropInstanceMerger2D();
virtual void _create_job();
PropInstanceMerger();
~PropInstanceMerger();
protected:
void _notification(int p_what);
@ -158,7 +160,7 @@ private:
Transform _last_transform;
Ref<PropInstancePropJob2D> _job;
Ref<PropInstancePropJob> _job;
Vector<Ref<Material>> _materials;
Vector<MeshEntry> _meshes;

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_instance_prop_job_2d.h"
#include "prop_instance_prop_job.h"
#include "core/version.h"
@ -30,14 +30,14 @@ SOFTWARE.
#define GET_WORLD get_world
#endif
#include "jobs/prop_mesher_job_step_2d.h"
#include "lights/prop_light_2d.h"
#include "material_cache/prop_material_cache_2d.h"
#include "prop_instance_2d.h"
#include "prop_instance_merger_2d.h"
#include "prop_mesher_2d.h"
#include "jobs/prop_mesher_job_step.h"
#include "lights/prop_light.h"
#include "material_cache/prop_material_cache.h"
#include "prop_instance.h"
#include "prop_instance_merger.h"
#include "prop_mesher.h"
#include "scene/resources/shape.h"
#include "singleton/prop_cache_2d.h"
#include "singleton/prop_cache.h"
#ifdef MESH_DATA_RESOURCE_PRESENT
#include "../mesh_data_resource/mesh_data_resource.h"
@ -54,44 +54,43 @@ SOFTWARE.
#if MESH_DATA_RESOURCE_PRESENT
//define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling,
//but not when included from here.
#define PROPS_PRESENT 1
#include "../mesh_data_resource/props/prop_data_mesh_data.h"
#undef PROPS_PRESENT
#define PROPS_2D_PRESENT 1
#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h"
#endif
#include "props/prop_data_tiled_wall_2d.h"
#include "tiled_wall/tiled_wall_data_2d.h"
#include "props/prop_data_tiled_wall.h"
#include "tiled_wall/tiled_wall_data.h"
Ref<PropMaterialCache2D> PropInstancePropJob2D::get_material_cache() {
Ref<PropMaterialCache> PropInstancePropJob::get_material_cache() {
return _material_cache;
}
void PropInstancePropJob2D::set_material_cache(const Ref<PropMaterialCache2D> &cache) {
void PropInstancePropJob::set_material_cache(const Ref<PropMaterialCache> &cache) {
_material_cache = cache;
}
Ref<PropMesherJobStep2D> PropInstancePropJob2D::get_jobs_step(int index) const {
ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref<PropMesherJobStep2D>());
Ref<PropMesherJobStep> PropInstancePropJob::get_jobs_step(int index) const {
ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref<PropMesherJobStep>());
return _job_steps.get(index);
}
void PropInstancePropJob2D::set_jobs_step(int index, const Ref<PropMesherJobStep2D> &step) {
void PropInstancePropJob::set_jobs_step(int index, const Ref<PropMesherJobStep> &step) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.set(index, step);
}
void PropInstancePropJob2D::remove_jobs_step(const int index) {
void PropInstancePropJob::remove_jobs_step(const int index) {
ERR_FAIL_INDEX(index, _job_steps.size());
_job_steps.remove(index);
}
void PropInstancePropJob2D::add_jobs_step(const Ref<PropMesherJobStep2D> &step) {
void PropInstancePropJob::add_jobs_step(const Ref<PropMesherJobStep> &step) {
_job_steps.push_back(step);
}
int PropInstancePropJob2D::get_jobs_step_count() const {
int PropInstancePropJob::get_jobs_step_count() const {
return _job_steps.size();
}
void PropInstancePropJob2D::add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape) {
void PropInstancePropJob::add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape) {
CollisionShapeEntry e;
e.shape = shape;
@ -100,30 +99,30 @@ void PropInstancePropJob2D::add_collision_shape(const Ref<Shape> &shape, const T
_collision_shapes.push_back(e);
}
void PropInstancePropJob2D::clear_collision_shapes() {
void PropInstancePropJob::clear_collision_shapes() {
_collision_shapes.clear();
}
PropInstanceMerger2D *PropInstancePropJob2D::get_prop_instace() {
PropInstanceMerger *PropInstancePropJob::get_prop_instace() {
return _prop_instace;
}
void PropInstancePropJob2D::set_prop_instace(PropInstanceMerger2D *prop) {
void PropInstancePropJob::set_prop_instace(PropInstanceMerger *prop) {
_prop_instace = prop;
_instance = prop;
}
void PropInstancePropJob2D::set_prop_instace_bind(Node *prop) {
set_prop_instace(Object::cast_to<PropInstanceMerger2D>(prop));
void PropInstancePropJob::set_prop_instace_bind(Node *prop) {
set_prop_instace(Object::cast_to<PropInstanceMerger>(prop));
}
Ref<PropMesher2D> PropInstancePropJob2D::get_prop_mesher() const {
Ref<PropMesher> PropInstancePropJob::get_prop_mesher() const {
return _prop_mesher;
}
void PropInstancePropJob2D::set_prop_mesher(const Ref<PropMesher2D> &mesher) {
void PropInstancePropJob::set_prop_mesher(const Ref<PropMesher> &mesher) {
_prop_mesher = mesher;
}
#if MESH_DATA_RESOURCE_PRESENT
void PropInstancePropJob2D::add_mesh(const Ref<PropDataMeshData2D> &mesh_data, const Transform &base_transform) {
void PropInstancePropJob::add_mesh(const Ref<Prop2DDataMeshData> &mesh_data, const Transform &base_transform) {
PMDREntry e;
e.mesh_data = mesh_data;
e.base_transform = base_transform;
@ -131,12 +130,12 @@ void PropInstancePropJob2D::add_mesh(const Ref<PropDataMeshData2D> &mesh_data, c
_prop_mesh_datas.push_back(e);
}
void PropInstancePropJob2D::clear_meshes() {
void PropInstancePropJob::clear_meshes() {
_prop_mesh_datas.clear();
}
#endif
void PropInstancePropJob2D::add_tiled_wall(const Ref<PropDataTiledWall2D> &data, const Transform &base_transform) {
void PropInstancePropJob::add_tiled_wall(const Ref<PropDataTiledWall> &data, const Transform &base_transform) {
PTWEntry e;
e.data = data;
e.base_transform = base_transform;
@ -144,25 +143,25 @@ void PropInstancePropJob2D::add_tiled_wall(const Ref<PropDataTiledWall2D> &data,
_prop_tiled_wall_datas.push_back(e);
}
void PropInstancePropJob2D::clear_tiled_walls() {
void PropInstancePropJob::clear_tiled_walls() {
_prop_tiled_wall_datas.clear();
}
void PropInstancePropJob2D::add_light(const Ref<PropLight2D> &light) {
void PropInstancePropJob::add_light(const Ref<PropLight> &light) {
_prop_mesher->add_light(light);
}
void PropInstancePropJob2D::clear_lights() {
void PropInstancePropJob::clear_lights() {
_prop_mesher->clear_lights();
}
void PropInstancePropJob2D::_physics_process(float delta) {
void PropInstancePropJob::_physics_process(float delta) {
if (_phase == 0)
phase_physics_process();
}
void PropInstancePropJob2D::_execute_phase() {
void PropInstancePropJob::_execute_phase() {
if (!_material_cache.is_valid()) {
ERR_PRINT("!PropInstancePropJob2D::_execute_phase(): !_material_cache.is_valid()");
ERR_PRINT("!PropInstancePropJob::_execute_phase(): !_material_cache.is_valid()");
//reset_meshes();
set_complete(true); //So threadpool knows it's done
finished();
@ -186,12 +185,12 @@ void PropInstancePropJob2D::_execute_phase() {
} else if (_phase > 3) {
set_complete(true); //So threadpool knows it's done
finished();
ERR_FAIL_MSG("PropInstancePropJob2D: _phase is too high!");
ERR_FAIL_MSG("PropInstancePropJob: _phase is too high!");
}
}
void PropInstancePropJob2D::_reset() {
PropInstanceJob2D::_reset();
void PropInstancePropJob::_reset() {
PropInstanceJob::_reset();
_build_done = false;
_phase = 0;
@ -207,16 +206,13 @@ void PropInstancePropJob2D::_reset() {
_prop_tiled_wall_datas.clear();
#if MESH_DATA_RESOURCE_PRESENT
_prop_mesh_datas.clear();
#endif
clear_collision_shapes();
set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
}
void PropInstancePropJob2D::phase_physics_process() {
void PropInstancePropJob::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 +259,7 @@ void PropInstancePropJob2D::phase_physics_process() {
next_phase();
}
void PropInstancePropJob2D::phase_setup_cache() {
void PropInstancePropJob::phase_setup_cache() {
if (should_do()) {
if (!_material_cache->get_initialized()) {
_material_cache->mutex_lock();
@ -292,19 +288,14 @@ void PropInstancePropJob2D::phase_setup_cache() {
next_phase();
}
void PropInstancePropJob2D::phase_prop() {
void PropInstancePropJob::phase_prop() {
if (!_prop_mesher.is_valid()) {
set_complete(true); //So threadpool knows it's done
return;
}
if (should_do()) {
if (
#if MESH_DATA_RESOURCE_PRESENT
_prop_mesh_datas.size() == 0 &&
#endif
_prop_tiled_wall_datas.size() == 0) {
if (_prop_mesh_datas.size() == 0 && _prop_tiled_wall_datas.size() == 0) {
//reset_meshes();
reset_stages();
set_complete(true); //So threadpool knows it's done
@ -315,7 +306,7 @@ void PropInstancePropJob2D::phase_prop() {
for (int i = 0; i < _prop_mesh_datas.size(); ++i) {
PMDREntry &e = _prop_mesh_datas.write[i];
Ref<PropDataMeshData> pmd = e.mesh_data;
Ref<Prop2DDataMeshData> pmd = e.mesh_data;
Ref<MeshDataResource> mesh = pmd->get_mesh();
Ref<Texture> tex = pmd->get_texture();
@ -330,7 +321,7 @@ void PropInstancePropJob2D::phase_prop() {
for (int i = 0; i < _prop_tiled_wall_datas.size(); ++i) {
PTWEntry &e = _prop_tiled_wall_datas.write[i];
Ref<PropDataTiledWall2D> pdtw = e.data;
Ref<PropDataTiledWall> pdtw = e.data;
//Transform t = pdtw->get_transform();
Transform t = e.base_transform;
@ -352,7 +343,7 @@ void PropInstancePropJob2D::phase_prop() {
}
if (should_do()) {
if ((_prop_mesher->get_build_flags() & PropMesher2D::BUILD_FLAG_USE_LIGHTING) != 0) {
if ((_prop_mesher->get_build_flags() & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) {
_prop_mesher->bake_colors();
}
@ -365,7 +356,7 @@ void PropInstancePropJob2D::phase_prop() {
next_phase();
}
void PropInstancePropJob2D::phase_steps() {
void PropInstancePropJob::phase_steps() {
ERR_FAIL_COND(!_prop_mesher.is_valid());
if (should_return()) {
@ -388,27 +379,27 @@ void PropInstancePropJob2D::phase_steps() {
//first count how many we need
int count = 0;
for (int i = 0; i < _job_steps.size(); ++i) {
Ref<PropMesherJobStep2D> step = _job_steps[i];
Ref<PropMesherJobStep> step = _job_steps[i];
ERR_FAIL_COND(!step.is_valid());
switch (step->get_job_type()) {
case PropMesherJobStep2D::TYPE_NORMAL:
case PropMesherJobStep::TYPE_NORMAL:
++count;
break;
case PropMesherJobStep2D::TYPE_NORMAL_LOD:
case PropMesherJobStep::TYPE_NORMAL_LOD:
++count;
break;
case PropMesherJobStep2D::TYPE_DROP_UV2:
case PropMesherJobStep::TYPE_DROP_UV2:
++count;
break;
case PropMesherJobStep2D::TYPE_MERGE_VERTS:
case PropMesherJobStep::TYPE_MERGE_VERTS:
++count;
break;
case PropMesherJobStep2D::TYPE_BAKE_TEXTURE:
case PropMesherJobStep::TYPE_BAKE_TEXTURE:
++count;
break;
case PropMesherJobStep2D::TYPE_SIMPLIFY_MESH:
case PropMesherJobStep::TYPE_SIMPLIFY_MESH:
#ifdef MESH_UTILS_PRESENT
count += step->get_simplification_steps();
#endif
@ -441,30 +432,30 @@ void PropInstancePropJob2D::phase_steps() {
}
for (; _current_job_step < _job_steps.size();) {
Ref<PropMesherJobStep2D> step = _job_steps[_current_job_step];
Ref<PropMesherJobStep> step = _job_steps[_current_job_step];
ERR_FAIL_COND(!step.is_valid());
switch (step->get_job_type()) {
case PropMesherJobStep2D::TYPE_NORMAL:
case PropMesherJobStep::TYPE_NORMAL:
step_type_normal();
break;
case PropMesherJobStep2D::TYPE_NORMAL_LOD:
case PropMesherJobStep::TYPE_NORMAL_LOD:
step_type_normal_lod();
break;
case PropMesherJobStep2D::TYPE_DROP_UV2:
case PropMesherJobStep::TYPE_DROP_UV2:
step_type_drop_uv2();
break;
case PropMesherJobStep2D::TYPE_MERGE_VERTS:
case PropMesherJobStep::TYPE_MERGE_VERTS:
step_type_merge_verts();
break;
case PropMesherJobStep2D::TYPE_BAKE_TEXTURE:
case PropMesherJobStep::TYPE_BAKE_TEXTURE:
step_type_bake_texture();
break;
case PropMesherJobStep2D::TYPE_SIMPLIFY_MESH:
case PropMesherJobStep::TYPE_SIMPLIFY_MESH:
step_type_simplify_mesh();
break;
case PropMesherJobStep2D::TYPE_OTHER:
case PropMesherJobStep::TYPE_OTHER:
//do nothing
break;
}
@ -482,7 +473,7 @@ void PropInstancePropJob2D::phase_steps() {
finished();
}
void PropInstancePropJob2D::step_type_normal() {
void PropInstancePropJob::step_type_normal() {
//TODO add a lighting generation step
temp_mesh_arr = _prop_mesher->build_mesh();
@ -500,13 +491,13 @@ void PropInstancePropJob2D::step_type_normal() {
++_current_mesh;
}
void PropInstancePropJob2D::step_type_normal_lod() {
void PropInstancePropJob::step_type_normal_lod() {
print_error("Error: step_type_normal_lod doesn't work for TerraPropJobs!");
++_current_mesh;
}
void PropInstancePropJob2D::step_type_drop_uv2() {
void PropInstancePropJob::step_type_drop_uv2() {
RID mesh_rid = _prop_instace->mesh_get(_current_mesh);
temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant();
@ -522,7 +513,7 @@ void PropInstancePropJob2D::step_type_drop_uv2() {
++_current_mesh;
}
void PropInstancePropJob2D::step_type_merge_verts() {
void PropInstancePropJob::step_type_merge_verts() {
Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr);
temp_mesh_arr = temp_mesh_arr2;
@ -539,7 +530,7 @@ void PropInstancePropJob2D::step_type_merge_verts() {
++_current_mesh;
}
void PropInstancePropJob2D::step_type_bake_texture() {
void PropInstancePropJob::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 +559,10 @@ void PropInstancePropJob2D::step_type_bake_texture() {
++_current_mesh;
}
void PropInstancePropJob2D::step_type_simplify_mesh() {
void PropInstancePropJob::step_type_simplify_mesh() {
#ifdef MESH_UTILS_PRESENT
Ref<PropMesherJobStep2D> step = _job_steps[_current_job_step];
Ref<PropMesherJobStep> 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 +589,7 @@ void PropInstancePropJob2D::step_type_simplify_mesh() {
#endif
}
Array PropInstancePropJob2D::merge_mesh_array(Array arr) const {
Array PropInstancePropJob::merge_mesh_array(Array arr) const {
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr);
PoolVector3Array verts = arr[VisualServer::ARRAY_VERTEX];
@ -662,7 +653,7 @@ Array PropInstancePropJob2D::merge_mesh_array(Array arr) const {
return arr;
}
Array PropInstancePropJob2D::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_color) const {
Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float mul_color) const {
ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr);
ERR_FAIL_COND_V(!tex.is_valid(), arr);
@ -703,7 +694,7 @@ Array PropInstancePropJob2D::bake_mesh_array_uv(Array arr, Ref<Texture> tex, con
return arr;
}
void PropInstancePropJob2D::reset_meshes() {
void PropInstancePropJob::reset_meshes() {
if (!_prop_instace) {
return;
}
@ -725,7 +716,7 @@ void PropInstancePropJob2D::reset_meshes() {
}
}
PropInstancePropJob2D::PropInstancePropJob2D() {
PropInstancePropJob::PropInstancePropJob() {
set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
_prop_instace = NULL;
@ -734,29 +725,29 @@ PropInstancePropJob2D::PropInstancePropJob2D() {
//todo allocate this in a virtual method
_prop_mesher.instance();
_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);
_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);
}
PropInstancePropJob2D::~PropInstancePropJob2D() {
PropInstancePropJob::~PropInstancePropJob() {
}
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");
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");
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_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_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("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("add_light", "light"), &PropInstancePropJob2D::add_light);
ClassDB::bind_method(D_METHOD("clear_lights"), &PropInstancePropJob2D::clear_lights);
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("_physics_process", "delta"), &PropInstancePropJob2D::_physics_process);
ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &PropInstancePropJob::_physics_process);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,56 +20,56 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_JOB_2D_H
#define PROP_JOB_2D_H
#ifndef PROP_JOB_H
#define PROP_JOB_H
#include "prop_instance_job_2d.h"
#include "prop_instance_job.h"
class PropMesher2D;
class PropInstance2D;
class PropInstanceMerger2D;
class PropMesherJobStep2D;
class PropMaterialCache2D;
class PropMesher;
class PropInstance;
class PropInstanceMerger;
class PropMesherJobStep;
class PropMaterialCache;
class Shape;
class PropLight2D;
class PropDataTiledWall2D;
class PropLight;
class PropDataTiledWall;
#if MESH_DATA_RESOURCE_PRESENT
class PropDataMeshData;
class Prop2DDataMeshData;
#endif
class PropInstancePropJob2D : public PropInstanceJob2D {
GDCLASS(PropInstancePropJob2D, PropInstanceJob2D);
class PropInstancePropJob : public PropInstanceJob {
GDCLASS(PropInstancePropJob, PropInstanceJob);
public:
Ref<PropMaterialCache2D> get_material_cache();
void set_material_cache(const Ref<PropMaterialCache2D> &cache);
Ref<PropMaterialCache> get_material_cache();
void set_material_cache(const Ref<PropMaterialCache> &cache);
Ref<PropMesherJobStep2D> get_jobs_step(const int index) const;
void set_jobs_step(const int index, const Ref<PropMesherJobStep2D> &step);
Ref<PropMesherJobStep> get_jobs_step(const int index) const;
void set_jobs_step(const int index, const Ref<PropMesherJobStep> &step);
void remove_jobs_step(const int index);
void add_jobs_step(const Ref<PropMesherJobStep2D> &step);
void add_jobs_step(const Ref<PropMesherJobStep> &step);
int get_jobs_step_count() const;
void add_collision_shape(const Ref<Shape> &shape, const Transform &transform, const bool owns_shape = false);
void clear_collision_shapes();
PropInstanceMerger2D *get_prop_instace();
void set_prop_instace(PropInstanceMerger2D *prop);
PropInstanceMerger *get_prop_instace();
void set_prop_instace(PropInstanceMerger *prop);
void set_prop_instace_bind(Node *prop);
Ref<PropMesher2D> get_prop_mesher() const;
void set_prop_mesher(const Ref<PropMesher2D> &mesher);
Ref<PropMesher> get_prop_mesher() const;
void set_prop_mesher(const Ref<PropMesher> &mesher);
#if MESH_DATA_RESOURCE_PRESENT
void add_mesh(const Ref<PropDataMeshData2D> &mesh_data, const Transform &base_transform);
void add_mesh(const Ref<Prop2DDataMeshData> &mesh_data, const Transform &base_transform);
void clear_meshes();
#endif
void add_tiled_wall(const Ref<PropDataTiledWall2D> &data, const Transform &base_transform);
void add_tiled_wall(const Ref<PropDataTiledWall> &data, const Transform &base_transform);
void clear_tiled_walls();
void add_light(const Ref<PropLight2D> &light);
void add_light(const Ref<PropLight> &light);
void clear_lights();
void _physics_process(float delta);
@ -93,8 +93,8 @@ public:
void reset_meshes();
PropInstancePropJob2D();
~PropInstancePropJob2D();
PropInstancePropJob();
~PropInstancePropJob();
protected:
static void _bind_methods();
@ -102,13 +102,13 @@ protected:
protected:
#if MESH_DATA_RESOURCE_PRESENT
struct PMDREntry {
Ref<PropDataMeshData> mesh_data;
Ref<Prop2DDataMeshData> mesh_data;
Transform base_transform;
};
#endif
struct PTWEntry {
Ref<PropDataTiledWall2D> data;
Ref<PropDataTiledWall> data;
Transform base_transform;
};
@ -122,14 +122,14 @@ protected:
}
};
Ref<PropMaterialCache2D> _material_cache;
Ref<PropMaterialCache> _material_cache;
Vector<Ref<PropMesherJobStep2D>> _job_steps;
Vector<Ref<PropMesherJobStep>> _job_steps;
int _current_job_step;
int _current_mesh;
Ref<PropMesher2D> _prop_mesher;
PropInstanceMerger2D *_prop_instace;
Ref<PropMesher> _prop_mesher;
PropInstanceMerger *_prop_instace;
#if MESH_DATA_RESOURCE_PRESENT
Vector<PMDREntry> _prop_mesh_datas;

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,17 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_mesher_2d.h"
#include "prop_mesher.h"
#include "lights/prop_light_2d.h"
#include "lights/prop_light.h"
#include "modules/opensimplex/open_simplex_noise.h"
#include "material_cache/prop_material_cache_2d.h"
#include "tiled_wall/tiled_wall_data_2d.h"
#include "material_cache/prop_material_cache.h"
#include "tiled_wall/tiled_wall_data.h"
const String PropMesher2D::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights";
const String PropMesher::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights";
bool PropMesher2D::Vertex::operator==(const Vertex &p_vertex) const {
bool PropMesher::Vertex::operator==(const Vertex &p_vertex) const {
if (vertex != p_vertex.vertex)
return false;
@ -65,7 +65,7 @@ bool PropMesher2D::Vertex::operator==(const Vertex &p_vertex) const {
return true;
}
uint32_t PropMesher2D::VertexHasher::hash(const Vertex &p_vtx) {
uint32_t PropMesher::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 PropMesher2D::VertexHasher::hash(const Vertex &p_vtx) {
return h;
}
int PropMesher2D::get_channel_index_type() const {
int PropMesher::get_channel_index_type() const {
return _channel_index_type;
}
void PropMesher2D::set_channel_index_type(const int value) {
void PropMesher::set_channel_index_type(const int value) {
_channel_index_type = value;
}
int PropMesher2D::get_channel_index_isolevel() const {
int PropMesher::get_channel_index_isolevel() const {
return _channel_index_isolevel;
}
void PropMesher2D::set_channel_index_isolevel(const int value) {
void PropMesher::set_channel_index_isolevel(const int value) {
_channel_index_isolevel = value;
}
int PropMesher2D::get_mesher_index() const {
int PropMesher::get_mesher_index() const {
return _mesher_index;
}
void PropMesher2D::set_mesher_index(const int value) {
void PropMesher::set_mesher_index(const int value) {
_mesher_index = value;
}
int PropMesher2D::get_format() const {
int PropMesher::get_format() const {
return _format;
}
void PropMesher2D::set_format(const int value) {
void PropMesher::set_format(const int value) {
_format = value;
}
int PropMesher2D::get_texture_scale() const {
int PropMesher::get_texture_scale() const {
return _texture_scale;
}
void PropMesher2D::set_texture_scale(const int value) {
void PropMesher::set_texture_scale(const int value) {
_texture_scale = value;
}
Ref<Material> PropMesher2D::get_material() {
Ref<Material> PropMesher::get_material() {
return _material;
}
void PropMesher2D::set_material(const Ref<Material> &material) {
void PropMesher::set_material(const Ref<Material> &material) {
_material = material;
}
float PropMesher2D::get_ao_strength() const {
float PropMesher::get_ao_strength() const {
return _ao_strength;
}
void PropMesher2D::set_ao_strength(float value) {
void PropMesher::set_ao_strength(float value) {
_ao_strength = value;
}
float PropMesher2D::get_base_light_value() const {
float PropMesher::get_base_light_value() const {
return _base_light_value;
}
void PropMesher2D::set_base_light_value(float value) {
void PropMesher::set_base_light_value(float value) {
_base_light_value = value;
}
float PropMesher2D::get_voxel_scale() const {
float PropMesher::get_voxel_scale() const {
return _voxel_scale;
}
void PropMesher2D::set_voxel_scale(const float voxel_scale) {
void PropMesher::set_voxel_scale(const float voxel_scale) {
_voxel_scale = voxel_scale;
}
Rect2 PropMesher2D::get_uv_margin() const {
Rect2 PropMesher::get_uv_margin() const {
return _uv_margin;
}
void PropMesher2D::set_uv_margin(const Rect2 margin) {
void PropMesher::set_uv_margin(const Rect2 margin) {
_uv_margin = margin;
}
_FORCE_INLINE_ int PropMesher2D::get_build_flags() const {
_FORCE_INLINE_ int PropMesher::get_build_flags() const {
return _build_flags;
}
_FORCE_INLINE_ void PropMesher2D::set_build_flags(const int flags) {
_FORCE_INLINE_ void PropMesher::set_build_flags(const int flags) {
_build_flags = flags;
if ((_build_flags & PropMesher2D::BUILD_FLAG_USE_LIGHTING) != 0) {
if ((_build_flags & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) {
_format |= VisualServer::ARRAY_FORMAT_COLOR;
} else {
_format ^= VisualServer::ARRAY_FORMAT_COLOR;
}
}
Array PropMesher2D::build_mesh() {
Array PropMesher::build_mesh() {
Array a;
a.resize(VisualServer::ARRAY_MAX);
@ -305,7 +305,7 @@ Array PropMesher2D::build_mesh() {
return a;
}
void PropMesher2D::build_mesh_into(RID mesh) {
void PropMesher::build_mesh_into(RID mesh) {
ERR_FAIL_COND(mesh == RID());
VS::get_singleton()->mesh_clear(mesh);
@ -323,7 +323,7 @@ void PropMesher2D::build_mesh_into(RID mesh) {
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _material->get_rid());
}
void PropMesher2D::generate_normals(bool p_flip) {
void PropMesher::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 PropMesher2D::generate_normals(bool p_flip) {
}
}
void PropMesher2D::remove_doubles() {
void PropMesher::remove_doubles() {
if (_vertices.size() == 0)
return;
@ -401,7 +401,7 @@ void PropMesher2D::remove_doubles() {
}
//lot faster that normal remove_doubles, but false positives can happen curtesy of hash collisions
void PropMesher2D::remove_doubles_hashed() {
void PropMesher::remove_doubles_hashed() {
if (_vertices.size() == 0)
return;
@ -453,7 +453,7 @@ void PropMesher2D::remove_doubles_hashed() {
//print_error("after " + String::num(_vertices.size()) + " " + String::num(duration.count()));
}
void PropMesher2D::reset() {
void PropMesher::reset() {
_vertices.resize(0);
_indices.resize(0);
@ -466,7 +466,7 @@ void PropMesher2D::reset() {
_last_tangent = Plane();
}
void PropMesher2D::add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref<TiledWallData2D> &tiled_wall_data, Ref<PropMaterialCache2D> cache) {
void PropMesher::add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref<TiledWallData> &tiled_wall_data, Ref<PropMaterialCache> cache) {
ERR_FAIL_COND(!tiled_wall_data.is_valid());
ERR_FAIL_COND(!cache.is_valid());
ERR_FAIL_COND(width < 0);
@ -503,11 +503,11 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons
normal_rects.push_back(Rect2(0, 0, 1, 1));
}
TiledWallData2D::TiledWallTilingType tiling_type = tiled_wall_data->get_tiling_type();
TiledWallData::TiledWallTilingType tiling_type = tiled_wall_data->get_tiling_type();
//todo implement flavour!
if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_NONE) {
if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_NONE) {
Rect2 r = normal_rects[0];
if (flavour_rects.size() == 0) {
@ -529,7 +529,7 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons
}
}
}
} else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_HORIZONTAL) {
} else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_HORIZONTAL) {
Rect2 r;
if (flavour_rects.size() == 0) {
@ -555,7 +555,7 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons
}
}
}
} else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_VERTICAL) {
} else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_VERTICAL) {
Rect2 r;
if (flavour_rects.size() == 0) {
@ -581,7 +581,7 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons
}
}
}
} else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_BOTH) {
} else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_BOTH) {
Rect2 r;
if (flavour_rects.size() == 0) {
@ -610,7 +610,7 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons
}
}
void PropMesher2D::add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect) {
void PropMesher::add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect) {
int vc = get_vertex_count();
//x + 1, y
@ -641,7 +641,7 @@ void PropMesher2D::add_tiled_wall_mesh_rect_simple(const int x, const int y, con
add_indices(vc + 0);
}
_FORCE_INLINE_ Vector2 PropMesher2D::transform_uv(const Vector2 &uv, const Rect2 &rect) const {
_FORCE_INLINE_ Vector2 PropMesher::transform_uv(const Vector2 &uv, const Rect2 &rect) const {
Vector2 ruv = uv;
ruv.x *= rect.size.x;
@ -653,13 +653,13 @@ _FORCE_INLINE_ Vector2 PropMesher2D::transform_uv(const Vector2 &uv, const Rect2
}
#ifdef MESH_DATA_RESOURCE_PRESENT
void PropMesher2D::add_mesh_data_resource(Ref<MeshDataResource> mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) {
void PropMesher::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 PropMesher2D::add_mesh_data_resource_transform(Ref<MeshDataResource> mesh, const Transform transform, const Rect2 uv_rect) {
void PropMesher::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 PropMesher2D::add_mesh_data_resource_transform(Ref<MeshDataResource> mesh,
}
}
void PropMesher2D::add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) {
void PropMesher::add_mesh_data_resource_transform_colored(Ref<MeshDataResource> mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) {
if (mesh->get_array().size() == 0)
return;
@ -748,7 +748,7 @@ void PropMesher2D::add_mesh_data_resource_transform_colored(Ref<MeshDataResource
#endif
//Data Management functions
void PropMesher2D::generate_ao() {
void PropMesher::generate_ao() {
/*
ERR_FAIL_COND(!_chunk.is_valid());
@ -787,7 +787,7 @@ void PropMesher2D::generate_ao() {
}*/
}
float PropMesher2D::get_random_ao(const Vector3 &position) {
float PropMesher::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 PropMesher2D::get_random_ao(const Vector3 &position) {
return val;
}
Color PropMesher2D::get_light_color_at(const Vector3 &position, const Vector3 &normal) {
Color PropMesher::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<PropLight2D> light = _lights.get(i);
Ref<PropLight> light = _lights.get(i);
Vector3 lightDir = light->get_position() - position;
@ -843,10 +843,10 @@ Color PropMesher2D::get_light_color_at(const Vector3 &position, const Vector3 &n
return Color(v_lightDiffuse.x, v_lightDiffuse.y, v_lightDiffuse.z);
}
void PropMesher2D::add_mesher(const Ref<PropMesher2D> &mesher) {
void PropMesher::add_mesher(const Ref<PropMesher> &mesher) {
call("_add_mesher", mesher);
}
void PropMesher2D::_add_mesher(const Ref<PropMesher2D> &mesher) {
void PropMesher::_add_mesher(const Ref<PropMesher> &mesher) {
int orig_size = _vertices.size();
_vertices.append_array(mesher->_vertices);
@ -864,14 +864,14 @@ void PropMesher2D::_add_mesher(const Ref<PropMesher2D> &mesher) {
}
}
void PropMesher2D::add_light(const Ref<PropLight2D> &light) {
void PropMesher::add_light(const Ref<PropLight> &light) {
_lights.push_back(light);
}
void PropMesher2D::clear_lights() {
void PropMesher::clear_lights() {
_lights.clear();
}
PoolVector<Vector3> PropMesher2D::build_collider() const {
PoolVector<Vector3> PropMesher::build_collider() const {
PoolVector<Vector3> face_points;
if (_vertices.size() == 0)
@ -901,13 +901,13 @@ PoolVector<Vector3> PropMesher2D::build_collider() const {
return face_points;
}
void PropMesher2D::bake_colors() {
if ((get_build_flags() & PropMesher2D::BUILD_FLAG_USE_LIGHTING) == 0) {
void PropMesher::bake_colors() {
if ((get_build_flags() & PropMesher::BUILD_FLAG_USE_LIGHTING) == 0) {
return;
}
bool rao = (get_build_flags() & PropMesher2D::BUILD_FLAG_USE_RAO) != 0;
bool lights = (get_build_flags() & PropMesher2D::BUILD_FLAG_BAKE_LIGHTS) != 0;
bool rao = (get_build_flags() & PropMesher::BUILD_FLAG_USE_RAO) != 0;
bool lights = (get_build_flags() & PropMesher::BUILD_FLAG_BAKE_LIGHTS) != 0;
if (rao && lights) {
bake_colors_lights_rao();
@ -925,7 +925,7 @@ void PropMesher2D::bake_colors() {
}
}
void PropMesher2D::bake_colors_rao() {
void PropMesher::bake_colors_rao() {
for (int i = 0; i < _vertices.size(); ++i) {
Vertex vertex = _vertices[i];
Vector3 vert = vertex.vertex;
@ -949,7 +949,7 @@ void PropMesher2D::bake_colors_rao() {
_vertices.set(i, vertex);
}
}
void PropMesher2D::bake_colors_lights_rao() {
void PropMesher::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 PropMesher2D::bake_colors_lights_rao() {
_vertices.set(i, vertex);
}
}
void PropMesher2D::bake_colors_lights() {
void PropMesher::bake_colors_lights() {
for (int i = 0; i < _vertices.size(); ++i) {
Vertex vertex = _vertices[i];
Vector3 vert = vertex.vertex;
@ -1001,7 +1001,7 @@ void PropMesher2D::bake_colors_lights() {
}
#ifdef TERRAMAN_PRESENT
void PropMesher2D::bake_lights(MeshInstance *node, Vector<Ref<TerraLight>> &lights) {
void PropMesher::bake_lights(MeshInstance *node, Vector<Ref<TerrainLight>> &lights) {
ERR_FAIL_COND(node == NULL);
Color darkColor(0, 0, 0, 1);
@ -1018,7 +1018,7 @@ void PropMesher2D::bake_lights(MeshInstance *node, Vector<Ref<TerraLight>> &ligh
//calculate the lights value
for (int i = 0; i < lights.size(); ++i) {
Ref<TerraLight> light = lights.get(i);
Ref<TerrainLight> light = lights.get(i);
Vector3 lightDir = light->get_world_position() - vertex;
@ -1089,7 +1089,7 @@ void PropMesher2D::bake_lights(MeshInstance *node, Vector<Ref<TerraLight>> &ligh
}
#endif
PoolVector<Vector3> PropMesher2D::get_vertices() const {
PoolVector<Vector3> PropMesher::get_vertices() const {
PoolVector<Vector3> arr;
arr.resize(_vertices.size());
@ -1100,7 +1100,7 @@ PoolVector<Vector3> PropMesher2D::get_vertices() const {
return arr;
}
void PropMesher2D::set_vertices(const PoolVector<Vector3> &values) {
void PropMesher::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 PropMesher2D::set_vertices(const PoolVector<Vector3> &values) {
}
}
int PropMesher2D::get_vertex_count() const {
int PropMesher::get_vertex_count() const {
return _vertices.size();
}
void PropMesher2D::add_vertex(const Vector3 &vertex) {
void PropMesher::add_vertex(const Vector3 &vertex) {
Vertex vtx;
vtx.vertex = vertex;
vtx.color = _last_color;
@ -1132,15 +1132,15 @@ void PropMesher2D::add_vertex(const Vector3 &vertex) {
_vertices.push_back(vtx);
}
Vector3 PropMesher2D::get_vertex(const int idx) const {
Vector3 PropMesher::get_vertex(const int idx) const {
return _vertices.get(idx).vertex;
}
void PropMesher2D::remove_vertex(const int idx) {
void PropMesher::remove_vertex(const int idx) {
_vertices.remove(idx);
}
PoolVector<Vector3> PropMesher2D::get_normals() const {
PoolVector<Vector3> PropMesher::get_normals() const {
PoolVector<Vector3> arr;
arr.resize(_vertices.size());
@ -1151,7 +1151,7 @@ PoolVector<Vector3> PropMesher2D::get_normals() const {
return arr;
}
void PropMesher2D::set_normals(const PoolVector<Vector3> &values) {
void PropMesher::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 PropMesher2D::set_normals(const PoolVector<Vector3> &values) {
}
}
void PropMesher2D::add_normal(const Vector3 &normal) {
void PropMesher::add_normal(const Vector3 &normal) {
_last_normal = normal;
}
Vector3 PropMesher2D::get_normal(int idx) const {
Vector3 PropMesher::get_normal(int idx) const {
return _vertices.get(idx).normal;
}
PoolVector<Color> PropMesher2D::get_colors() const {
PoolVector<Color> PropMesher::get_colors() const {
PoolVector<Color> arr;
arr.resize(_vertices.size());
@ -1182,7 +1182,7 @@ PoolVector<Color> PropMesher2D::get_colors() const {
return arr;
}
void PropMesher2D::set_colors(const PoolVector<Color> &values) {
void PropMesher::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 PropMesher2D::set_colors(const PoolVector<Color> &values) {
}
}
void PropMesher2D::add_color(const Color &color) {
void PropMesher::add_color(const Color &color) {
_last_color = color;
}
Color PropMesher2D::get_color(const int idx) const {
Color PropMesher::get_color(const int idx) const {
return _vertices.get(idx).color;
}
PoolVector<Vector2> PropMesher2D::get_uvs() const {
PoolVector<Vector2> PropMesher::get_uvs() const {
PoolVector<Vector2> arr;
arr.resize(_vertices.size());
@ -1213,7 +1213,7 @@ PoolVector<Vector2> PropMesher2D::get_uvs() const {
return arr;
}
void PropMesher2D::set_uvs(const PoolVector<Vector2> &values) {
void PropMesher::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 PropMesher2D::set_uvs(const PoolVector<Vector2> &values) {
}
}
void PropMesher2D::add_uv(const Vector2 &uv) {
void PropMesher::add_uv(const Vector2 &uv) {
_last_uv = uv;
}
Vector2 PropMesher2D::get_uv(const int idx) const {
Vector2 PropMesher::get_uv(const int idx) const {
return _vertices.get(idx).uv;
}
PoolVector<Vector2> PropMesher2D::get_uv2s() const {
PoolVector<Vector2> PropMesher::get_uv2s() const {
PoolVector<Vector2> arr;
arr.resize(_vertices.size());
@ -1244,7 +1244,7 @@ PoolVector<Vector2> PropMesher2D::get_uv2s() const {
return arr;
}
void PropMesher2D::set_uv2s(const PoolVector<Vector2> &values) {
void PropMesher::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 PropMesher2D::set_uv2s(const PoolVector<Vector2> &values) {
}
}
void PropMesher2D::add_uv2(const Vector2 &uv) {
void PropMesher::add_uv2(const Vector2 &uv) {
_last_uv2 = uv;
}
Vector2 PropMesher2D::get_uv2(const int idx) const {
Vector2 PropMesher::get_uv2(const int idx) const {
return _vertices.get(idx).uv2;
}
PoolVector<int> PropMesher2D::get_indices() const {
PoolVector<int> PropMesher::get_indices() const {
return _indices;
}
void PropMesher2D::set_indices(const PoolVector<int> &values) {
void PropMesher::set_indices(const PoolVector<int> &values) {
_indices = values;
}
int PropMesher2D::get_indices_count() const {
int PropMesher::get_indices_count() const {
return _indices.size();
}
void PropMesher2D::add_indices(const int index) {
void PropMesher::add_indices(const int index) {
_indices.push_back(index);
}
int PropMesher2D::get_index(const int idx) const {
int PropMesher::get_index(const int idx) const {
return _indices.get(idx);
}
void PropMesher2D::remove_index(const int idx) {
void PropMesher::remove_index(const int idx) {
_indices.remove(idx);
}
PropMesher2D::PropMesher2D() {
PropMesher::PropMesher() {
_mesher_index = 0;
_voxel_scale = 1;
_ao_strength = 0.25;
@ -1313,120 +1313,120 @@ PropMesher2D::PropMesher2D() {
_rao_seed = 2134;
}
PropMesher2D::~PropMesher2D() {
PropMesher::~PropMesher() {
}
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);
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);
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"), &PropMesher2D::get_channel_index_isolevel);
ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &PropMesher2D::set_channel_index_isolevel);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_isolevel"), "set_channel_index_isolevel", "get_channel_index_isolevel");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "mesher_index"), "set_mesher_index", "get_mesher_index");
ClassDB::bind_method(D_METHOD("get_format"), &PropMesher2D::get_format);
ClassDB::bind_method(D_METHOD("set_format", "value"), &PropMesher2D::set_format);
ClassDB::bind_method(D_METHOD("get_format"), &PropMesher::get_format);
ClassDB::bind_method(D_METHOD("set_format", "value"), &PropMesher::set_format);
ADD_PROPERTY(PropertyInfo(Variant::INT, "format"), "set_format", "get_format");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_scale"), "set_texture_scale", "get_texture_scale");
ClassDB::bind_method(D_METHOD("get_material"), &PropMesher2D::get_material);
ClassDB::bind_method(D_METHOD("set_material", "value"), &PropMesher2D::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &PropMesher::get_material);
ClassDB::bind_method(D_METHOD("set_material", "value"), &PropMesher::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"), &PropMesher2D::get_voxel_scale);
ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &PropMesher2D::set_voxel_scale);
ClassDB::bind_method(D_METHOD("get_voxel_scale"), &PropMesher::get_voxel_scale);
ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &PropMesher::set_voxel_scale);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale");
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);
ClassDB::bind_method(D_METHOD("get_ao_strength"), &PropMesher::get_ao_strength);
ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &PropMesher::set_ao_strength);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_strength"), "set_ao_strength", "get_ao_strength");
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);
ClassDB::bind_method(D_METHOD("get_base_light_value"), &PropMesher::get_base_light_value);
ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &PropMesher::set_base_light_value);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_light_value"), "set_base_light_value", "get_base_light_value");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "uv_margin"), "set_uv_margin", "get_uv_margin");
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("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("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);
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);
#ifdef MESH_DATA_RESOURCE_PRESENT
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)));
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)));
#endif
ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher2D::generate_ao);
ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher2D::get_random_ao);
ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher::generate_ao);
ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher::get_random_ao);
BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher2D")));
ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &PropMesher2D::add_mesher);
ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &PropMesher2D::_add_mesher);
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);
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("add_light", "light"), &PropMesher::add_light);
ClassDB::bind_method(D_METHOD("clear_lights"), &PropMesher::clear_lights);
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_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_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_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_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_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_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_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_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_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_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("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("reset"), &PropMesher2D::reset);
ClassDB::bind_method(D_METHOD("reset"), &PropMesher::reset);
//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("calculate_vertex_ambient_occlusion", "meshinstance_path", "radius", "intensity", "sampleCount"), &PropMesher::calculate_vertex_ambient_occlusion_path);
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("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("bake_colors"), &PropMesher2D::bake_colors);
ClassDB::bind_method(D_METHOD("bake_colors"), &PropMesher::bake_colors);
ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher2D::generate_normals, DEFVAL(false));
ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher::generate_normals, DEFVAL(false));
ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher2D::remove_doubles);
ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &PropMesher2D::remove_doubles_hashed);
ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher::remove_doubles);
ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &PropMesher::remove_doubles_hashed);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_MESHER_2D_H
#define PROP_MESHER_2D_H
#ifndef PROP_MESHER_H
#define PROP_MESHER_H
#include "core/version.h"
@ -57,16 +57,16 @@ using PoolVector = Vector<N>;
#endif
#ifdef TERRAMAN_PRESENT
#include "../terraman/data/terra_light.h"
#include "../terraman/data/terrain_light.h"
#endif
class OpenSimplexNoise;
class PropLight2D;
class PropMaterialCache2D;
class TiledWallData2D;
class PropLight;
class PropMaterialCache;
class TiledWallData;
class PropMesher2D : public Reference {
GDCLASS(PropMesher2D, Reference);
class PropMesher : public Reference {
GDCLASS(PropMesher, 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<TiledWallData2D> &tiled_wall_data, Ref<PropMaterialCache2D> cache);
void add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref<TiledWallData> &tiled_wall_data, Ref<PropMaterialCache> cache);
void add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect);
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<PropMesher2D> &mesher);
void _add_mesher(const Ref<PropMesher2D> &mesher);
void add_mesher(const Ref<PropMesher> &mesher);
void _add_mesher(const Ref<PropMesher> &mesher);
void add_light(const Ref<PropLight2D> &light);
void add_light(const Ref<PropLight> &light);
void clear_lights();
PoolVector<Vector3> build_collider() const;
@ -173,7 +173,7 @@ public:
void bake_colors_lights();
#ifdef TERRAMAN_PRESENT
void bake_lights(MeshInstance *node, Vector<Ref<TerraLight>> &lights);
void bake_lights(MeshInstance *node, Vector<Ref<TerrainLight>> &lights);
#endif
Array build_mesh();
@ -217,8 +217,8 @@ public:
void remove_index(const int idx);
void add_indices(const int index);
PropMesher2D();
~PropMesher2D();
PropMesher();
~PropMesher();
protected:
static void _bind_methods();
@ -234,7 +234,7 @@ protected:
PoolVector<Vertex> _vertices;
PoolVector<int> _indices;
Vector<Ref<PropLight2D>> _lights;
Vector<Ref<PropLight>> _lights;
Color _last_color;
Vector3 _last_normal;
@ -258,6 +258,6 @@ protected:
int _rao_seed;
};
VARIANT_ENUM_CAST(PropMesher2D::BuildFlags);
VARIANT_ENUM_CAST(PropMesher::BuildFlags);
#endif

View File

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

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2020 Péter Magyar
Copyright (c) 2020-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_SCENE_INSTANCE_2D_H
#define PROP_SCENE_INSTANCE_2D_H
#ifndef PROP_SCENE_INSTANCE_H
#define PROP_SCENE_INSTANCE_H
#include "core/version.h"
@ -35,11 +35,11 @@ SOFTWARE.
#include "core/math/vector3.h"
#include "props/prop_data_2d.h"
#include "props/prop_data.h"
#include "scene/resources/packed_scene.h"
class PropSceneInstance2D : public Spatial {
GDCLASS(PropSceneInstance2D, Spatial);
class PropSceneInstance : public Spatial {
GDCLASS(PropSceneInstance, Spatial);
public:
Ref<PackedScene> get_scene();
@ -53,8 +53,8 @@ public:
void build();
PropSceneInstance2D();
~PropSceneInstance2D();
PropSceneInstance();
~PropSceneInstance();
protected:
void _notification(int p_what);

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,11 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_data_2d.h"
#include "prop_data.h"
#include "prop_data_entry_2d.h"
#include "prop_data_light_2d.h"
#include "prop_data_prop_2d.h"
#include "prop_data_entry.h"
#include "prop_data_light.h"
#include "prop_data_prop.h"
#if VERSION_MAJOR < 4
#include "servers/physics_server.h"
@ -34,51 +34,51 @@ SOFTWARE.
#define Shape Shape3D
#endif
int PropData2D::get_id() const {
int PropData::get_id() const {
return _id;
}
void PropData2D::set_id(const int value) {
void PropData::set_id(const int value) {
_id = value;
}
bool PropData2D::get_snap_to_mesh() const {
bool PropData::get_snap_to_mesh() const {
return _snap_to_mesh;
}
void PropData2D::set_snap_to_mesh(const bool value) {
void PropData::set_snap_to_mesh(const bool value) {
_snap_to_mesh = value;
}
Vector3 PropData2D::get_snap_axis() const {
Vector3 PropData::get_snap_axis() const {
return _snap_axis;
}
void PropData2D::set_snap_axis(const Vector3 &value) {
void PropData::set_snap_axis(const Vector3 &value) {
_snap_axis = value;
}
Ref<PropDataEntry2D> PropData2D::get_prop(const int index) const {
ERR_FAIL_INDEX_V(index, _props.size(), Ref<PropDataEntry2D>());
Ref<PropDataEntry> PropData::get_prop(const int index) const {
ERR_FAIL_INDEX_V(index, _props.size(), Ref<PropDataEntry>());
return _props.get(index);
}
void PropData2D::set_prop(const int index, const Ref<PropDataEntry2D> prop) {
void PropData::set_prop(const int index, const Ref<PropDataEntry> prop) {
ERR_FAIL_INDEX(index, _props.size());
_props.set(index, prop);
}
void PropData2D::add_prop(const Ref<PropDataEntry2D> prop) {
void PropData::add_prop(const Ref<PropDataEntry> prop) {
_props.push_back(prop);
}
void PropData2D::remove_prop(const int index) {
void PropData::remove_prop(const int index) {
ERR_FAIL_INDEX(index, _props.size());
_props.remove(index);
}
int PropData2D::get_prop_count() const {
int PropData::get_prop_count() const {
return _props.size();
}
Vector<Variant> PropData2D::get_props() {
Vector<Variant> PropData::get_props() {
Vector<Variant> r;
for (int i = 0; i < _props.size(); i++) {
#if VERSION_MAJOR < 4
@ -89,21 +89,21 @@ Vector<Variant> PropData2D::get_props() {
}
return r;
}
void PropData2D::set_props(const Vector<Variant> &props) {
void PropData::set_props(const Vector<Variant> &props) {
_props.clear();
for (int i = 0; i < props.size(); i++) {
Ref<PropDataEntry2D> prop = Ref<PropDataEntry2D>(props[i]);
Ref<PropDataEntry> prop = Ref<PropDataEntry>(props[i]);
_props.push_back(prop);
}
}
#if TEXTURE_PACKER_PRESENT
void PropData2D::add_textures_into(Ref<TexturePacker> texture_packer) {
void PropData::add_textures_into(Ref<TexturePacker> texture_packer) {
ERR_FAIL_COND(!texture_packer.is_valid());
for (int i = 0; i < _props.size(); ++i) {
Ref<PropDataEntry2D> entry = _props.get(i);
Ref<PropDataEntry> entry = _props.get(i);
if (entry.is_valid()) {
entry->add_textures_into(texture_packer);
@ -112,21 +112,21 @@ void PropData2D::add_textures_into(Ref<TexturePacker> texture_packer) {
}
#endif
bool PropData2D::get_is_room() const {
bool PropData::get_is_room() const {
return _is_room;
}
void PropData2D::set_is_room(const bool value) {
void PropData::set_is_room(const bool value) {
_is_room = value;
}
PoolVector3Array PropData2D::get_room_bounds() {
PoolVector3Array PropData::get_room_bounds() {
return _room_bounds;
}
void PropData2D::set_room_bounds(const PoolVector3Array &bounds) {
void PropData::set_room_bounds(const PoolVector3Array &bounds) {
_room_bounds = bounds;
}
void PropData2D::copy_from(const Ref<PropData2D> &prop_data) {
void PropData::copy_from(const Ref<PropData> &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 PropData2D::copy_from(const Ref<PropData2D> &prop_data) {
emit_changed();
}
PropData2D::PropData2D() {
PropData::PropData() {
_id = 0;
_snap_to_mesh = false;
_is_room = false;
_snap_axis = Vector3(0, -1, 0);
}
PropData2D::~PropData2D() {
PropData::~PropData() {
_props.clear();
}
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
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", "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_count"), &PropData2D::get_prop_count);
ClassDB::bind_method(D_METHOD("get_prop_count"), &PropData::get_prop_count);
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");
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");
#if TEXTURE_PACKER_PRESENT
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData2D::add_textures_into);
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData::add_textures_into);
#endif
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_room"), "set_is_room", "get_is_room");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "room_bounds"), "set_room_bounds", "get_room_bounds");
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData2D::copy_from);
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData::copy_from);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,34 +20,38 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_DATA_2D_H
#define PROP_DATA_2D_H
#ifndef PROP_DATA_H
#define PROP_DATA_H
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/object/reference.h"
#include "core/object/ref_counted.h"
#ifndef Reference
#define Reference RefCounted
#endif
#include "core/math/transform_3d.h"
#include "core/templates/vector.h"
#else
#include "core/reference.h"
#include "core/vector.h"
#include "core/math/transform.h"
#endif
#include "core/math/rect2.h"
#include "core/math/transform.h"
#include "core/math/vector2.h"
#include "core/math/vector3.h"
#include "core/version.h"
#include "prop_data_entry_2d.h"
#include "prop_data_entry.h"
#if TEXTURE_PACKER_PRESENT
#include "../../texture_packer/texture_packer.h"
#endif
class PropData2D : public Resource {
GDCLASS(PropData2D, Resource);
class PropData : public Resource {
GDCLASS(PropData, Resource);
public:
int get_id() const;
@ -59,9 +63,9 @@ public:
Vector3 get_snap_axis() const;
void set_snap_axis(const Vector3 &value);
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);
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);
void remove_prop(const int index);
int get_prop_count() const;
@ -79,10 +83,10 @@ public:
PoolVector3Array get_room_bounds();
void set_room_bounds(const PoolVector3Array &bounds);
void copy_from(const Ref<PropData2D> &prop_data);
void copy_from(const Ref<PropData> &prop_data);
PropData2D();
~PropData2D();
PropData();
~PropData();
protected:
static void _bind_methods();
@ -92,7 +96,7 @@ private:
bool _snap_to_mesh;
Vector3 _snap_axis;
Vector<Ref<PropDataEntry2D>> _props;
Vector<Ref<PropDataEntry>> _props;
bool _is_room;
PoolVector3Array _room_bounds;

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,9 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_data_entry_2d.h"
#include "prop_data_entry.h"
#include "prop_data_2d.h"
#include "prop_data.h"
#include "core/version.h"
@ -38,66 +38,66 @@ SOFTWARE.
#endif
#include "../prop_mesher_2d.h"
#include "../prop_mesher.h"
Transform PropDataEntry2D::get_transform() const {
Transform PropDataEntry::get_transform() const {
return _transform;
}
void PropDataEntry2D::set_transform(const Transform &value) {
void PropDataEntry::set_transform(const Transform &value) {
_transform = value;
}
#if TEXTURE_PACKER_PRESENT
void PropDataEntry2D::add_textures_into(Ref<TexturePacker> texture_packer) {
void PropDataEntry::add_textures_into(Ref<TexturePacker> texture_packer) {
if (has_method("_add_textures_into"))
call("_add_textures_into", texture_packer);
}
#endif
bool PropDataEntry2D::processor_handles(Node *node) {
bool PropDataEntry::processor_handles(Node *node) {
return call("_processor_handles", node);
}
void PropDataEntry2D::processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
void PropDataEntry::processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
call("_processor_process", prop_data, node, transform);
}
Node *PropDataEntry2D::processor_get_node_for(const Transform &transform) {
Node *PropDataEntry::processor_get_node_for(const Transform &transform) {
return call("_processor_get_node_for", transform);
}
bool PropDataEntry2D::processor_evaluate_children() {
bool PropDataEntry::processor_evaluate_children() {
return call("_processor_evaluate_children");
}
bool PropDataEntry2D::_processor_handles(Node *node) {
bool PropDataEntry::_processor_handles(Node *node) {
return false;
}
void PropDataEntry2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
void PropDataEntry::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
}
Node *PropDataEntry2D::_processor_get_node_for(const Transform &transform) {
Node *PropDataEntry::_processor_get_node_for(const Transform &transform) {
return NULL;
}
bool PropDataEntry2D::_processor_evaluate_children() {
bool PropDataEntry::_processor_evaluate_children() {
return true;
}
PropDataEntry2D::PropDataEntry2D() {
PropDataEntry::PropDataEntry() {
}
PropDataEntry2D::~PropDataEntry2D() {
PropDataEntry::~PropDataEntry() {
}
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);
void PropDataEntry::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_transform"), &PropDataEntry::get_transform);
ClassDB::bind_method(D_METHOD("set_transform", "value"), &PropDataEntry::set_transform);
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform");
#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"), &PropDataEntry2D::add_textures_into);
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropDataEntry::add_textures_into);
#endif
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "handles"), "_processor_handles"));
BIND_VMETHOD(MethodInfo("_processor_process",
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"),
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"),
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"),
PropertyInfo(Variant::TRANSFORM, "transform")));
@ -106,14 +106,14 @@ void PropDataEntry2D::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "evaluate"), "_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", "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", "transform"), &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);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,25 +20,29 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_DATA_DATA_2D_H
#define PROP_DATA_DATA_2D_H
#ifndef PROP_DATA_DATA_H
#define PROP_DATA_DATA_H
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/io/resource.h"
#include "core/math/transform_3d.h"
#ifndef Transform
#define Transform Transform3D
#endif
#else
#include "core/resource.h"
#include "core/math/transform.h"
#endif
#include "core/math/transform.h"
class PropData2D;
class PropMesher2D;
class PropData;
class PropMesher;
class TexturePacker;
class PropDataEntry2D : public Resource {
GDCLASS(PropDataEntry2D, Resource);
class PropDataEntry : public Resource {
GDCLASS(PropDataEntry, Resource);
public:
Transform get_transform() const;
@ -49,17 +53,17 @@ public:
#endif
bool processor_handles(Node *node);
void processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
void processor_process(Ref<PropData> 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<PropData2D> prop_data, Node *node, const Transform &transform);
virtual void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
virtual Node *_processor_get_node_for(const Transform &transform);
virtual bool _processor_evaluate_children();
PropDataEntry2D();
~PropDataEntry2D();
PropDataEntry();
~PropDataEntry();
protected:
static void _bind_methods();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,9 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_data_light_2d.h"
#include "prop_data_light.h"
#include "prop_data_2d.h"
#include "prop_data.h"
#if VERSION_MAJOR < 4
#include "scene/3d/light.h"
@ -32,32 +32,32 @@ SOFTWARE.
#define Light Light3D
#endif
Color PropDataLight2D::get_light_color() const {
Color PropDataLight::get_light_color() const {
return _light_color;
}
void PropDataLight2D::set_light_color(const Color value) {
void PropDataLight::set_light_color(const Color value) {
_light_color = value;
}
int PropDataLight2D::get_light_size() const {
int PropDataLight::get_light_size() const {
return _light_size;
}
void PropDataLight2D::set_light_size(const int value) {
void PropDataLight::set_light_size(const int value) {
_light_size = value;
}
bool PropDataLight2D::_processor_handles(Node *node) {
bool PropDataLight::_processor_handles(Node *node) {
OmniLight *i = Object::cast_to<OmniLight>(node);
return i;
}
void PropDataLight2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
void PropDataLight::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
OmniLight *i = Object::cast_to<OmniLight>(node);
ERR_FAIL_COND(!i);
Ref<PropDataLight2D> l;
Ref<PropDataLight> 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 PropDataLight2D::_processor_process(Ref<PropData2D> prop_data, Node *node,
prop_data->add_prop(l);
}
Node *PropDataLight2D::_processor_get_node_for(const Transform &transform) {
Node *PropDataLight::_processor_get_node_for(const Transform &transform) {
OmniLight *i = memnew(OmniLight);
i->set_color(get_light_color());
@ -75,18 +75,18 @@ Node *PropDataLight2D::_processor_get_node_for(const Transform &transform) {
return i;
}
PropDataLight2D::PropDataLight2D() {
PropDataLight::PropDataLight() {
_light_size = 0;
}
PropDataLight2D::~PropDataLight2D() {
PropDataLight::~PropDataLight() {
}
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), "set_light_color", "get_light_color");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_size"), "set_light_size", "get_light_size");
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_DATA_LIGHT_2D_H
#define PROP_DATA_LIGHT_2D_H
#ifndef PROP_DATA_LIGHT_H
#define PROP_DATA_LIGHT_H
#include "core/version.h"
@ -31,10 +31,10 @@ SOFTWARE.
#include "core/color.h"
#endif
#include "prop_data_entry_2d.h"
#include "prop_data_entry.h"
class PropDataLight2D : public PropDataEntry2D {
GDCLASS(PropDataLight2D, PropDataEntry2D);
class PropDataLight : public PropDataEntry {
GDCLASS(PropDataLight, PropDataEntry);
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<PropData2D> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataLight2D();
~PropDataLight2D();
PropDataLight();
~PropDataLight();
protected:
static void _bind_methods();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,59 +20,59 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_data_portal_2d.h"
#include "prop_data_portal.h"
#include "prop_data_2d.h"
#include "prop_data.h"
#include "scene/3d/portal.h"
bool PropDataPortal2D::get_is_active() const {
bool PropDataPortal::get_is_active() const {
return _is_active;
}
void PropDataPortal2D::set_is_active(bool p_active) {
void PropDataPortal::set_is_active(bool p_active) {
_is_active = p_active;
}
bool PropDataPortal2D::get_is_two_way() const {
bool PropDataPortal::get_is_two_way() const {
return _is_two_way;
}
void PropDataPortal2D::set_is_two_way(bool p_two_way) {
void PropDataPortal::set_is_two_way(bool p_two_way) {
_is_two_way = p_two_way;
}
bool PropDataPortal2D::get_use_default_margin() const {
bool PropDataPortal::get_use_default_margin() const {
return _use_default_margin;
}
void PropDataPortal2D::set_use_default_margin(bool p_use) {
void PropDataPortal::set_use_default_margin(bool p_use) {
_use_default_margin = p_use;
}
real_t PropDataPortal2D::get_portal_margin() const {
real_t PropDataPortal::get_portal_margin() const {
return _portal_margin;
}
void PropDataPortal2D::set_portal_margin(real_t p_margin) {
void PropDataPortal::set_portal_margin(real_t p_margin) {
_portal_margin = p_margin;
}
PoolVector<Vector2> PropDataPortal2D::get_points() const {
PoolVector<Vector2> PropDataPortal::get_points() const {
return _points;
}
void PropDataPortal2D::set_points(const PoolVector<Vector2> &p_points) {
void PropDataPortal::set_points(const PoolVector<Vector2> &p_points) {
_points = p_points;
}
bool PropDataPortal2D::_processor_handles(Node *node) {
bool PropDataPortal::_processor_handles(Node *node) {
Portal *p = Object::cast_to<Portal>(node);
return p;
}
void PropDataPortal2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
void PropDataPortal::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
Portal *p = Object::cast_to<Portal>(node);
ERR_FAIL_COND(!p);
Ref<PropDataPortal2D> l;
Ref<PropDataPortal> 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 PropDataPortal2D::_processor_process(Ref<PropData2D> prop_data, Node *node,
prop_data->add_prop(l);
}
Node *PropDataPortal2D::_processor_get_node_for(const Transform &transform) {
Node *PropDataPortal::_processor_get_node_for(const Transform &transform) {
Portal *p = memnew(Portal);
p->set_portal_active(get_is_active());
@ -98,33 +98,33 @@ Node *PropDataPortal2D::_processor_get_node_for(const Transform &transform) {
return p;
}
PropDataPortal2D::PropDataPortal2D() {
PropDataPortal::PropDataPortal() {
_is_active = true;
_is_two_way = true;
_use_default_margin = true;
_portal_margin = 1;
}
PropDataPortal2D::~PropDataPortal2D() {
PropDataPortal::~PropDataPortal() {
}
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_active"), "set_is_active", "get_is_active");
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);
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);
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"), &PropDataPortal2D::get_use_default_margin);
ClassDB::bind_method(D_METHOD("set_use_default_margin", "value"), &PropDataPortal2D::set_use_default_margin);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_default_margin"), "set_use_default_margin", "get_use_default_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);
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);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "portal_margin"), "set_portal_margin", "get_portal_margin");
ClassDB::bind_method(D_METHOD("get_points"), &PropDataPortal2D::get_points);
ClassDB::bind_method(D_METHOD("set_points", "value"), &PropDataPortal2D::set_points);
ClassDB::bind_method(D_METHOD("get_points"), &PropDataPortal::get_points);
ClassDB::bind_method(D_METHOD("set_points", "value"), &PropDataPortal::set_points);
ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "points"), "set_points", "get_points");
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,15 +20,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_DATA_PORTAL_2D_H
#define PROP_DATA_PORTAL_2D_H
#ifndef PROP_DATA_PORTAL_H
#define PROP_DATA_PORTAL_H
#include "core/version.h"
#include "prop_data_entry_2d.h"
#include "prop_data_entry.h"
class PropDataPortal2D : public PropDataEntry2D {
GDCLASS(PropDataPortal2D, PropDataEntry2D);
class PropDataPortal : public PropDataEntry {
GDCLASS(PropDataPortal, PropDataEntry);
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<PropData2D> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataPortal2D();
~PropDataPortal2D();
PropDataPortal();
~PropDataPortal();
protected:
static void _bind_methods();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,60 +20,60 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_data_prop_2d.h"
#include "prop_data_prop.h"
#include "../prop_instance_2d.h"
#include "prop_data_2d.h"
#include "../prop_instance.h"
#include "prop_data.h"
Ref<PropData2D> PropDataProp2D::get_prop() const {
Ref<PropData> PropDataProp::get_prop() const {
return _prop;
}
void PropDataProp2D::set_prop(const Ref<PropData2D> value) {
void PropDataProp::set_prop(const Ref<PropData> value) {
_prop = value;
}
bool PropDataProp2D::get_snap_to_mesh() {
bool PropDataProp::get_snap_to_mesh() {
return _snap_to_mesh;
}
void PropDataProp2D::set_snap_to_mesh(bool value) {
void PropDataProp::set_snap_to_mesh(bool value) {
_snap_to_mesh = value;
}
Vector3 PropDataProp2D::get_snap_axis() {
Vector3 PropDataProp::get_snap_axis() {
return _snap_axis;
}
void PropDataProp2D::set_snap_axis(Vector3 value) {
void PropDataProp::set_snap_axis(Vector3 value) {
_snap_axis = value;
}
#if TEXTURE_PACKER_PRESENT
void PropDataProp2D::_add_textures_into(Ref<TexturePacker> texture_packer) {
void PropDataProp::_add_textures_into(Ref<TexturePacker> texture_packer) {
if (get_prop().is_valid()) {
get_prop()->add_textures_into(texture_packer);
}
}
#endif
bool PropDataProp2D::_processor_handles(Node *node) {
PropInstance2D *i = Object::cast_to<PropInstance2D>(node);
bool PropDataProp::_processor_handles(Node *node) {
PropInstance *i = Object::cast_to<PropInstance>(node);
return i;
}
void PropDataProp2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
PropInstance2D *i = Object::cast_to<PropInstance2D>(node);
void PropDataProp::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
PropInstance *i = Object::cast_to<PropInstance>(node);
ERR_FAIL_COND(!i);
Ref<PropDataProp2D> l;
Ref<PropDataProp> l;
l.instance();
l->set_prop(i->get_prop_data());
l->set_transform(transform * i->get_transform());
prop_data->add_prop(l);
}
Node *PropDataProp2D::_processor_get_node_for(const Transform &transform) {
PropInstance2D *i = memnew(PropInstance2D);
Node *PropDataProp::_processor_get_node_for(const Transform &transform) {
PropInstance *i = memnew(PropInstance);
i->set_prop_data(get_prop());
i->set_transform(get_transform());
@ -81,29 +81,29 @@ Node *PropDataProp2D::_processor_get_node_for(const Transform &transform) {
return i;
}
PropDataProp2D::PropDataProp2D() {
PropDataProp::PropDataProp() {
_snap_to_mesh = false;
_snap_axis = Vector3(0, 1, 0);
}
PropDataProp2D::~PropDataProp2D() {
PropDataProp::~PropDataProp() {
if (_prop.is_valid())
_prop.unref();
}
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");
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");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
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);
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);
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"), &PropDataProp2D::_add_textures_into);
ClassDB::bind_method(D_METHOD("_add_textures_into", "texture_packer"), &PropDataProp::_add_textures_into);
#endif
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,24 +20,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_DATA_PROP_2D_H
#define PROP_DATA_PROP_2D_H
#ifndef PROP_DATA_PROP_H
#define PROP_DATA_PROP_H
#include "core/math/vector3.h"
#include "prop_data_entry_2d.h"
#include "prop_data_entry.h"
#include "prop_data_2d.h"
#include "prop_data.h"
#if TEXTURE_PACKER_PRESENT
#include "../../texture_packer/texture_packer.h"
#endif
class PropDataProp2D : public PropDataEntry2D {
GDCLASS(PropDataProp2D, PropDataEntry2D);
class PropDataProp : public PropDataEntry {
GDCLASS(PropDataProp, PropDataEntry);
public:
Ref<PropData2D> get_prop() const;
void set_prop(const Ref<PropData2D> value);
Ref<PropData> get_prop() const;
void set_prop(const Ref<PropData> 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<PropData2D> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataProp2D();
~PropDataProp2D();
PropDataProp();
~PropDataProp();
protected:
static void _bind_methods();
@ -62,7 +62,7 @@ protected:
private:
bool _snap_to_mesh;
Vector3 _snap_axis;
Ref<PropData2D> _prop;
Ref<PropData> _prop;
};
#endif

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,52 +20,52 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_data_scene_2d.h"
#include "prop_data_scene.h"
#include "../prop_scene_instance_2d.h"
#include "prop_data_2d.h"
#include "../prop_scene_instance.h"
#include "prop_data.h"
Ref<PackedScene> PropDataScene2D::get_scene() {
Ref<PackedScene> PropDataScene::get_scene() {
return _scene;
}
void PropDataScene2D::set_scene(const Ref<PackedScene> &value) {
void PropDataScene::set_scene(const Ref<PackedScene> &value) {
_scene = value;
}
bool PropDataScene2D::get_snap_to_mesh() {
bool PropDataScene::get_snap_to_mesh() {
return _snap_to_mesh;
}
void PropDataScene2D::set_snap_to_mesh(bool value) {
void PropDataScene::set_snap_to_mesh(bool value) {
_snap_to_mesh = value;
}
Vector3 PropDataScene2D::get_snap_axis() {
Vector3 PropDataScene::get_snap_axis() {
return _snap_axis;
}
void PropDataScene2D::set_snap_axis(Vector3 value) {
void PropDataScene::set_snap_axis(Vector3 value) {
_snap_axis = value;
}
bool PropDataScene2D::_processor_handles(Node *node) {
PropSceneInstance2D *i = Object::cast_to<PropSceneInstance2D>(node);
bool PropDataScene::_processor_handles(Node *node) {
PropSceneInstance *i = Object::cast_to<PropSceneInstance>(node);
return i;
}
void PropDataScene2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
PropSceneInstance2D *i = Object::cast_to<PropSceneInstance2D>(node);
void PropDataScene::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
PropSceneInstance *i = Object::cast_to<PropSceneInstance>(node);
ERR_FAIL_COND(!i);
Ref<PropDataScene2D> l;
Ref<PropDataScene> l;
l.instance();
l->set_scene(i->get_scene());
l->set_transform(transform * i->get_transform());
prop_data->add_prop(l);
}
Node *PropDataScene2D::_processor_get_node_for(const Transform &transform) {
PropSceneInstance2D *i = memnew(PropSceneInstance2D);
Node *PropDataScene::_processor_get_node_for(const Transform &transform) {
PropSceneInstance *i = memnew(PropSceneInstance);
i->set_scene(get_scene());
i->set_transform(get_transform());
@ -73,25 +73,25 @@ Node *PropDataScene2D::_processor_get_node_for(const Transform &transform) {
return i;
}
PropDataScene2D::PropDataScene2D() {
PropDataScene::PropDataScene() {
_snap_to_mesh = true;
_snap_axis = Vector3(0, 1, 0);
}
PropDataScene2D::~PropDataScene2D() {
PropDataScene::~PropDataScene() {
if (_scene.is_valid())
_scene.unref();
}
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,16 +20,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_DATA_SCENE_2D_H
#define PROP_DATA_SCENE_2D_H
#ifndef PROP_DATA_SCENE_H
#define PROP_DATA_SCENE_H
#include "core/math/vector3.h"
#include "prop_data_entry_2d.h"
#include "prop_data_entry.h"
#include "scene/resources/packed_scene.h"
class PropDataScene2D : public PropDataEntry2D {
GDCLASS(PropDataScene2D, PropDataEntry2D);
class PropDataScene : public PropDataEntry {
GDCLASS(PropDataScene, PropDataEntry);
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<PropData2D> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataScene2D();
~PropDataScene2D();
PropDataScene();
~PropDataScene();
protected:
static void _bind_methods();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,53 +20,53 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_data_tiled_wall_2d.h"
#include "prop_data_tiled_wall.h"
#include "../tiled_wall/tiled_wall_2d.h"
#include "../tiled_wall/tiled_wall_data_2d.h"
#include "../tiled_wall/tiled_wall.h"
#include "../tiled_wall/tiled_wall_data.h"
#include "prop_data_2d.h"
#include "prop_data.h"
int PropDataTiledWall2D::get_width() const {
int PropDataTiledWall::get_width() const {
return _width;
}
void PropDataTiledWall2D::set_width(const int value) {
void PropDataTiledWall::set_width(const int value) {
_width = value;
}
int PropDataTiledWall2D::get_heigth() const {
int PropDataTiledWall::get_heigth() const {
return _height;
}
void PropDataTiledWall2D::set_heigth(const int value) {
void PropDataTiledWall::set_heigth(const int value) {
_height = value;
}
Ref<TiledWallData2D> PropDataTiledWall2D::get_data() {
Ref<TiledWallData> PropDataTiledWall::get_data() {
return _data;
}
void PropDataTiledWall2D::set_data(const Ref<TiledWallData2D> &data) {
void PropDataTiledWall::set_data(const Ref<TiledWallData> &data) {
_data = data;
}
bool PropDataTiledWall2D::get_collision() const {
bool PropDataTiledWall::get_collision() const {
return _collision;
}
void PropDataTiledWall2D::set_collision(const int value) {
void PropDataTiledWall::set_collision(const int value) {
_collision = value;
}
bool PropDataTiledWall2D::_processor_handles(Node *node) {
TiledWall2D *t = Object::cast_to<TiledWall2D>(node);
bool PropDataTiledWall::_processor_handles(Node *node) {
TiledWall *t = Object::cast_to<TiledWall>(node);
return t;
}
void PropDataTiledWall2D::_processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
TiledWall2D *t = Object::cast_to<TiledWall2D>(node);
void PropDataTiledWall::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
TiledWall *t = Object::cast_to<TiledWall>(node);
ERR_FAIL_COND(!t);
Ref<PropDataTiledWall2D> tw;
Ref<PropDataTiledWall> tw;
tw.instance();
tw->set_width(t->get_width());
@ -77,8 +77,8 @@ void PropDataTiledWall2D::_processor_process(Ref<PropData2D> prop_data, Node *no
prop_data->add_prop(tw);
}
Node *PropDataTiledWall2D::_processor_get_node_for(const Transform &transform) {
TiledWall2D *t = memnew(TiledWall2D);
Node *PropDataTiledWall::_processor_get_node_for(const Transform &transform) {
TiledWall *t = memnew(TiledWall);
t->set_width(get_width());
t->set_heigth(get_heigth());
@ -89,29 +89,29 @@ Node *PropDataTiledWall2D::_processor_get_node_for(const Transform &transform) {
return t;
}
PropDataTiledWall2D::PropDataTiledWall2D() {
PropDataTiledWall::PropDataTiledWall() {
_width = 1;
_height = 1;
_collision = true;
}
PropDataTiledWall2D::~PropDataTiledWall2D() {
PropDataTiledWall::~PropDataTiledWall() {
_data.unref();
}
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::INT, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_heigth"), &PropDataTiledWall2D::get_heigth);
ClassDB::bind_method(D_METHOD("set_heigth", "value"), &PropDataTiledWall2D::set_heigth);
ClassDB::bind_method(D_METHOD("get_heigth"), &PropDataTiledWall::get_heigth);
ClassDB::bind_method(D_METHOD("set_heigth", "value"), &PropDataTiledWall::set_heigth);
ADD_PROPERTY(PropertyInfo(Variant::INT, "heigth"), "set_heigth", "get_heigth");
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_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_collision"), &PropDataTiledWall2D::get_collision);
ClassDB::bind_method(D_METHOD("set_collision", "value"), &PropDataTiledWall2D::set_collision);
ClassDB::bind_method(D_METHOD("get_collision"), &PropDataTiledWall::get_collision);
ClassDB::bind_method(D_METHOD("set_collision", "value"), &PropDataTiledWall::set_collision);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision"), "set_collision", "get_collision");
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,16 +20,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_DATA_TILED_WALL_2D_H
#define PROP_DATA_TILED_WALL_2D_H
#ifndef PROP_DATA_TILED_WALL_H
#define PROP_DATA_TILED_WALL_H
#include "core/math/vector3.h"
#include "prop_data_entry_2d.h"
#include "prop_data_entry.h"
class TiledWallData2D;
class TiledWallData;
class PropDataTiledWall2D : public PropDataEntry2D {
GDCLASS(PropDataTiledWall2D, PropDataEntry2D);
class PropDataTiledWall : public PropDataEntry {
GDCLASS(PropDataTiledWall, PropDataEntry);
public:
int get_width() const;
@ -38,18 +38,18 @@ public:
int get_heigth() const;
void set_heigth(const int value);
Ref<TiledWallData2D> get_data();
void set_data(const Ref<TiledWallData2D> &data);
Ref<TiledWallData> get_data();
void set_data(const Ref<TiledWallData> &data);
bool get_collision() const;
void set_collision(const int value);
bool _processor_handles(Node *node);
void _processor_process(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataTiledWall2D();
~PropDataTiledWall2D();
PropDataTiledWall();
~PropDataTiledWall();
protected:
static void _bind_methods();
@ -59,7 +59,7 @@ private:
int _height;
bool _collision;
Ref<TiledWallData2D> _data;
Ref<TiledWallData> _data;
};
#endif

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -30,121 +30,121 @@ SOFTWARE.
#include "core/engine.h"
#endif
#include "tiled_wall/tiled_wall_2d.h"
#include "tiled_wall/tiled_wall_data_2d.h"
#include "tiled_wall/tiled_wall.h"
#include "tiled_wall/tiled_wall_data.h"
#include "props/prop_data_2d.h"
#include "props/prop_data_entry_2d.h"
#include "props/prop_data_light_2d.h"
#include "props/prop_data_prop_2d.h"
#include "props/prop_data_scene_2d.h"
#include "props/prop_data_tiled_wall_2d.h"
#include "props/prop_data.h"
#include "props/prop_data_entry.h"
#include "props/prop_data_light.h"
#include "props/prop_data_prop.h"
#include "props/prop_data_scene.h"
#include "props/prop_data_tiled_wall.h"
#if VERSION_MINOR >= 4
#include "props/prop_data_portal_2d.h"
#include "props/prop_data_portal.h"
#endif
#include "clutter/ground_clutter_2d.h"
#include "clutter/ground_clutter_foliage_2d.h"
#include "clutter/ground_clutter.h"
#include "clutter/ground_clutter_foliage.h"
#include "prop_ess_entity_2d.h"
#include "prop_instance_2d.h"
#include "prop_instance_merger_2d.h"
#include "prop_ess_entity.h"
#include "prop_instance.h"
#include "prop_instance_merger.h"
#include "prop_instance_job_2d.h"
#include "prop_instance_prop_job_2d.h"
#include "prop_instance_job.h"
#include "prop_instance_prop_job.h"
#include "jobs/prop_mesher_job_step_2d.h"
#include "jobs/prop_texture_job_2d.h"
#include "jobs/prop_mesher_job_step.h"
#include "jobs/prop_texture_job.h"
#include "prop_scene_instance_2d.h"
#include "prop_scene_instance.h"
#include "singleton/prop_cache_2d.h"
#include "singleton/prop_utils_2d.h"
#include "singleton/prop_cache.h"
#include "singleton/prop_utils.h"
#include "lights/prop_light_2d.h"
#include "lights/prop_light.h"
#include "./editor/prop_editor_plugin_2d.h"
#include "./editor/prop_editor_plugin.h"
#include "prop_mesher_2d.h"
#include "prop_mesher.h"
#include "material_cache/prop_material_cache_2d.h"
#include "material_cache/prop_material_cache.h"
#ifdef TEXTURE_PACKER_PRESENT
#include "material_cache/prop_material_cache_pcm_2d.h"
#include "material_cache/prop_material_cache_pcm.h"
#endif
static PropUtils2D *prop_utils = NULL;
static PropCache2D *prop_texture_cache = NULL;
static PropUtils *prop_utils = NULL;
static PropCache *prop_texture_cache = NULL;
void register_props_2d_types() {
ClassDB::register_class<TiledWall2D>();
ClassDB::register_class<TiledWallData2D>();
ClassDB::register_class<TiledWall>();
ClassDB::register_class<TiledWallData>();
ClassDB::register_class<PropLight2D>();
ClassDB::register_class<PropLight>();
ClassDB::register_class<PropData2D>();
ClassDB::register_class<PropDataEntry2D>();
ClassDB::register_class<PropDataScene2D>();
ClassDB::register_class<PropDataLight2D>();
ClassDB::register_class<PropDataProp2D>();
ClassDB::register_class<PropDataTiledWall2D>();
ClassDB::register_class<PropData>();
ClassDB::register_class<PropDataEntry>();
ClassDB::register_class<PropDataScene>();
ClassDB::register_class<PropDataLight>();
ClassDB::register_class<PropDataProp>();
ClassDB::register_class<PropDataTiledWall>();
#if VERSION_MINOR >= 4
ClassDB::register_class<PropDataPortal2D>();
ClassDB::register_class<PropDataPortal>();
#endif
ClassDB::register_class<GroundClutter2D>();
ClassDB::register_class<GroundClutterFoliage2D>();
ClassDB::register_class<GroundClutter>();
ClassDB::register_class<GroundClutterFoliage>();
ClassDB::register_class<PropMesher2D>();
ClassDB::register_class<PropMesherJobStep2D>();
ClassDB::register_class<PropMesher>();
ClassDB::register_class<PropMesherJobStep>();
ClassDB::register_class<PropInstance2D>();
ClassDB::register_class<PropInstanceMerger2D>();
ClassDB::register_class<PropInstance>();
ClassDB::register_class<PropInstanceMerger>();
ClassDB::register_class<PropESSEntity2D>();
ClassDB::register_class<PropESSEntity>();
ClassDB::register_class<PropInstanceJob2D>();
ClassDB::register_class<PropInstancePropJob2D>();
ClassDB::register_class<PropInstanceJob>();
ClassDB::register_class<PropInstancePropJob>();
ClassDB::register_class<PropTextureJob2D>();
ClassDB::register_class<PropTextureJob>();
ClassDB::register_class<PropSceneInstance2D>();
ClassDB::register_class<PropSceneInstance>();
ClassDB::register_class<PropMaterialCache2D>();
ClassDB::register_class<PropMaterialCache>();
#ifdef TEXTURE_PACKER_PRESENT
ClassDB::register_class<PropMaterialCachePCM2D>();
ClassDB::register_class<PropMaterialCachePCM>();
#endif
prop_utils = memnew(PropUtils2D);
ClassDB::register_class<PropUtils2D>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils2D", PropUtils2D::get_singleton()));
prop_utils = memnew(PropUtils);
ClassDB::register_class<PropUtils>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton()));
prop_texture_cache = memnew(PropCache2D);
ClassDB::register_class<PropCache2D>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache2D", PropCache2D::get_singleton()));
prop_texture_cache = memnew(PropCache);
ClassDB::register_class<PropCache>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton()));
Ref<PropDataLight2D> light_processor = Ref<PropDataLight2D>(memnew(PropDataLight2D));
PropUtils2D::add_processor(light_processor);
Ref<PropDataLight> light_processor = Ref<PropDataLight>(memnew(PropDataLight));
PropUtils::add_processor(light_processor);
Ref<PropDataProp2D> prop_processor = Ref<PropDataProp2D>(memnew(PropDataProp2D));
PropUtils2D::add_processor(prop_processor);
Ref<PropDataProp> prop_processor = Ref<PropDataProp>(memnew(PropDataProp));
PropUtils::add_processor(prop_processor);
Ref<PropDataScene2D> scene_processor = Ref<PropDataScene2D>(memnew(PropDataScene2D));
PropUtils2D::add_processor(scene_processor);
Ref<PropDataScene> scene_processor = Ref<PropDataScene>(memnew(PropDataScene));
PropUtils::add_processor(scene_processor);
#if VERSION_MINOR >= 4
Ref<PropDataPortal2D> portal_processor = Ref<PropDataPortal2D>(memnew(PropDataPortal2D));
PropUtils2D::add_processor(portal_processor);
Ref<PropDataPortal> portal_processor = Ref<PropDataPortal>(memnew(PropDataPortal));
PropUtils::add_processor(portal_processor);
#endif
Ref<PropDataTiledWall2D> tiled_wall_processor = Ref<PropDataTiledWall2D>(memnew(PropDataTiledWall2D));
PropUtils2D::add_processor(tiled_wall_processor);
Ref<PropDataTiledWall> tiled_wall_processor = Ref<PropDataTiledWall>(memnew(PropDataTiledWall));
PropUtils::add_processor(tiled_wall_processor);
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<PropEditorPlugin2D>();
EditorPlugins::add_by_type<PropEditorPlugin>();
#endif
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROPS_2D_REGISTER_TYPES_H
#define PROPS_2D_REGISTER_TYPES_H
#ifndef PROPS_REGISTER_TYPES_H
#define PROPS_REGISTER_TYPES_H
void register_props_2d_types();
void unregister_props_2d_types();

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_cache_2d.h"
#include "prop_cache.h"
#include "../props/prop_data_2d.h"
#include "../props/prop_data_entry_2d.h"
#include "../props/prop_data.h"
#include "../props/prop_data_entry.h"
#include "core/version.h"
@ -35,14 +35,14 @@ SOFTWARE.
#include "core/project_settings.h"
#endif
#include "../jobs/prop_texture_job_2d.h"
#include "../jobs/prop_texture_job.h"
#if THREAD_POOL_PRESENT
#include "../../thread_pool/thread_pool.h"
#endif
#include "../material_cache/prop_material_cache_2d.h"
#include "../tiled_wall/tiled_wall_data_2d.h"
#include "../material_cache/prop_material_cache.h"
#include "../tiled_wall/tiled_wall_data.h"
#include "core/hashfuncs.h"
@ -66,94 +66,94 @@ SOFTWARE.
#endif
PropCache2D *PropCache2D::_instance;
PropCache *PropCache::_instance;
PropCache2D *PropCache2D::get_singleton() {
PropCache *PropCache::get_singleton() {
return _instance;
}
StringName PropCache2D::get_default_prop_material_cache_class() {
StringName PropCache::get_default_prop_material_cache_class() {
return _default_prop_material_cache_class;
}
void PropCache2D::set_default_prop_material_cache_class(const StringName &cls_name) {
void PropCache::set_default_prop_material_cache_class(const StringName &cls_name) {
_default_prop_material_cache_class = cls_name;
}
#ifdef TEXTURE_PACKER_PRESENT
int PropCache2D::get_texture_flags() const {
int PropCache::get_texture_flags() const {
return _texture_flags;
}
void PropCache2D::set_texture_flags(const int flags) {
void PropCache::set_texture_flags(const int flags) {
_texture_flags = flags;
}
int PropCache2D::get_max_atlas_size() const {
int PropCache::get_max_atlas_size() const {
return _max_atlas_size;
}
void PropCache2D::set_max_atlas_size(const int size) {
void PropCache::set_max_atlas_size(const int size) {
_max_atlas_size = size;
}
bool PropCache2D::get_keep_original_atlases() const {
bool PropCache::get_keep_original_atlases() const {
return _keep_original_atlases;
}
void PropCache2D::set_keep_original_atlases(const bool value) {
void PropCache::set_keep_original_atlases(const bool value) {
_keep_original_atlases = value;
}
Color PropCache2D::get_background_color() const {
Color PropCache::get_background_color() const {
return _background_color;
}
void PropCache2D::set_background_color(const Color &color) {
void PropCache::set_background_color(const Color &color) {
_background_color = color;
}
int PropCache2D::get_margin() const {
int PropCache::get_margin() const {
return _margin;
}
void PropCache2D::set_margin(const int margin) {
void PropCache::set_margin(const int margin) {
_margin = margin;
}
#endif
PoolStringArray PropCache2D::material_paths_get() const {
PoolStringArray PropCache::material_paths_get() const {
return _material_paths;
}
void PropCache2D::material_paths_set(const PoolStringArray &value) {
void PropCache::material_paths_set(const PoolStringArray &value) {
_material_paths = value;
}
void PropCache2D::material_add(const Ref<Material> &value) {
void PropCache::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
Ref<Material> PropCache2D::material_get(const int index) {
Ref<Material> PropCache::material_get(const int index) {
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>());
return _materials[index];
}
void PropCache2D::material_set(const int index, const Ref<Material> &value) {
void PropCache::material_set(const int index, const Ref<Material> &value) {
ERR_FAIL_INDEX(index, _materials.size());
_materials.set(index, value);
}
void PropCache2D::material_remove(const int index) {
void PropCache::material_remove(const int index) {
_materials.remove(index);
}
int PropCache2D::material_get_num() const {
int PropCache::material_get_num() const {
return _materials.size();
}
void PropCache2D::materials_clear() {
void PropCache::materials_clear() {
_materials.clear();
}
void PropCache2D::materials_load() {
void PropCache::materials_load() {
_materials.clear();
for (int i = 0; i < _material_paths.size(); ++i) {
@ -169,17 +169,17 @@ void PropCache2D::materials_load() {
}
}
void PropCache2D::ensure_materials_loaded() {
void PropCache::ensure_materials_loaded() {
if (_materials.size() != _material_paths.size()) {
materials_load();
}
}
Vector<Variant> PropCache2D::materials_get() {
Vector<Variant> PropCache::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void PropCache2D::materials_set(const Vector<Variant> &materials) {
void PropCache::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
@ -189,16 +189,16 @@ void PropCache2D::materials_set(const Vector<Variant> &materials) {
}
}
Ref<PropMaterialCache2D> PropCache2D::material_cache_get(const Ref<PropData2D> &prop) {
ERR_FAIL_COND_V(!prop.is_valid(), Ref<PropMaterialCache2D>());
Ref<PropMaterialCache> PropCache::material_cache_get(const Ref<PropData> &prop) {
ERR_FAIL_COND_V(!prop.is_valid(), Ref<PropMaterialCache>());
//get pointer's value as uint64
uint64_t k = make_uint64_t<const PropData2D *>(*prop);
uint64_t k = make_uint64_t<const PropData *>(*prop);
_material_cache_mutex.lock();
if (_material_cache.has(k)) {
Ref<PropMaterialCache2D> m = _material_cache[k];
Ref<PropMaterialCache> m = _material_cache[k];
m->inc_ref_count();
@ -207,13 +207,13 @@ Ref<PropMaterialCache2D> PropCache2D::material_cache_get(const Ref<PropData2D> &
return m;
}
PropMaterialCache2D *p = Object::cast_to<PropMaterialCache2D>(ClassDB::instance(_default_prop_material_cache_class));
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instance(_default_prop_material_cache_class));
if (!p) {
ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class));
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
}
Ref<PropMaterialCache2D> m(p);
Ref<PropMaterialCache> m(p);
_material_cache[k] = m;
@ -221,21 +221,21 @@ Ref<PropMaterialCache2D> PropCache2D::material_cache_get(const Ref<PropData2D> &
return m;
}
void PropCache2D::material_cache_unref(const Ref<PropData2D> &prop) {
void PropCache::material_cache_unref(const Ref<PropData> &prop) {
//get pointer's value as uint64
uint64_t k = make_uint64_t<const PropData2D *>(*prop);
uint64_t k = make_uint64_t<const PropData *>(*prop);
_material_cache_mutex.lock();
if (!_material_cache.has(k)) {
_material_cache_mutex.unlock();
ERR_PRINT("PropCache2D::material_cache_unref: can't find cache!");
ERR_PRINT("PropCache::material_cache_unref: can't find cache!");
return;
}
Ref<PropMaterialCache2D> m = _material_cache[k];
Ref<PropMaterialCache> m = _material_cache[k];
m->dec_ref_count();
if (m->get_ref_count() <= 0) {
@ -245,16 +245,16 @@ void PropCache2D::material_cache_unref(const Ref<PropData2D> &prop) {
_material_cache_mutex.unlock();
}
Ref<PropMaterialCache2D> PropCache2D::tiled_wall_material_cache_get(const Ref<TiledWallData2D> &twd) {
ERR_FAIL_COND_V(!twd.is_valid(), Ref<PropMaterialCache2D>());
Ref<PropMaterialCache> PropCache::tiled_wall_material_cache_get(const Ref<TiledWallData> &twd) {
ERR_FAIL_COND_V(!twd.is_valid(), Ref<PropMaterialCache>());
//get pointer's value as uint64
uint64_t k = make_uint64_t<const TiledWallData2D *>(*twd);
uint64_t k = make_uint64_t<const TiledWallData *>(*twd);
_tiled_wall_material_cache_mutex.lock();
if (_tiled_wall_material_cache.has(k)) {
Ref<PropMaterialCache2D> m = _tiled_wall_material_cache[k];
Ref<PropMaterialCache> m = _tiled_wall_material_cache[k];
m->inc_ref_count();
@ -263,13 +263,13 @@ Ref<PropMaterialCache2D> PropCache2D::tiled_wall_material_cache_get(const Ref<Ti
return m;
}
PropMaterialCache2D *p = Object::cast_to<PropMaterialCache2D>(ClassDB::instance(_default_prop_material_cache_class));
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instance(_default_prop_material_cache_class));
if (!p) {
ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class));
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
}
Ref<PropMaterialCache2D> m(p);
Ref<PropMaterialCache> m(p);
_tiled_wall_material_cache[k] = m;
@ -277,21 +277,21 @@ Ref<PropMaterialCache2D> PropCache2D::tiled_wall_material_cache_get(const Ref<Ti
return m;
}
void PropCache2D::tiled_wall_material_cache_unref(const Ref<TiledWallData2D> &twd) {
void PropCache::tiled_wall_material_cache_unref(const Ref<TiledWallData> &twd) {
//get pointer's value as uint64
uint64_t k = make_uint64_t<const TiledWallData2D *>(*twd);
uint64_t k = make_uint64_t<const TiledWallData *>(*twd);
_tiled_wall_material_cache_mutex.lock();
if (!_tiled_wall_material_cache.has(k)) {
_tiled_wall_material_cache_mutex.unlock();
ERR_PRINT("PropCache2D::material_cache_unref: can't find cache!");
ERR_PRINT("PropCache::material_cache_unref: can't find cache!");
return;
}
Ref<PropMaterialCache2D> m = _tiled_wall_material_cache[k];
Ref<PropMaterialCache> m = _tiled_wall_material_cache[k];
m->dec_ref_count();
if (m->get_ref_count() <= 0) {
@ -301,11 +301,11 @@ void PropCache2D::tiled_wall_material_cache_unref(const Ref<TiledWallData2D> &tw
_tiled_wall_material_cache_mutex.unlock();
}
Ref<PropMaterialCache2D> PropCache2D::material_cache_custom_key_get(const uint64_t key) {
Ref<PropMaterialCache> PropCache::material_cache_custom_key_get(const uint64_t key) {
_custom_keyed_material_cache_mutex.lock();
if (_custom_keyed_material_cache.has(key)) {
Ref<PropMaterialCache2D> m = _custom_keyed_material_cache[key];
Ref<PropMaterialCache> m = _custom_keyed_material_cache[key];
m->inc_ref_count();
@ -314,13 +314,13 @@ Ref<PropMaterialCache2D> PropCache2D::material_cache_custom_key_get(const uint64
return m;
}
PropMaterialCache2D *p = Object::cast_to<PropMaterialCache2D>(ClassDB::instance(_default_prop_material_cache_class));
PropMaterialCache *p = Object::cast_to<PropMaterialCache>(ClassDB::instance(_default_prop_material_cache_class));
if (!p) {
ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class));
ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class));
}
Ref<PropMaterialCache2D> m(p);
Ref<PropMaterialCache> m(p);
_custom_keyed_material_cache[key] = m;
@ -328,18 +328,18 @@ Ref<PropMaterialCache2D> PropCache2D::material_cache_custom_key_get(const uint64
return m;
}
void PropCache2D::material_cache_custom_key_unref(const uint64_t key) {
void PropCache::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("PropCache2D::material_cache_custom_key_unref: can't find cache!");
ERR_PRINT("PropCache::material_cache_custom_key_unref: can't find cache!");
return;
}
Ref<PropMaterialCache2D> m = _custom_keyed_material_cache[key];
Ref<PropMaterialCache> m = _custom_keyed_material_cache[key];
m->dec_ref_count();
if (m->get_ref_count() <= 0) {
@ -349,7 +349,7 @@ void PropCache2D::material_cache_custom_key_unref(const uint64_t key) {
_custom_keyed_material_cache_mutex.unlock();
}
Ref<Resource> PropCache2D::load_resource(const String &path, const String &type_hint) {
Ref<Resource> PropCache::load_resource(const String &path, const String &type_hint) {
_ResourceLoader *rl = _ResourceLoader::get_singleton();
#if VERSION_MAJOR < 4
@ -365,13 +365,13 @@ Ref<Resource> PropCache2D::load_resource(const String &path, const String &type_
#endif
}
PropCache2D::PropCache2D() {
PropCache::PropCache() {
_instance = this;
#if TEXTURE_PACKER_PRESENT
_default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache2DPCM");
_default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCachePCM");
#else
_default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache2D");
_default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache");
#endif
#ifdef TEXTURE_PACKER_PRESENT
@ -390,62 +390,62 @@ PropCache2D::PropCache2D() {
_material_paths = GLOBAL_DEF("props/material_paths", PoolStringArray());
}
PropCache2D::~PropCache2D() {
PropCache::~PropCache() {
_instance = NULL;
}
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);
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);
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"), &PropCache2D::get_texture_flags);
ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropCache2D::set_texture_flags);
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);
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"), &PropCache2D::get_max_atlas_size);
ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropCache2D::set_max_atlas_size);
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);
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"), &PropCache2D::get_keep_original_atlases);
ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropCache2D::set_keep_original_atlases);
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);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases");
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);
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);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color");
ClassDB::bind_method(D_METHOD("get_margin"), &PropCache2D::get_margin);
ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropCache2D::set_margin);
ClassDB::bind_method(D_METHOD("get_margin"), &PropCache::get_margin);
ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropCache::set_margin);
ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin");
#endif
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);
ClassDB::bind_method(D_METHOD("material_paths_get"), &PropCache::material_paths_get);
ClassDB::bind_method(D_METHOD("material_paths_set", "value"), &PropCache::material_paths_set);
ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "material_paths"), "material_paths_set", "material_paths_get");
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("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("materials_get"), &PropCache2D::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropCache2D::materials_set);
ClassDB::bind_method(D_METHOD("materials_get"), &PropCache::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &PropCache::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"), &PropCache2D::material_cache_get);
ClassDB::bind_method(D_METHOD("material_cache_unref", "prop"), &PropCache2D::material_cache_unref);
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("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("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("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("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("load_resource", "path", "type_hint"), &PropCache2D::load_resource, "");
ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &PropCache::load_resource, "");
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_CACHE_2D_H
#define PROP_CACHE_2D_H
#ifndef PROP_CACHE_H
#define PROP_CACHE_H
#include "core/version.h"
@ -45,16 +45,16 @@ SOFTWARE.
#include "core/os/mutex.h"
#include "../props/prop_data_2d.h"
#include "../props/prop_data.h"
class PropMaterialCache2D;
class TiledWallData2D;
class PropMaterialCache;
class TiledWallData;
class PropCache2D : public Object {
GDCLASS(PropCache2D, Object);
class PropCache : public Object {
GDCLASS(PropCache, Object);
public:
static PropCache2D *get_singleton();
static PropCache *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<PropMaterialCache2D> material_cache_get(const Ref<PropData2D> &prop);
void material_cache_unref(const Ref<PropData2D> &prop);
Ref<PropMaterialCache> material_cache_get(const Ref<PropData> &prop);
void material_cache_unref(const Ref<PropData> &prop);
Ref<PropMaterialCache2D> tiled_wall_material_cache_get(const Ref<TiledWallData2D> &twd);
void tiled_wall_material_cache_unref(const Ref<TiledWallData2D> &twd);
Ref<PropMaterialCache> tiled_wall_material_cache_get(const Ref<TiledWallData> &twd);
void tiled_wall_material_cache_unref(const Ref<TiledWallData> &twd);
Ref<PropMaterialCache2D> material_cache_custom_key_get(const uint64_t key);
Ref<PropMaterialCache> 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 PropCache2D *_instance;
static PropCache *_instance;
public:
PropCache2D();
~PropCache2D();
PropCache();
~PropCache();
protected:
static void _bind_methods();
StringName _default_prop_material_cache_class;
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;
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;
Mutex _material_cache_mutex;
Mutex _tiled_wall_material_cache_mutex;

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "prop_utils_2d.h"
#include "prop_utils.h"
#include "../props/prop_data_2d.h"
#include "../props/prop_data_entry_2d.h"
#include "../props/prop_data.h"
#include "../props/prop_data_entry.h"
#include "core/version.h"
@ -46,19 +46,19 @@ SOFTWARE.
#include "core/engine.h"
#endif
PropUtils2D *PropUtils2D::_instance;
Vector<Ref<PropDataEntry2D> > PropUtils2D::_processors;
PropUtils *PropUtils::_instance;
Vector<Ref<PropDataEntry> > PropUtils::_processors;
PropUtils2D *PropUtils2D::get_singleton() {
PropUtils *PropUtils::get_singleton() {
return _instance;
}
Ref<PropData2D> PropUtils2D::convert_tree(Node *root) {
Ref<PropData> PropUtils::convert_tree(Node *root) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref<PropData2D>());
ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref<PropData>());
#endif
Ref<PropData2D> data;
Ref<PropData> data;
data.instance();
Transform t;
@ -67,13 +67,13 @@ Ref<PropData2D> PropUtils2D::convert_tree(Node *root) {
return data;
}
void PropUtils2D::_convert_tree(Ref<PropData2D> prop_data, Node *node, const Transform &transform) {
void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transform &transform) {
#if VERSION_MAJOR < 4
ERR_FAIL_COND(!ObjectDB::instance_validate(node));
#endif
for (int i = 0; i < PropUtils2D::_processors.size(); ++i) {
Ref<PropDataEntry2D> proc = PropUtils2D::_processors.get(i);
for (int i = 0; i < PropUtils::_processors.size(); ++i) {
Ref<PropDataEntry> proc = PropUtils::_processors.get(i);
ERR_CONTINUE(!proc.is_valid());
@ -138,7 +138,7 @@ void PropUtils2D::_convert_tree(Ref<PropData2D> prop_data, Node *node, const Tra
}
#if VERSION_MINOR >= 4
bool PropUtils2D::generate_room_points_node(Node *node) {
bool PropUtils::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 PropUtils2D::generate_room_points_node(Node *node) {
return false;
}
void PropUtils2D::generate_room_points(Room *room) {
void PropUtils::generate_room_points(Room *room) {
ERR_FAIL_COND(!ObjectDB::instance_validate(room));
Vector<PoolVector<Vector3> > mesh_arrays;
@ -281,7 +281,7 @@ void PropUtils2D::generate_room_points(Room *room) {
}
//based on Room::SimplifyInfo::add_plane_if_unique
bool PropUtils2D::is_plane_unique(const PoolVector<Plane> &planes, const Plane &p) {
bool PropUtils::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 PropUtils2D::is_plane_unique(const PoolVector<Plane> &planes, const Plane &
return true;
}
void PropUtils2D::get_mesh_arrays(Node *node, Vector<PoolVector<Vector3> > *arrs) {
void PropUtils::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 PropUtils2D::get_mesh_arrays(Node *node, Vector<PoolVector<Vector3> > *arrs
#endif
int PropUtils2D::add_processor(const Ref<PropDataEntry2D> &processor) {
int PropUtils::add_processor(const Ref<PropDataEntry> &processor) {
ERR_FAIL_COND_V(!processor.is_valid(), 0);
PropUtils2D::_processors.push_back(processor);
PropUtils::_processors.push_back(processor);
return PropUtils2D::_processors.size() - 1;
return PropUtils::_processors.size() - 1;
}
Ref<PropDataEntry2D> PropUtils2D::get_processor(const int index) {
ERR_FAIL_INDEX_V(index, PropUtils2D::_processors.size(), Ref<PropDataEntry2D>());
Ref<PropDataEntry> PropUtils::get_processor(const int index) {
ERR_FAIL_INDEX_V(index, PropUtils::_processors.size(), Ref<PropDataEntry>());
return PropUtils2D::_processors[index];
return PropUtils::_processors[index];
}
void PropUtils2D::swap_processors(const int index1, const int index2) {
ERR_FAIL_INDEX(index1, PropUtils2D::_processors.size());
ERR_FAIL_INDEX(index2, PropUtils2D::_processors.size());
void PropUtils::swap_processors(const int index1, const int index2) {
ERR_FAIL_INDEX(index1, PropUtils::_processors.size());
ERR_FAIL_INDEX(index2, PropUtils::_processors.size());
Ref<PropDataEntry2D> a = PropUtils2D::_processors.get(index1);
PropUtils2D::_processors.set(index1, PropUtils2D::_processors.get(index2));
PropUtils2D::_processors.set(index2, a);
Ref<PropDataEntry> a = PropUtils::_processors.get(index1);
PropUtils::_processors.set(index1, PropUtils::_processors.get(index2));
PropUtils::_processors.set(index2, a);
}
void PropUtils2D::remove_processor(const int index) {
ERR_FAIL_INDEX(index, PropUtils2D::_processors.size());
void PropUtils::remove_processor(const int index) {
ERR_FAIL_INDEX(index, PropUtils::_processors.size());
PropUtils2D::_processors.remove(index);
PropUtils::_processors.remove(index);
}
int PropUtils2D::get_processor_count() {
return PropUtils2D::_processors.size();
int PropUtils::get_processor_count() {
return PropUtils::_processors.size();
}
PropUtils2D::PropUtils2D() {
PropUtils::PropUtils() {
_instance = this;
}
PropUtils2D::~PropUtils2D() {
PropUtils::~PropUtils() {
_instance = NULL;
PropUtils2D::_processors.clear();
PropUtils::_processors.clear();
}
void PropUtils2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils2D::convert_tree);
void PropUtils::_bind_methods() {
ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils::convert_tree);
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);
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);
}
int PropUtils2D::_add_processor_bind(const Ref<PropDataEntry2D> &processor) {
return PropUtils2D::add_processor(processor);
int PropUtils::_add_processor_bind(const Ref<PropDataEntry> &processor) {
return PropUtils::add_processor(processor);
}
Ref<PropDataEntry2D> PropUtils2D::_get_processor_bind(const int index) {
return PropUtils2D::get_processor(index);
Ref<PropDataEntry> PropUtils::_get_processor_bind(const int index) {
return PropUtils::get_processor(index);
}
void PropUtils2D::_swap_processors_bind(const int index1, const int index2) {
PropUtils2D::swap_processors(index1, index2);
void PropUtils::_swap_processors_bind(const int index1, const int index2) {
PropUtils::swap_processors(index1, index2);
}
void PropUtils2D::_remove_processor_bind(const int index) {
PropUtils2D::remove_processor(index);
void PropUtils::_remove_processor_bind(const int index) {
PropUtils::remove_processor(index);
}
int PropUtils2D::_get_processor_count_bind() {
return PropUtils2D::get_processor_count();
int PropUtils::_get_processor_count_bind() {
return PropUtils::get_processor_count();
}

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef PROP_UTILS_2D_H
#define PROP_UTILS_2D_H
#ifndef PROP_UTILS_H
#define PROP_UTILS_H
#include "core/version.h"
@ -39,21 +39,21 @@ SOFTWARE.
#include "scene/main/node.h"
class PropData2D;
class PropDataEntry2D;
class PropData;
class PropDataEntry;
#if VERSION_MINOR >= 4
class Room;
#endif
class PropUtils2D : public Object {
GDCLASS(PropUtils2D, Object);
class PropUtils : public Object {
GDCLASS(PropUtils, Object);
public:
static PropUtils2D *get_singleton();
static PropUtils *get_singleton();
Ref<PropData2D> convert_tree(Node *root);
void _convert_tree(Ref<PropData2D> prop_data, Node *node, const Transform &transform);
Ref<PropData> convert_tree(Node *root);
void _convert_tree(Ref<PropData> 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<PropDataEntry2D> &processor);
static Ref<PropDataEntry2D> get_processor(const int index);
static int add_processor(const Ref<PropDataEntry> &processor);
static Ref<PropDataEntry> 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();
PropUtils2D();
~PropUtils2D();
PropUtils();
~PropUtils();
protected:
static void _bind_methods();
private:
int _add_processor_bind(const Ref<PropDataEntry2D> &processor);
Ref<PropDataEntry2D> _get_processor_bind(const int index);
int _add_processor_bind(const Ref<PropDataEntry> &processor);
Ref<PropDataEntry> _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<PropDataEntry2D>> _processors;
static PropUtils2D *_instance;
static Vector<Ref<PropDataEntry>> _processors;
static PropUtils *_instance;
};
#endif

View File

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

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2020 Péter Magyar
Copyright (c) 2020-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef TILED_WALL_2D_H
#define TILED_WALL_2D_H
#ifndef TILED_WALL_H
#define TILED_WALL_H
#include "core/version.h"
#include "scene/resources/texture.h"
@ -38,12 +38,12 @@ SOFTWARE.
#include "core/math/vector3.h"
class TiledWallData2D;
class PropMaterialCache2D;
class PropMesher2D;
class TiledWallData;
class PropMaterialCache;
class PropMesher;
class TiledWall2D : public GeometryInstance {
GDCLASS(TiledWall2D, GeometryInstance);
class TiledWall : public GeometryInstance {
GDCLASS(TiledWall, GeometryInstance);
public:
int get_width() const;
@ -52,8 +52,8 @@ public:
int get_heigth() const;
void set_heigth(const int value);
Ref<TiledWallData2D> get_data();
void set_data(const Ref<TiledWallData2D> &data);
Ref<TiledWallData> get_data();
void set_data(const Ref<TiledWallData> &data);
bool get_collision() const;
void set_collision(const int value);
@ -75,8 +75,8 @@ public:
void create_colliders();
void free_colliders();
TiledWall2D();
~TiledWall2D();
TiledWall();
~TiledWall();
protected:
void _notification(int p_what);
@ -90,9 +90,9 @@ private:
uint32_t _collision_layer;
uint32_t _collision_mask;
Ref<TiledWallData2D> _data;
Ref<PropMaterialCache2D> _cache;
Ref<PropMesher2D> _mesher;
Ref<TiledWallData> _data;
Ref<PropMaterialCache> _cache;
Ref<PropMesher> _mesher;
AABB _aabb;
RID _mesh_rid;

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "tiled_wall_data_2d.h"
#include "tiled_wall_data.h"
#if VERSION_MAJOR < 4
#include "servers/physics_server.h"
@ -57,35 +57,35 @@ SOFTWARE.
arr_into.push_back(e); \
}
#include "../material_cache/prop_material_cache_2d.h"
#include "../material_cache/prop_material_cache.h"
const String TiledWallData2D::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both";
const String TiledWallData::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both";
TiledWallData2D::TiledWallTilingType TiledWallData2D::get_tiling_type() const {
TiledWallData::TiledWallTilingType TiledWallData::get_tiling_type() const {
return _tiling_type;
}
void TiledWallData2D::set_tiling_type(const TiledWallData2D::TiledWallTilingType value) {
void TiledWallData::set_tiling_type(const TiledWallData::TiledWallTilingType value) {
_tiling_type = value;
emit_changed();
}
Ref<Texture> TiledWallData2D::get_texture(const int index) const {
Ref<Texture> TiledWallData::get_texture(const int index) const {
ERR_FAIL_INDEX_V(index, _textures.size(), Ref<Texture>());
return _textures.get(index);
}
void TiledWallData2D::set_texture(const int index, const Ref<Texture> &texture) {
void TiledWallData::set_texture(const int index, const Ref<Texture> &texture) {
ERR_FAIL_INDEX(index, _textures.size());
_textures.set(index, texture);
emit_changed();
}
void TiledWallData2D::add_texture(const Ref<Texture> &texture) {
void TiledWallData::add_texture(const Ref<Texture> &texture) {
_textures.push_back(texture);
}
void TiledWallData2D::remove_texture(const int index) {
void TiledWallData::remove_texture(const int index) {
ERR_FAIL_INDEX(index, _textures.size());
_textures.remove(index);
@ -93,11 +93,11 @@ void TiledWallData2D::remove_texture(const int index) {
emit_changed();
}
int TiledWallData2D::get_texture_count() const {
int TiledWallData::get_texture_count() const {
return _textures.size();
}
Vector<Variant> TiledWallData2D::get_textures() {
Vector<Variant> TiledWallData::get_textures() {
Vector<Variant> r;
for (int i = 0; i < _textures.size(); i++) {
#if VERSION_MAJOR < 4
@ -108,7 +108,7 @@ Vector<Variant> TiledWallData2D::get_textures() {
}
return r;
}
void TiledWallData2D::set_textures(const Vector<Variant> &textures) {
void TiledWallData::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 TiledWallData2D::set_textures(const Vector<Variant> &textures) {
}
//flavour_textures
Ref<Texture> TiledWallData2D::get_flavour_texture(const int index) const {
Ref<Texture> TiledWallData::get_flavour_texture(const int index) const {
ERR_FAIL_INDEX_V(index, _flavour_textures.size(), Ref<Texture>());
return _flavour_textures.get(index);
}
void TiledWallData2D::set_flavour_texture(const int index, const Ref<Texture> &texture) {
void TiledWallData::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 TiledWallData2D::add_flavour_texture(const Ref<Texture> &texture) {
void TiledWallData::add_flavour_texture(const Ref<Texture> &texture) {
_flavour_textures.push_back(texture);
}
void TiledWallData2D::remove_flavour_texture(const int index) {
void TiledWallData::remove_flavour_texture(const int index) {
ERR_FAIL_INDEX(index, _flavour_textures.size());
_flavour_textures.remove(index);
@ -141,11 +141,11 @@ void TiledWallData2D::remove_flavour_texture(const int index) {
emit_changed();
}
int TiledWallData2D::get_flavour_texture_count() const {
int TiledWallData::get_flavour_texture_count() const {
return _flavour_textures.size();
}
Vector<Variant> TiledWallData2D::get_flavour_textures() {
Vector<Variant> TiledWallData::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> TiledWallData2D::get_flavour_textures() {
}
return r;
}
void TiledWallData2D::set_flavour_textures(const Vector<Variant> &textures) {
void TiledWallData::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 TiledWallData2D::set_flavour_textures(const Vector<Variant> &textures) {
emit_changed();
}
float TiledWallData2D::get_flavour_chance() const {
float TiledWallData::get_flavour_chance() const {
return _flavour_chance;
}
void TiledWallData2D::set_flavour_chance(const float value) {
void TiledWallData::set_flavour_chance(const float value) {
_flavour_chance = value;
}
//materials
void TiledWallData2D::material_add(const Ref<Material> &value) {
void TiledWallData::material_add(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_materials.push_back(value);
}
void TiledWallData2D::material_set(const int index, const Ref<Material> &value) {
void TiledWallData::material_set(const int index, const Ref<Material> &value) {
ERR_FAIL_INDEX(index, _materials.size());
_materials.set(index, value);
@ -189,25 +189,25 @@ void TiledWallData2D::material_set(const int index, const Ref<Material> &value)
emit_changed();
}
void TiledWallData2D::material_remove(const int index) {
void TiledWallData::material_remove(const int index) {
_materials.remove(index);
emit_changed();
}
int TiledWallData2D::material_get_num() const {
int TiledWallData::material_get_num() const {
return _materials.size();
}
void TiledWallData2D::materials_clear() {
void TiledWallData::materials_clear() {
_materials.clear();
}
Vector<Variant> TiledWallData2D::materials_get() {
Vector<Variant> TiledWallData::materials_get() {
VARIANT_ARRAY_GET(_materials);
}
void TiledWallData2D::materials_set(const Vector<Variant> &materials) {
void TiledWallData::materials_set(const Vector<Variant> &materials) {
_materials.clear();
for (int i = 0; i < materials.size(); i++) {
@ -220,7 +220,7 @@ void TiledWallData2D::materials_set(const Vector<Variant> &materials) {
}
#if TEXTURE_PACKER_PRESENT
void TiledWallData2D::add_textures_into(Ref<TexturePacker> texture_packer) {
void TiledWallData::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 TiledWallData2D::add_textures_into(Ref<TexturePacker> texture_packer) {
}
#endif
void TiledWallData2D::setup_cache(Ref<PropMaterialCache2D> cache) {
void TiledWallData::setup_cache(Ref<PropMaterialCache> cache) {
//Note: the caller should lock and unlock the cache!
call("_setup_cache", cache);
}
void TiledWallData2D::_setup_cache(Ref<PropMaterialCache2D> cache) {
void TiledWallData::_setup_cache(Ref<PropMaterialCache> 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 TiledWallData2D::_setup_cache(Ref<PropMaterialCache2D> cache) {
}
}
void TiledWallData2D::copy_from(const Ref<TiledWallData2D> &tiled_wall_data) {
void TiledWallData::copy_from(const Ref<TiledWallData> &tiled_wall_data) {
ERR_FAIL_COND(!tiled_wall_data.is_valid());
_tiling_type = tiled_wall_data->_tiling_type;
@ -296,70 +296,70 @@ void TiledWallData2D::copy_from(const Ref<TiledWallData2D> &tiled_wall_data) {
emit_changed();
}
TiledWallData2D::TiledWallData2D() {
TiledWallData::TiledWallData() {
_tiling_type = TILED_WALL_TILING_TYPE_NONE;
_flavour_chance = 0.15;
}
TiledWallData2D::~TiledWallData2D() {
TiledWallData::~TiledWallData() {
_textures.clear();
_flavour_textures.clear();
_materials.clear();
}
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");
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");
//textures
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", "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_count"), &TiledWallData2D::get_texture_count);
ClassDB::bind_method(D_METHOD("get_texture_count"), &TiledWallData::get_texture_count);
ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData2D::get_textures);
ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData2D::set_textures);
ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData::get_textures);
ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData::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"), &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", "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_count"), &TiledWallData2D::get_flavour_texture_count);
ClassDB::bind_method(D_METHOD("get_flavour_texture_count"), &TiledWallData::get_flavour_texture_count);
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);
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);
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"), &TiledWallData2D::get_flavour_chance);
ClassDB::bind_method(D_METHOD("set_flavour_chance", "texture"), &TiledWallData2D::set_flavour_chance);
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);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "flavour_chance"), "set_flavour_chance", "get_flavour_chance");
//materials
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("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("materials_get"), &TiledWallData2D::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &TiledWallData2D::materials_set);
ClassDB::bind_method(D_METHOD("materials_get"), &TiledWallData::materials_get);
ClassDB::bind_method(D_METHOD("materials_set"), &TiledWallData::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"), &TiledWallData2D::add_textures_into);
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWallData::add_textures_into);
#endif
BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache2D")));
BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache")));
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("setup_cache", "cache"), &TiledWallData::setup_cache);
ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWallData::_setup_cache);
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData2D::copy_from);
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData::copy_from);
BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_NONE);
BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_HORIZONTAL);

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2019-2021 Péter Magyar
Copyright (c) 2019-2022 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef TILED_WALL_DATA_2D_H
#define TILED_WALL_DATA_2D_H
#ifndef TILED_WALL_DATA_H
#define TILED_WALL_DATA_H
#include "core/version.h"
@ -47,11 +47,11 @@ SOFTWARE.
#include "../../texture_packer/texture_packer.h"
#endif
class PropMaterialCache2D;
class PropMesher2D;
class PropMaterialCache;
class PropMesher;
class TiledWallData2D : public Resource {
GDCLASS(TiledWallData2D, Resource);
class TiledWallData : public Resource {
GDCLASS(TiledWallData, Resource);
public:
enum TiledWallTilingType {
@ -106,15 +106,15 @@ public:
void add_textures_into(Ref<TexturePacker> texture_packer);
#endif
void setup_cache(Ref<PropMaterialCache2D> cache);
void _setup_cache(Ref<PropMaterialCache2D> cache);
void setup_cache(Ref<PropMaterialCache> cache);
void _setup_cache(Ref<PropMaterialCache> cache);
void copy_from(const Ref<TiledWallData2D> &tiled_wall_data);
void copy_from(const Ref<TiledWallData> &tiled_wall_data);
//Ref<Shape> get_collider_shape();
TiledWallData2D();
~TiledWallData2D();
TiledWallData();
~TiledWallData();
protected:
static void _bind_methods();
@ -129,6 +129,6 @@ private:
Vector<Ref<Material>> _materials;
};
VARIANT_ENUM_CAST(TiledWallData2D::TiledWallTilingType);
VARIANT_ENUM_CAST(TiledWallData::TiledWallTilingType);
#endif