Cleaned up more version checks.

This commit is contained in:
Relintai 2022-03-18 03:08:46 +01:00
parent 441f7a3694
commit dc34206f3a
26 changed files with 25 additions and 388 deletions

View File

@ -1544,11 +1544,7 @@ String Spell::_get_description(const int class_level, const int character_level)
if (pos == str.size() - 1)
break;
#if GODOT4
char32_t o = str[pos + 1];
#else
CharType o = str[pos + 1];
#endif
if (o == '#' || o == '$' || o == '%') {
int nsp = str.find_char(' ', pos + 1);
@ -1611,11 +1607,7 @@ String Spell::_aura_get_description(const int class_level, const int character_l
if (pos == str.size() - 1)
break;
#if GODOT4
char32_t o = str[pos + 1];
#else
CharType o = str[pos + 1];
#endif
if (o == '#' || o == '$' || o == '%') {
int nsp = str.find_char(' ', pos + 1);

View File

@ -72,11 +72,7 @@ Vector<Variant> CharacterSpec::get_talents() {
Vector<Variant> entries;
for (int k = 0; k < _rows[j].size(); k++) {
#if GODOT4
entries.push_back(_rows[i][j][k]);
#else
entries.push_back(_rows[i][j][k].get_ref_ptr());
#endif
}
col.push_back(entries);

View File

@ -165,11 +165,7 @@ void ESSMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
ESSMaterialCachePCM::ESSMaterialCachePCM() {
_packer.instance();
#if GODOT4
#warning implement
#else
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_packer->set_max_atlas_size(1024);
_packer->set_keep_original_atlases(false);

View File

@ -420,9 +420,7 @@ Array CharacterSkeleton2D::bake_mesh_array_uv(Array arr, Ref<Texture> tex, float
PoolVector2Array uvs = arr[VisualServer::ARRAY_TEX_UV];
PoolColorArray colors = arr[VisualServer::ARRAY_COLOR];
#if !GODOT4
img->lock();
#endif
for (int i = 0; i < uvs.size(); ++i) {
Vector2 uv = uvs[i];
@ -433,9 +431,7 @@ Array CharacterSkeleton2D::bake_mesh_array_uv(Array arr, Ref<Texture> tex, float
colors.set(i, colors[i] * c * mul_color);
}
#if !GODOT4
img->unlock();
#endif
arr[VisualServer::ARRAY_COLOR] = colors;

View File

@ -296,7 +296,7 @@ void CharacterSkeleton3D::add_model_visual_entry(Ref<ModelVisual> vis, Ref<Model
int target_bone_idx = ive->get_bone();
Vector<Ref<SkeletonModelEntry> > &entries = _entries.write[target_bone_idx];
Vector<Ref<SkeletonModelEntry>> &entries = _entries.write[target_bone_idx];
for (int i = 0; i < entries.size(); ++i) {
Ref<SkeletonModelEntry> e = entries.get(i);
@ -338,7 +338,7 @@ void CharacterSkeleton3D::remove_model_visual_entry(Ref<ModelVisual> vis, Ref<Mo
int target_bone_idx = ive->get_bone();
Vector<Ref<SkeletonModelEntry> > &entries = _entries.write[target_bone_idx];
Vector<Ref<SkeletonModelEntry>> &entries = _entries.write[target_bone_idx];
for (int i = 0; i < entries.size(); ++i) {
Ref<SkeletonModelEntry> e = entries.get(i);
@ -372,7 +372,7 @@ int CharacterSkeleton3D::get_model_entry_count(const int bone_index) {
void CharacterSkeleton3D::sort_layers() {
for (int i = 0; i < _entries.size(); ++i) {
Vector<Ref<SkeletonModelEntry> > &entries = _entries.write[i];
Vector<Ref<SkeletonModelEntry>> &entries = _entries.write[i];
entries.sort_custom<_ModelEntryComparator>();
}
@ -460,9 +460,7 @@ Array CharacterSkeleton3D::bake_mesh_array_uv(Array arr, Ref<Texture> tex, float
PoolVector2Array uvs = arr[VisualServer::ARRAY_TEX_UV];
PoolColorArray colors = arr[VisualServer::ARRAY_COLOR];
#if !GODOT4
img->lock();
#endif
for (int i = 0; i < uvs.size(); ++i) {
Vector2 uv = uvs[i];
@ -473,9 +471,7 @@ Array CharacterSkeleton3D::bake_mesh_array_uv(Array arr, Ref<Texture> tex, float
colors.set(i, colors[i] * c * mul_color);
}
#if !GODOT4
img->unlock();
#endif
arr[VisualServer::ARRAY_COLOR] = colors;

View File

@ -2,31 +2,6 @@
#ifndef MESH_UTILS_DEFINES_H
#define MESH_UTILS_DEFINES_H
#include "core/version.h"
#if VERSION_MAJOR >= 4
#define GODOT4 true
#endif
//includes
#if GODOT4
#define core_input_h "core/input/input_event.h"
#define spatial_editor_plugin_h "editor/plugins/node_3d_editor_plugin.h"
#define camera_h "scene/3d/camera_3d.h"
#define spatial_h "scene/3d/node_3d.h"
#define navigation_h "scene/3d/navigation_3d.h"
#define light_h "scene/3d/light_3d.h"
#define visual_server_h "servers/rendering_server.h"
#define mesh_instance_h "scene/3d/mesh_instance_3d.h"
#define pool_vector_h "core/templates/vector.h"
#define physics_server_h "servers/physics_server_3d.h"
#define immediate_geometry_h "scene/3d/immediate_geometry_3d.h"
#define include_pool_vector \
template <class N> \
class Vector; \
template <class N> \
using PoolVector = Vector<N>;
#else
#define core_input_h "core/os/input.h"
#define spatial_editor_plugin_h "editor/plugins/spatial_editor_plugin.h"
#define camera_h "scene/3d/camera.h"
@ -39,54 +14,6 @@
#define physics_server_h "servers/physics_server.h"
#define immediate_geometry_h "scene/3d/immediate_geometry.h"
#define include_pool_vector
#endif
//Type Defines
#if GODOT4
#define PhysicsDirectSpaceState PhysicsDirectSpaceState3D
#define SpatialEditor Node3DEditor
#define SpatialEditorPlugin Node3DEditorPlugin
#define SpatialEditorViewport Node3DEditorViewport
#define PoolStringArray PackedStringArray
#define REAL FLOAT
#define POOL_STRING_ARRAY PACKED_STRING_ARRAY
#define POOL_BYTE_ARRAY PACKED_BYTE_ARRAY
#define Spatial Node3D
#define SpatialMaterial StandardMaterial3D
#define PoolVector3Array PackedVector3Array
#define PoolVector2Array PackedVector2Array
#define PoolColorArray PackedColorArray
#define PoolIntArray PackedInt64Array
#define PoolRealArray PackedFloat32Array
#define PoolByteArray PackedByteArray
#define MeshInstance MeshInstance3D
#define Camera Camera3D
typedef class World3D World;
#define DirectionalLight DirectionalLight3D
typedef class ImmediateGeometry3D ImmediateGeometry;
typedef class Navigation3D Navigation;
typedef class PhysicsServer3D PhysicsServer;
typedef class RenderingServer VisualServer;
typedef class RenderingServer VS;
//typedef class StandardMaterial3D SpatialMaterial;
//toodo figure out a way to have this
//#define Variant::CallError Callable::CallError
#endif
#if GODOT4
#define VARIANT_ARRAY_GET(arr) \
Vector<Variant> r; \
for (int i = 0; i < arr.size(); i++) { \
r.push_back(arr[i]); \
} \
return r;
#else
#define VARIANT_ARRAY_GET(arr) \
Vector<Variant> r; \
@ -95,8 +22,6 @@ typedef class RenderingServer VS;
} \
return r;
#endif
#define VARIANT_ARRAY_SET(arr, arr_into, type) \
arr_into.clear(); \
for (int i = 0; i < arr.size(); i++) { \
@ -104,17 +29,9 @@ typedef class RenderingServer VS;
arr_into.push_back(e); \
}
#if GODOT4
//TODO do this properly
#define INSTANCE_VALIDATE(var) var
#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method))
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method))
#define GET_WORLD get_world_3d
#else
#define INSTANCE_VALIDATE(var) ObjectDB::instance_validate(var)
#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method)
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method)
#define GET_WORLD get_world
#endif
#endif

View File

@ -142,21 +142,13 @@ Array MeshMerger::build_mesh() {
{
PoolVector<Vector3> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector3>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].vertex;
#else
array.set(i, _vertices[i].vertex);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_VERTEX] = array;
}
@ -164,63 +156,41 @@ Array MeshMerger::build_mesh() {
if ((_format & VisualServer::ARRAY_FORMAT_NORMAL) != 0) {
PoolVector<Vector3> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector3>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].normal;
#else
array.set(i, _vertices[i].normal);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_NORMAL] = array;
}
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) {
PoolVector<Color> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Color>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].color;
#else
array.set(i, _vertices[i].color);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_COLOR] = array;
}
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) {
PoolVector<Vector2> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].uv;
#else
array.set(i, _vertices[i].uv);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV] = array;
}
@ -228,21 +198,14 @@ Array MeshMerger::build_mesh() {
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV2) != 0) {
PoolVector<Vector2> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].uv2;
#else
array.set(i, _vertices[i].uv2);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV2] = array;
}
@ -252,26 +215,19 @@ Array MeshMerger::build_mesh() {
PoolVector<int> bone_array;
bone_array.resize(size);
#if !GODOT4
PoolVector<int>::Write wb = bone_array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
const Vertex &vertex = _vertices[i];
int curr = i * 4;
for (int j = 0; j < vertex.bones.size(); ++j) {
#if !GODOT4
wb[curr + j] = vertex.bones[j];
#else
bone_array.write[curr + j] = vertex.bones[j];
#endif
}
}
#if !GODOT4
wb.release();
#endif
a[VisualServer::ARRAY_BONES] = bone_array;
}
@ -280,47 +236,35 @@ Array MeshMerger::build_mesh() {
PoolVector<float> bone_weights_array;
bone_weights_array.resize(size);
#if !GODOT4
PoolVector<float>::Write wbw = bone_weights_array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
const Vertex &vertex = _vertices[i];
int curr = i * 4;
for (int j = 0; j < vertex.bones.size(); ++j) {
#if !GODOT4
wbw[curr + j] = vertex.weights[j];
#else
bone_weights_array.write[curr + j] = vertex.weights[j];
#endif
}
}
#if !GODOT4
wbw.release();
#endif
a[VisualServer::ARRAY_WEIGHTS] = bone_weights_array;
}
if (_indices.size() > 0) {
PoolVector<int> array;
array.resize(_indices.size());
#if !GODOT4
PoolVector<int>::Write w = array.write();
#endif
for (int i = 0; i < _indices.size(); ++i) {
#if !GODOT4
w[i] = _indices[i];
#else
array.set(i, _indices[i]);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_INDEX] = array;
}

View File

@ -29,13 +29,7 @@ SOFTWARE.
#include "xatlas/xatlas.h"
#if GODOT4
#define Texture Texture2D
#include "core/math/delaunay_3d.h"
#else
#include "delaunay/delaunay_3d.h"
#endif
MeshUtils *MeshUtils::_instance;
@ -143,9 +137,7 @@ Array MeshUtils::bake_mesh_array_uv(Array arr, Ref<Texture> tex, float mul_color
PoolVector2Array uvs = arr[VisualServer::ARRAY_TEX_UV];
PoolColorArray colors = arr[VisualServer::ARRAY_COLOR];
#if !GODOT4
img->lock();
#endif
for (int i = 0; i < uvs.size(); ++i) {
Vector2 uv = uvs[i];
@ -156,9 +148,7 @@ Array MeshUtils::bake_mesh_array_uv(Array arr, Ref<Texture> tex, float mul_color
colors.set(i, colors[i] * c * mul_color);
}
#if !GODOT4
img->unlock();
#endif
arr[VisualServer::ARRAY_COLOR] = colors;
@ -639,6 +629,3 @@ void MeshUtils::_bind_methods() {
ClassDB::bind_method(D_METHOD("delaunay3d_tetrahedralize", "points"), &MeshUtils::delaunay3d_tetrahedralize);
}
#if GODOT4
#undef Texture
#endif

View File

@ -38,10 +38,6 @@ SOFTWARE.
#include "defines.h"
#if GODOT4
#define Texture Texture2D
#endif
class MeshUtils : public Object {
GDCLASS(MeshUtils, Object);
@ -70,8 +66,4 @@ private:
static MeshUtils *_instance;
};
#if GODOT4
#undef Texture
#endif
#endif

View File

@ -165,11 +165,7 @@ void PropMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
PropMaterialCachePCM::PropMaterialCachePCM() {
_packer.instance();
#if GODOT4
#warning implement
#else
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_packer->set_max_atlas_size(1024);
_packer->set_keep_original_atlases(false);

View File

@ -425,11 +425,7 @@ void PropInstancePropJob::phase_steps() {
RID mesh_rid = _prop_instace->mesh_get(i);
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
}
}
}
@ -672,9 +668,7 @@ Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const
if (colors.size() < uvs.size())
colors.resize(uvs.size());
#if !GODOT4
img->lock();
#endif
for (int i = 0; i < uvs.size(); ++i) {
Vector2 uv = uvs[i];
@ -688,9 +682,7 @@ Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const
colors.set(i, colors[i] * c * mul_color);
}
#if !GODOT4
img->unlock();
#endif
arr[VisualServer::ARRAY_COLOR] = colors;
@ -710,11 +702,7 @@ void PropInstancePropJob::reset_meshes() {
RID mesh_rid = _prop_instace->mesh_get(i);
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
}
}
}

View File

@ -173,21 +173,13 @@ Array PropMesher::build_mesh() {
{
PoolVector<Vector3> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector3>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].vertex;
#else
array.set(i, _vertices[i].vertex);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_VERTEX] = array;
}
@ -199,63 +191,43 @@ Array PropMesher::build_mesh() {
{
PoolVector<Vector3> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector3>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].normal;
#else
array.set(i, _vertices[i].normal);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_NORMAL] = array;
}
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) {
PoolVector<Color> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Color>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].color;
#else
array.set(i, _vertices[i].color);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_COLOR] = array;
}
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) {
PoolVector<Vector2> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].uv;
#else
array.set(i, _vertices[i].uv);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV] = array;
}
@ -263,42 +235,30 @@ Array PropMesher::build_mesh() {
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV2) != 0) {
PoolVector<Vector2> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
#if !GODOT4
w[i] = _vertices[i].uv2;
#else
array.set(i, _vertices[i].uv2);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV2] = array;
}
if (_indices.size() > 0) {
PoolVector<int> array;
array.resize(_indices.size());
#if !GODOT4
PoolVector<int>::Write w = array.write();
#endif
for (int i = 0; i < _indices.size(); ++i) {
#if !GODOT4
w[i] = _indices[i];
#else
array.set(i, _indices[i]);
#endif
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_INDEX] = array;
}

View File

@ -22,30 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/math/color.h"
#include "core/object/reference.h"
#include "core/templates/vector.h"
template <class N>
class Vector;
template <class N>
using PoolVector = Vector<N>;
#include "scene/3d/mesh_instance_3d.h"
#else
#include "core/color.h"
#include "core/pool_vector.h"
#include "core/reference.h"
#include "core/vector.h"
#include "scene/3d/mesh_instance.h"
#endif
#include "core/math/rect2.h"
#include "core/math/vector2.h"

View File

@ -1,12 +1,6 @@
#include "prop_scene_instance.h"
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/config/engine.h"
#else
#include "core/engine.h"
#endif
Ref<PackedScene> PropSceneInstance::get_scene() {
return _scene;

View File

@ -22,18 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "core/version.h"
#if VERSION_MAJOR < 4
#include "scene/3d/spatial.h"
#else
#include "scene/3d/node_3d.h"
#define Spatial Node3D
#endif
#include "core/math/vector3.h"

View File

@ -22,13 +22,7 @@ SOFTWARE.
#include "register_types.h"
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/config/engine.h"
#else
#include "core/engine.h"
#endif
#include "tiled_wall/tiled_wall.h"
#include "tiled_wall/tiled_wall_data.h"
@ -40,9 +34,7 @@ SOFTWARE.
#include "props/prop_data_scene.h"
#include "props/prop_data_tiled_wall.h"
#if VERSION_MINOR >= 4
#include "props/prop_data_portal.h"
#endif
#include "clutter/ground_clutter.h"
#include "clutter/ground_clutter_foliage.h"
@ -90,9 +82,7 @@ void register_props_types() {
ClassDB::register_class<PropDataProp>();
ClassDB::register_class<PropDataTiledWall>();
#if VERSION_MINOR >= 4
ClassDB::register_class<PropDataPortal>();
#endif
ClassDB::register_class<GroundClutter>();
ClassDB::register_class<GroundClutterFoliage>();
@ -135,10 +125,8 @@ void register_props_types() {
Ref<PropDataScene> scene_processor = Ref<PropDataScene>(memnew(PropDataScene));
PropUtils::add_processor(scene_processor);
#if VERSION_MINOR >= 4
Ref<PropDataPortal> portal_processor = Ref<PropDataPortal>(memnew(PropDataPortal));
PropUtils::add_processor(portal_processor);
#endif
Ref<PropDataTiledWall> tiled_wall_processor = Ref<PropDataTiledWall>(memnew(PropDataTiledWall));
PropUtils::add_processor(tiled_wall_processor);

View File

@ -22,9 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
void register_props_types();
void unregister_props_types();

View File

@ -232,9 +232,7 @@ Array Terrain2DJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float
if (colors.size() < uvs.size())
colors.resize(uvs.size());
#if !GODOT4
img->lock();
#endif
for (int i = 0; i < uvs.size(); ++i) {
Vector2 uv = uvs[i];
@ -248,9 +246,7 @@ Array Terrain2DJob::bake_mesh_array_uv(Array arr, Ref<Texture> tex, const float
colors.set(i, colors[i] * c * mul_color);
}
#if !GODOT4
img->unlock();
#endif
arr[VisualServer::ARRAY_COLOR] = colors;

View File

@ -333,11 +333,7 @@ void Terrain2DProp2DJob::phase_steps() {
mesh_rid = chunk->mesh_rid_get(Terrain2DChunkDefault::MESH_INDEX_PROP, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH);
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
}
}

View File

@ -278,11 +278,7 @@ void Terrain2DTerrain2DJob::phase_terrain_mesh() {
mesh_rid = chunk->mesh_rid_get_index(Terrain2DChunkDefault::MESH_INDEX_TERRAIN, Terrain2DChunkDefault::MESH_TYPE_INDEX_MESH, i);
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
chunk->_mesh_transforms.write[i] = Transform2D();
}
@ -310,11 +306,7 @@ void Terrain2DTerrain2DJob::phase_terrain_mesh() {
}
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
if (should_return()) {
return;

View File

@ -579,15 +579,12 @@ PoolByteArray Terrain2DChunk::channel_get_compressed(const int channel_index) co
int bound = LZ4_compressBound(size);
arr.resize(bound);
#if !GODOT4
PoolByteArray::Write w = arr.write();
int ns = LZ4_compress_default(reinterpret_cast<char *>(ch), reinterpret_cast<char *>(w.ptr()), size, bound);
w.release();
#else
int ns = LZ4_compress_default(reinterpret_cast<char *>(ch), reinterpret_cast<char *>(arr.ptrw()), size, bound);
#endif
arr.resize(ns);
return arr;
@ -613,19 +610,12 @@ void Terrain2DChunk::channel_set_compressed(const int channel_index, const PoolB
int ds = data.size();
#if !GODOT4
PoolByteArray::Read r = data.read();
//We are not going to write to it
uint8_t *data_arr = const_cast<uint8_t *>(r.ptr());
LZ4_decompress_safe(reinterpret_cast<char *>(data_arr), reinterpret_cast<char *>(ch), ds, size);
#else
//We are not going to write to it
uint8_t *data_arr = const_cast<uint8_t *>(data.ptr());
LZ4_decompress_safe(reinterpret_cast<char *>(data_arr), reinterpret_cast<char *>(ch), ds, size);
#endif
}
_FORCE_INLINE_ int Terrain2DChunk::get_index(const int x, const int y) const {

View File

@ -181,11 +181,7 @@ void VoxelMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
VoxelMaterialCachePCM::VoxelMaterialCachePCM() {
_packer.instance();
#if GODOT4
#warning implement
#else
_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER);
#endif
_packer->set_max_atlas_size(1024);
_packer->set_keep_original_atlases(false);

View File

@ -173,17 +173,13 @@ Array VoxelMesher::build_mesh() {
{
PoolVector<Vector3> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector3>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
array.set(i, _vertices[i].vertex);
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_VERTEX] = array;
}
@ -195,51 +191,41 @@ Array VoxelMesher::build_mesh() {
{
PoolVector<Vector3> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector3>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
array.set(i, _vertices[i].normal);
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_NORMAL] = array;
}
if ((_format & VisualServer::ARRAY_FORMAT_COLOR) != 0) {
PoolVector<Color> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Color>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
array.set(i, _vertices[i].color);
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_COLOR] = array;
}
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV) != 0) {
PoolVector<Vector2> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
array.set(i, _vertices[i].uv);
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV] = array;
}
@ -247,34 +233,28 @@ Array VoxelMesher::build_mesh() {
if ((_format & VisualServer::ARRAY_FORMAT_TEX_UV2) != 0) {
PoolVector<Vector2> array;
array.resize(_vertices.size());
#if !GODOT4
PoolVector<Vector2>::Write w = array.write();
#endif
for (int i = 0; i < _vertices.size(); ++i) {
array.set(i, _vertices[i].uv2);
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_TEX_UV2] = array;
}
if (_indices.size() > 0) {
PoolVector<int> array;
array.resize(_indices.size());
#if !GODOT4
PoolVector<int>::Write w = array.write();
#endif
for (int i = 0; i < _indices.size(); ++i) {
array.set(i, _indices[i]);
}
#if !GODOT4
w.release();
#endif
a[VisualServer::ARRAY_INDEX] = array;
}

View File

@ -397,11 +397,7 @@ void VoxelPropJob::phase_steps() {
mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i);
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
}
}
}

View File

@ -493,11 +493,7 @@ void VoxelTerrainJob::phase_terrain_mesh() {
mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRAIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i);
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
}
}
}
@ -557,11 +553,7 @@ void VoxelTerrainJob::phase_terrain_mesh() {
}
if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0)
#if !GODOT4
VS::get_singleton()->mesh_remove_surface(mesh_rid, 0);
#else
VS::get_singleton()->mesh_clear(mesh_rid);
#endif
if (should_return()) {
return;

View File

@ -549,15 +549,12 @@ PoolByteArray VoxelChunk::channel_get_compressed(const int channel_index) const
int bound = LZ4_compressBound(size);
arr.resize(bound);
#if !GODOT4
PoolByteArray::Write w = arr.write();
int ns = LZ4_compress_default(reinterpret_cast<char *>(ch), reinterpret_cast<char *>(w.ptr()), size, bound);
w.release();
#else
int ns = LZ4_compress_default(reinterpret_cast<char *>(ch), reinterpret_cast<char *>(arr.ptrw()), size, bound);
#endif
arr.resize(ns);
return arr;
@ -583,19 +580,12 @@ void VoxelChunk::channel_set_compressed(const int channel_index, const PoolByteA
int ds = data.size();
#if !GODOT4
PoolByteArray::Read r = data.read();
//We are not going to write to it
uint8_t *data_arr = const_cast<uint8_t *>(r.ptr());
LZ4_decompress_safe(reinterpret_cast<char *>(data_arr), reinterpret_cast<char *>(ch), ds, size);
#else
//We are not going to write to it
uint8_t *data_arr = const_cast<uint8_t *>(data.ptr());
LZ4_decompress_safe(reinterpret_cast<char *>(data_arr), reinterpret_cast<char *>(ch), ds, size);
#endif
}
_FORCE_INLINE_ int VoxelChunk::get_index(const int x, const int y, const int z) const {