Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3c2ffdb
WorldScape3D initial commit: port from ReX
OldDev78 Jul 26, 2026
c4188cc
build errors, warnings fixes
OldDev78 Jul 26, 2026
36bf449
header guards
OldDev78 Jul 26, 2026
34e7fc1
compiler warning/error fixes
OldDev78 Jul 26, 2026
b2cc220
implement logging macro
OldDev78 Aug 10, 2026
1c7b9de
re-enable LOG macro
OldDev78 Aug 10, 2026
e0d8d7b
warning fixes
OldDev78 Aug 10, 2026
7c41dc5
more warning fixes
OldDev78 Aug 10, 2026
63194d4
more warning fixes
OldDev78 Aug 10, 2026
b8299c8
Merge branch 'master' into worldscape3d
OldDev78 Aug 10, 2026
3086250
yet more warning fixes
OldDev78 Aug 10, 2026
f6a00bf
documentation/binding fixes
OldDev78 Aug 10, 2026
b5d8b02
fixes for VOID macro
OldDev78 Aug 10, 2026
b427398
more doc fixes
OldDev78 Aug 11, 2026
d885706
fix cowdata.h mod zero warning on windows
OldDev78 Aug 11, 2026
8e166f2
move cowdata.h warning disable for windows build
OldDev78 Aug 11, 2026
d00628b
more doc fixes
OldDev78 Aug 11, 2026
89617a2
rename settings category to 'Terrain Editor'
OldDev78 Aug 12, 2026
5ecc4db
code rabbit menu suggestions
OldDev78 Aug 12, 2026
152119d
more cr fixes
OldDev78 Aug 12, 2026
97fb252
avoid finding nav region terrains more than once
OldDev78 Aug 14, 2026
ce7be6b
extend region size limit to 4096x4096
OldDev78 Aug 14, 2026
a3e1ec1
fix crash candidate in region gizmo update function
OldDev78 Aug 14, 2026
f54a0c4
stop region out of bounds error spam
OldDev78 Aug 15, 2026
d87eeed
fix AssetDock crash candidates
OldDev78 Aug 15, 2026
c938e4a
promote asserts in operations code
OldDev78 Aug 15, 2026
0eb563b
fix asset resource ID signals
OldDev78 Aug 15, 2026
23431ee
update assets docs
OldDev78 Aug 15, 2026
bd8a757
fix shader in compatibility renderer (from Terrain3D v1.0.2)
OldDev78 Aug 15, 2026
4d9e876
reduce crash log severity (from Terrain3D 1.0.2)
OldDev78 Aug 15, 2026
e67c4b9
fix off-by-one in shader code injection
OldDev78 Aug 15, 2026
fd5819a
fix WorldScape3DMaterial race condition (from Terrain3D 1.0.2)
OldDev78 Aug 15, 2026
1307d13
reduce severity of out-of-bounds regions logs
OldDev78 Aug 15, 2026
c416687
remove commented out code
OldDev78 Aug 15, 2026
fb64dcb
code clean up (align more to Terrain3D)
OldDev78 Aug 15, 2026
533fbab
fix missing inf checks
OldDev78 Aug 15, 2026
547e5e6
restore missing property descriptions to WorldScape3DMaterial
OldDev78 Aug 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/templates/cowdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class CowData {
// └────────────────────┴──┴─────────────┴──┴───────────...
// Offset: ↑ REF_COUNT_OFFSET ↑ SIZE_OFFSET ↑ DATA_OFFSET

static_assert(alignof(USize) > 0);

static constexpr size_t REF_COUNT_OFFSET = 0;
static constexpr size_t SIZE_OFFSET = ((REF_COUNT_OFFSET + sizeof(SafeNumeric<USize>)) % alignof(USize) == 0) ? (REF_COUNT_OFFSET + sizeof(SafeNumeric<USize>)) : ((REF_COUNT_OFFSET + sizeof(SafeNumeric<USize>)) + alignof(USize) - ((REF_COUNT_OFFSET + sizeof(SafeNumeric<USize>)) % alignof(USize)));
static constexpr size_t DATA_OFFSET = ((SIZE_OFFSET + sizeof(USize)) % alignof(max_align_t) == 0) ? (SIZE_OFFSET + sizeof(USize)) : ((SIZE_OFFSET + sizeof(USize)) + alignof(max_align_t) - ((SIZE_OFFSET + sizeof(USize)) % alignof(max_align_t)));
Expand Down Expand Up @@ -167,6 +169,11 @@ class CowData {
return _ptr;
}

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4724) // prevent false positive warning for potential modulo zero
#endif

_FORCE_INLINE_ Size size() const {
USize *size = (USize *)_get_size();
if (size) {
Expand All @@ -176,6 +183,10 @@ class CowData {
}
}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

_FORCE_INLINE_ void clear() { _unref(); }
_FORCE_INLINE_ bool is_empty() const { return _ptr == nullptr; }

Expand Down
10 changes: 10 additions & 0 deletions doc/classes/WorldScape3DAssetResource.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="WorldScape3DAssetResource" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
</brief_description>
<description>
Base class of WorldScape3DTextureAsset and WorldScape3DMeshAsset.
</description>
<tutorials>
</tutorials>
</class>
15 changes: 15 additions & 0 deletions modules/worldscape_3d/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *

Import("env")
Import("env_modules")

env_worldscape3d = env_modules.Clone()

env_worldscape3d.add_source_files(env.modules_sources, "./*.cpp")

if env.editor_build:
env_worldscape3d.Append(CPPDEFINES=["TOOLS_ENABLED"])
env_worldscape3d.add_source_files(env.modules_sources, "editor/*.cpp")
env_worldscape3d.add_source_files(env.modules_sources, "editor/menu/*.cpp")
env_worldscape3d.add_source_files(env.modules_sources, "editor/ui/*.cpp")
25 changes: 25 additions & 0 deletions modules/worldscape_3d/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def can_build(env, platform):
return True


def configure(env):
pass


def get_doc_path():
return "doc_classes"


def get_doc_classes():
return [
"WorldScape3D",
"WorldScape3DAssets",
"WorldScape3DMeshAsset",
"WorldScape3DTextureAsset",
"WorldScape3DCollision",
"WorldScape3DData",
"WorldScape3DEditor",
"WorldScape3DInstancer",
"WorldScape3DMaterial",
"WorldScape3DRegion",
]
179 changes: 179 additions & 0 deletions modules/worldscape_3d/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/**************************************************************************/
/* constants.h */
/**************************************************************************/
/* This file is part of: */
/* REDOT ENGINE */
/* https://redotengine.org */
/**************************************************************************/
/* Copyright (c) 2024-present Redot Engine contributors */
/* (see REDOT_AUTHORS.md) */
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#pragma once

// Terrain3D Godot plugin: Copyright © 2025 Cory Petkovsek, Roope Palmroos, and Contributors.

#include <bit>
#include <numbers>

#include "core/math/color.h"
#include "core/math/vector2.h"
#include "core/math/vector2i.h"
#include "core/math/vector3.h"
#include "core/math/vector3i.h"

// Macros
//#define PhysicsS PhysicsServer3D::get_singleton()
#define IS_EDITOR Engine::get_singleton()->is_editor_hint()

// Set class name for logger.h

#define CLASS_NAME() const String __class__ = String(get_class_static()) + \
String("#") + String::num_uint64(get_instance_id()).right(4);

#define CLASS_NAME_STATIC(p_name) static inline const char *__class__ = p_name;

// Validation macros

// TODO find the push/print UtilityFunctions
#if 0
#define ASSERT(cond, ret) \
if (!(cond)) { \
UtilityFunctions::push_error("Assertion '", #cond, "' failed at ", __FILE__, ":", __LINE__); \
return ret; \
}
#else
#define ASSERT(cond, ret)
#endif

#ifdef VOID
#undef VOID
#endif

#define VOID // a return value for void, to avoid compiler warnings

#define IS_INIT(ret) \
if (!_terrain) { \
return ret; \
}

#define IS_INIT_MESG(mesg, ret) \
if (!_terrain) { \
print_error(mesg); \
return ret; \
}

#define IS_INIT_COND(cond, ret) \
if (!_terrain || cond) { \
return ret; \
}

#define IS_INIT_COND_MESG(cond, mesg, ret) \
if (!_terrain || cond) { \
LOG(ERROR, mesg); \
return ret; \
}

#define IS_INSTANCER_INIT(ret) \
if (!_terrain || !_terrain->get_instancer()) { \
return ret; \
}

#define IS_INSTANCER_INIT_MESG(mesg, ret) \
if (!_terrain || !_terrain->get_instancer()) { \
LOG(ERROR, mesg); \
return ret; \
}

#define IS_DATA_INIT(ret) \
if (!_terrain || !_terrain->get_data()) { \
return ret; \
}

#define IS_DATA_INIT_MESG(mesg, ret) \
if (!_terrain || !_terrain->get_data()) { \
LOG(ERROR, mesg); \
return ret; \
}

// Constants
inline constexpr Color COLOR_NAN{ NAN, NAN, NAN, NAN };
inline constexpr Color COLOR_BLACK{ 0.0f, 0.0f, 0.0f, 1.0f };
inline constexpr Color COLOR_WHITE{ 1.0f, 1.0f, 1.0f, 1.0f };
inline constexpr Color COLOR_ROUGHNESS{ 1.0f, 1.0f, 1.0f, 0.5f };
inline constexpr Color COLOR_CHECKED{ 1.f, 1.f, 1.0f, 1.0f };
inline constexpr Color COLOR_NORMAL{ 0.5f, 0.5f, 1.0f, 1.0f };
inline constexpr Color COLOR_CONTROL{ std::bit_cast<float>(uint32_t{ true & 0x1 }), 0.f, 0.f, 1.0f };

inline constexpr real_t Math_PI = std::numbers::pi_v<real_t>;
inline constexpr real_t Math_SQRT2 = std::numbers::sqrt2_v<real_t>;
inline constexpr real_t Math_SQRT12 = real_t{ 0.5f } * Math_SQRT2;
inline constexpr real_t Math_LN2 = std::numbers::ln2_v<real_t>;
inline constexpr real_t Math_TAU = real_t{ 2.f } * Math_PI;
inline constexpr real_t Math_E = std::numbers::e_v<real_t>;

// For consistency between MSVC, gcc, clang
#ifndef FLT_MAX
#define FLT_MAX __FLT_MAX__
#endif
#ifndef FLT_MIN
#define FLT_MIN __FLT_MIN__
#endif

#define V2(x) Vector2(x, x)
#define V2I(x) Vector2i(x, x)
inline constexpr Vector2 V2_ZERO{ 0.f, 0.f };
inline constexpr Vector2i V2I_ZERO{ 0, 0 };
inline constexpr Vector2 V2_MAX{ FLT_MAX, FLT_MAX };
inline constexpr Vector2i V2I_MAX{ INT32_MAX, INT32_MAX };

#define V3(x) Vector3(x, x, x)
#define V3_(x) Vector3(x, 0.f, x)
inline constexpr Vector3 V3_ZERO{ 0.f, 0.f, 0.f };
inline constexpr Vector3 V3_MAX{ FLT_MAX, FLT_MAX, FLT_MAX };

// WorldScape3D::_warnings is uint8_t
inline constexpr uint8_t WARN_MISMATCHED_SIZE = 0x01;
inline constexpr uint8_t WARN_MISMATCHED_FORMAT = 0x02;
inline constexpr uint8_t WARN_MISMATCHED_MIPMAPS = 0x04;
inline constexpr uint8_t WARN_ALL = 0xFF;

// Global Types

struct Vector2iHash {
std::size_t operator()(const Vector2i &v) const {
std::size_t h1 = std::hash<int>()(v.x);
std::size_t h2 = std::hash<int>()(v.y);
return h1 ^ (h2 << 1);
}
};

struct Vector3Hash {
std::size_t operator()(const Vector3 &v) const {
std::size_t h1 = std::hash<float>()(v.x);
std::size_t h2 = std::hash<float>()(v.y);
std::size_t h3 = std::hash<float>()(v.z);
return h1 ^ (h2 << 1) ^ (h3 << 2);
}
};
Loading
Loading