From c49dfb9b8c65a05d2c14267b664c31e8f58f9391 Mon Sep 17 00:00:00 2001 From: ecker Date: Mon, 4 Aug 2025 17:51:43 -0500 Subject: [PATCH] some stuff to get the dreamcast build working again (or at least compiling, reading from the CD through KOS in emulators broke so I can't test much) --- Makefile | 15 +-- .../scenes/sourceengine/sourceengine.json | 4 +- bin/data/scenes/sourceengine/ss2_medsci1.json | 3 +- bin/dreamcast/{ => data}/config.json | 2 +- bin/dreamcast/elf2cdi.sh | 2 +- dep/include/dreamcast.h | 2 +- dep/src/imgui/imgui_stdlib.cpp | 5 +- engine/inc/uf/utils/io/console.h | 1 + engine/inc/uf/utils/io/inputs.h | 1 + engine/inc/uf/utils/math/physics.h | 6 +- engine/inc/uf/utils/math/physics/stub.h | 108 ++++++++++++++++++ engine/src/engine/entity/entity.cpp | 4 + engine/src/engine/graph/graph.cpp | 2 +- engine/src/engine/object/behavior.cpp | 2 + engine/src/engine/scene/behavior.cpp | 1 + engine/src/ext/gltf/gltf.cpp | 2 + engine/src/ext/lua/lua.cpp | 2 +- engine/src/spec/window/dreamcast.cpp | 8 +- engine/src/utils/debug/checkpoint.cpp | 4 + engine/src/utils/io/console.cpp | 6 + engine/src/utils/io/inputs.cpp | 1 + engine/src/utils/math/physics.cpp | 3 +- ext/behaviors/craeture/behavior.cpp | 2 + ext/behaviors/gui/glyph/behavior.cpp | 12 +- ext/behaviors/player/behavior.cpp | 2 + ext/behaviors/scene/behavior.cpp | 10 ++ ext/main.cpp | 7 +- makefiles/dreamcast.gcc.make | 2 +- 28 files changed, 194 insertions(+), 25 deletions(-) rename bin/dreamcast/{ => data}/config.json (94%) create mode 100644 engine/inc/uf/utils/math/physics/stub.h diff --git a/Makefile b/Makefile index 12d5a9ff..866b755d 100644 --- a/Makefile +++ b/Makefile @@ -64,11 +64,11 @@ LINKS += $(UF_LIBS) $(EXT_LIBS) $(DEPS) DEPS += FLAGS += -DUF_DEBUG -ifneq (,$(findstring -DUF_DEBUG,$(FLAGS))) - REQ_DEPS += meshoptimizer toml xatlas curl ffx:fsr cpptrace vall_e # ncurses openvr draco discord bullet ultralight-ux - FLAGS += -g -endif ifneq (,$(findstring win64,$(ARCH))) + ifneq (,$(findstring -DUF_DEBUG,$(FLAGS))) + REQ_DEPS += meshoptimizer toml xatlas curl ffx:fsr cpptrace vall_e # ncurses openvr draco discord bullet ultralight-ux + FLAGS += -g + endif REQ_DEPS += $(RENDERER) json:nlohmann png zlib luajit reactphysics simd ctti gltf imgui fmt freetype openal ogg wav # meshoptimizer toml xatlas curl ffx:fsr cpptrace # ncurses openvr draco discord bullet ultralight-ux FLAGS += -DUF_ENV_WINDOWS -DUF_ENV_WIN64 -DWIN32_LEAN_AND_MEAN DEPS += -lgdi32 -ldwmapi @@ -76,7 +76,7 @@ ifneq (,$(findstring win64,$(ARCH))) INCS := -I./dep/master/include $(INCS) else ifneq (,$(findstring dreamcast,$(ARCH))) FLAGS += -DUF_ENV_DREAMCAST - REQ_DEPS += simd opengl gldc json:nlohmann reactphysics png zlib ctti lua fmt imgui freetype openal aldc ogg # gltf bullet meshoptimizer draco luajit ultralight-ux ncurses curl openvr discord + REQ_DEPS += simd opengl gldc json:nlohmann png zlib ctti reactphysics lua freetype fmt imgui openal aldc ogg wav gltf # bullet meshoptimizer draco luajit ultralight-ux ncurses curl openvr discord INCS := -I./dep/dreamcast/include $(INCS) endif ifneq (,$(findstring vulkan,$(REQ_DEPS))) @@ -90,7 +90,7 @@ ifneq (,$(findstring opengl,$(REQ_DEPS))) ifneq (,$(findstring dreamcast,$(ARCH))) ifneq (,$(findstring gldc,$(REQ_DEPS))) - DEPS += -lGLdc + DEPS += -lGL # kos-ports version saves it as libGL instead of libGLdc FLAGS += -DUF_USE_OPENGL_GLDC else DEPS += -lGL @@ -109,6 +109,7 @@ endif ifneq (,$(findstring fmt,$(REQ_DEPS))) FLAGS += -DUF_USE_FMT ifneq (,$(findstring dreamcast,$(ARCH))) + # dreamcast uses a header only version because reasons else DEPS += -lfmt endif @@ -155,7 +156,7 @@ ifneq (,$(findstring openal,$(REQ_DEPS))) FLAGS += -DUF_USE_OPENAL -DUF_USE_ALUT ifneq (,$(findstring dreamcast,$(ARCH))) ifneq (,$(findstring aldc,$(REQ_DEPS))) - DEPS += -lALdc + DEPS += -lAL -lpthread # kos-ports version saves it as libAL instead of libALdc FLAGS += -DUF_USE_OPENAL_ALDC -DUF_USE_ALUT else DEPS += -lAL diff --git a/bin/data/scenes/sourceengine/sourceengine.json b/bin/data/scenes/sourceengine/sourceengine.json index 0ca77b5c..c1897bce 100644 --- a/bin/data/scenes/sourceengine/sourceengine.json +++ b/bin/data/scenes/sourceengine/sourceengine.json @@ -1,8 +1,8 @@ { // "import": "./rp_downtown_v2.json" -// "import": "./ss2_medsci1.json" + "import": "./ss2_medsci1.json" // "import": "./sh2_mcdonalds.json" - "import": "./animal_crossing.json" +// "import": "./animal_crossing.json" // "import": "./mds_mcdonalds.json" // "import": "./gm_construct.json" } \ No newline at end of file diff --git a/bin/data/scenes/sourceengine/ss2_medsci1.json b/bin/data/scenes/sourceengine/ss2_medsci1.json index 9e0b7a6a..295c1174 100644 --- a/bin/data/scenes/sourceengine/ss2_medsci1.json +++ b/bin/data/scenes/sourceengine/ss2_medsci1.json @@ -2,7 +2,8 @@ "import": "./base_sourceengine.json", "assets": [ // { "filename": "./models/ss2_medsci1.glb" } - { "filename": "./models/ss2_medsci1/graph.json" } + // { "filename": "./models/ss2_medsci1/graph.json" } + { "filename": "./models/ss2_medsci1_small/graph.json" } ], "metadata": { "graph": { diff --git a/bin/dreamcast/config.json b/bin/dreamcast/data/config.json similarity index 94% rename from bin/dreamcast/config.json rename to bin/dreamcast/data/config.json index 51bd999b..3afd814a 100644 --- a/bin/dreamcast/config.json +++ b/bin/dreamcast/data/config.json @@ -1,7 +1,7 @@ { "engine": { "scenes": { - "start": "StartMenu", + "start": "SourceEngine", "matrix": { "reverseInfinite": true }, "meshes": { "interleaved": false }, "lights": { "enabled": true, diff --git a/bin/dreamcast/elf2cdi.sh b/bin/dreamcast/elf2cdi.sh index ecc2f996..c6dca79c 100644 --- a/bin/dreamcast/elf2cdi.sh +++ b/bin/dreamcast/elf2cdi.sh @@ -6,6 +6,6 @@ rm ./build/* sh-elf-objcopy.exe -O binary $DIR/*.elf ./$TARGET_NAME.bin $KOS_BASE/utils/scramble/scramble.exe ./$TARGET_NAME.bin ./build/1ST_READ.bin $KOS_BASE/utils/makeip/makeip.exe -g "$TARGET_NAME" ./build/IP.BIN -xorrisofs -C 0,11702 -V DC_GAME -G ./build/IP.BIN -r -J -l -o ./$TARGET_NAME.iso ./build/ ../data/ ./config.json +xorrisofs -C 0,11702 -V DC_GAME -G ./build/IP.BIN -r -J -l -o ./$TARGET_NAME.iso ./build/ ../data/ ./data/ $KOS_BASE/utils/img4dc/cdi4dc.exe ./$TARGET_NAME.iso ./$TARGET_NAME.cdi > /dev/null # cp ./$TARGET_NAME.cdi /x/programs/vidya/emulators/redream/CDI/. \ No newline at end of file diff --git a/dep/include/dreamcast.h b/dep/include/dreamcast.h index 4bc6cf1c..2b4cba34 100644 --- a/dep/include/dreamcast.h +++ b/dep/include/dreamcast.h @@ -6,7 +6,7 @@ #include namespace std { -#if 1 +#if 0 inline double log2( double n ) { return log(n) / log(2); } inline double cbrt( double x ) { return ::cbrt( x ); } #endif diff --git a/dep/src/imgui/imgui_stdlib.cpp b/dep/src/imgui/imgui_stdlib.cpp index bbd976b4..13bd7b56 100644 --- a/dep/src/imgui/imgui_stdlib.cpp +++ b/dep/src/imgui/imgui_stdlib.cpp @@ -3,7 +3,7 @@ // Changelog: // - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string - +#if UF_USE_IMGUI #include "imgui.h" #include "imgui_stdlib.h" @@ -69,4 +69,5 @@ bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* cb_user_data.ChainCallback = callback; cb_user_data.ChainCallbackUserData = user_data; return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/engine/inc/uf/utils/io/console.h b/engine/inc/uf/utils/io/console.h index a5673004..3b1dcf0a 100644 --- a/engine/inc/uf/utils/io/console.h +++ b/engine/inc/uf/utils/io/console.h @@ -3,6 +3,7 @@ #include #include #include +#include //#define UF_INPUT_USE_ENUM_MOUSE 1 diff --git a/engine/inc/uf/utils/io/inputs.h b/engine/inc/uf/utils/io/inputs.h index 22b86477..dc83dea0 100644 --- a/engine/inc/uf/utils/io/inputs.h +++ b/engine/inc/uf/utils/io/inputs.h @@ -3,6 +3,7 @@ #include #include #include +#include #define UF_INPUT_USE_ENUM_MOUSE 1 diff --git a/engine/inc/uf/utils/math/physics.h b/engine/inc/uf/utils/math/physics.h index b25e592d..35b36df9 100644 --- a/engine/inc/uf/utils/math/physics.h +++ b/engine/inc/uf/utils/math/physics.h @@ -5,9 +5,11 @@ #include #if UF_USE_BULLET -#include + #include #elif UF_USE_REACTPHYSICS -#include + #include +#else + #include "physics/stub.h" #endif namespace uf { diff --git a/engine/inc/uf/utils/math/physics/stub.h b/engine/inc/uf/utils/math/physics/stub.h new file mode 100644 index 00000000..afd97b58 --- /dev/null +++ b/engine/inc/uf/utils/math/physics/stub.h @@ -0,0 +1,108 @@ +// enough things to get it to compile without a physics lib +namespace uf { + struct Mesh; +} + +namespace pod { + struct UF_API Physics { + size_t uid = 0; + uf::Object* object = NULL; + + bool shared = false; // share control of the transform both in-engine and bullet, set to true if you're directly modifying the transform + void* body = NULL; + void* shape = NULL; + + void* world = NULL; + + pod::Transform<> transform = {}; + + struct Linear { + pod::Vector3f velocity; + pod::Vector3f acceleration; + } linear; + struct Angular { + pod::Quaternion<> velocity; + pod::Quaternion<> acceleration; + } rotational; + + struct { + struct { + pod::Transform<> transform = {}; + Linear linear; + Angular rotational; + } current, previous; + } internal; + + + struct { + uint32_t flags = 0; + float mass = 0.0f; + float friction = 0.8f; + float restitution = 0.0f; + pod::Vector3f inertia = {0, 0, 0}; + pod::Vector3f gravity = {0, 0, 0}; + } stats; + }; + + typedef Physics PhysicsState; +} + +namespace uf { + namespace physics { + namespace impl { + typedef void* WorldState; + inline void UF_API initialize() {} + inline void UF_API initialize( uf::Object& ) {} + inline void UF_API tick( float = 0 ) {} + inline void UF_API tick( uf::Object&, float = 0 ) {} + inline void UF_API terminate() {} + inline void UF_API terminate( uf::Object& ) {} + + // base collider creation + inline pod::PhysicsState& UF_API create( uf::Object& ) { static pod::PhysicsState null; return null; } + + inline void UF_API destroy( uf::Object& ) { return; } + inline void UF_API destroy( pod::PhysicsState& ) { return; } + + inline void UF_API attach( pod::PhysicsState& ) { return; } + inline void UF_API detach( pod::PhysicsState& ) { return; } + + // collider for mesh (static or dynamic) + inline pod::PhysicsState& create( uf::Object&, const uf::Mesh&, bool ) { static pod::PhysicsState null; return null; } + // collider for boundingbox + inline pod::PhysicsState& UF_API create( uf::Object&, const pod::Vector3f& ) { static pod::PhysicsState null; return null; } + // collider for capsule + inline pod::PhysicsState& UF_API create( uf::Object&, float, float ) { static pod::PhysicsState null; return null; } + /* + // synchronize engine transforms to bullet transforms + inline void UF_API syncTo( ext::reactphysics::WorldState& ) { return; } + // synchronize bullet transforms to engine transforms + inline void UF_API syncFrom( ext::reactphysics::WorldState&, float = 1 ) { return; } + */ + // apply impulse + inline void UF_API setImpulse( pod::PhysicsState&, const pod::Vector3f& = {} ) { return; } + inline void UF_API applyImpulse( pod::PhysicsState&, const pod::Vector3f& ) { return; } + // directly move a transform + inline void UF_API applyMovement( pod::PhysicsState&, const pod::Vector3f& ) { return; } + // directly apply a velocity + inline void UF_API setVelocity( pod::PhysicsState&, const pod::Vector3f& ) { return; } + inline void UF_API applyVelocity( pod::PhysicsState&, const pod::Vector3f& ) { return; } + // directly rotate a transform + inline void UF_API applyRotation( pod::PhysicsState&, const pod::Quaternion<>& ) { return; } + inline void UF_API applyRotation( pod::PhysicsState&, const pod::Vector3f&, float ) { return; } + + // ray casting + inline uf::Object* UF_API rayCast( const pod::Vector3f&, const pod::Vector3f& ) { return NULL; } + inline uf::Object* UF_API rayCast( pod::PhysicsState&, const pod::Vector3f&, const pod::Vector3f& ) { return NULL; } + inline uf::Object* UF_API rayCast( pod::PhysicsState&, const pod::Vector3f&, const pod::Vector3f&, float& ) { return NULL; } + inline uf::Object* UF_API rayCast( const pod::Vector3f&, const pod::Vector3f&, uf::Object*, float& ) { return NULL; } + + // allows noclip + inline void UF_API activateCollision( pod::PhysicsState&, bool = true ) { return; } + + // + inline float UF_API getMass( pod::PhysicsState& ) { return {}; } + inline void UF_API setMass( pod::PhysicsState&, float ) { return; } + } + } +} \ No newline at end of file diff --git a/engine/src/engine/entity/entity.cpp b/engine/src/engine/entity/entity.cpp index 294eb4b8..418c85e0 100644 --- a/engine/src/engine/entity/entity.cpp +++ b/engine/src/engine/entity/entity.cpp @@ -170,5 +170,9 @@ uf::Entity* uf::Entity::globalFindByName( const uf::stl::string& name ) { #include uf::stl::string uf::string::toString( const uf::Entity& entity ) { +#if UF_USE_FMT return ::fmt::format("{} ({}): {}", entity.getName(), entity.getUid(), (void*) &entity); +#else + return entity.getName() + " (" + std::to_string(entity.getUid()) + "): " + std::to_string(&entity); +#endif } \ No newline at end of file diff --git a/engine/src/engine/graph/graph.cpp b/engine/src/engine/graph/graph.cpp index b70de61c..2d47f90a 100644 --- a/engine/src/engine/graph/graph.cpp +++ b/engine/src/engine/graph/graph.cpp @@ -1475,7 +1475,7 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent ) collider.stats.restitution = phyziks["restitution"].as(collider.stats.restitution); collider.stats.inertia = uf::vector::decode( phyziks["inertia"], collider.stats.inertia ); collider.stats.gravity = uf::vector::decode( phyziks["gravity"], collider.stats.gravity ); - + uf::physics::impl::create( entity.as(), mesh, !phyziks["static"].as(true) ); } else { auto min = uf::matrix::multiply( model, bounds.min, 1.0f ); diff --git a/engine/src/engine/object/behavior.cpp b/engine/src/engine/object/behavior.cpp index eb2c7eaf..21a0da9e 100644 --- a/engine/src/engine/object/behavior.cpp +++ b/engine/src/engine/object/behavior.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -11,6 +12,7 @@ #include #include #include +#include UF_BEHAVIOR_ENTITY_CPP_BEGIN(uf::Object) UF_BEHAVIOR_TRAITS_CPP(uf::ObjectBehavior, ticks = true, renders = false, multithread = false) // segfaults @ engine/src/ext/lua/lua.cpp:298 `auto result = state.safe_script_file( s.file, s.env, sol::script_pass_on_error );` diff --git a/engine/src/engine/scene/behavior.cpp b/engine/src/engine/scene/behavior.cpp index 835b6aeb..1e6adabf 100644 --- a/engine/src/engine/scene/behavior.cpp +++ b/engine/src/engine/scene/behavior.cpp @@ -3,6 +3,7 @@ #include #include #include +#include UF_BEHAVIOR_ENTITY_CPP_BEGIN(uf::Scene) UF_BEHAVIOR_TRAITS_CPP(uf::SceneBehavior, ticks = false, renders = false, multithread = false) diff --git a/engine/src/ext/gltf/gltf.cpp b/engine/src/ext/gltf/gltf.cpp index 4cb2423a..c6cf4859 100644 --- a/engine/src/ext/gltf/gltf.cpp +++ b/engine/src/ext/gltf/gltf.cpp @@ -556,7 +556,9 @@ pod::Graph ext::gltf::load( const uf::stl::string& filename, const uf::Serialize #endif if ( graph.metadata["exporter"]["enabled"].as() ) { + #if !UF_ENV_DREAMCAST graph.name = uf::graph::save( graph, filename ); + #endif // disable baking, doesn't output right if baking from a gltf imported model // graph.metadata["baking"]["enabled"] = false; diff --git a/engine/src/ext/lua/lua.cpp b/engine/src/ext/lua/lua.cpp index c579a355..815d598b 100644 --- a/engine/src/ext/lua/lua.cpp +++ b/engine/src/ext/lua/lua.cpp @@ -131,7 +131,7 @@ namespace binds { std::cout << str; if ( --count != 0 ) std::cout << "\t"; } - std::cout <<"\n"); + std::cout <<"\n"; std::cout.flush(); #endif }; diff --git a/engine/src/spec/window/dreamcast.cpp b/engine/src/spec/window/dreamcast.cpp index 586c338d..c4896b27 100644 --- a/engine/src/spec/window/dreamcast.cpp +++ b/engine/src/spec/window/dreamcast.cpp @@ -47,8 +47,12 @@ namespace { pod::Vector2ui resolution = { 640, 480 }; bool GetModifier( uint8_t modifier ) { + // to-fix later + return false; + /* if ( !::keyboard.state ) return false; return ::keyboard.state->cond.modifiers & modifier; + */ } uf::stl::vector GetKeys() { uf::stl::vector keys; @@ -367,11 +371,11 @@ spec::dreamcast::Window::vector_t spec::dreamcast::Window::getMousePosition( ) { } void spec::dreamcast::Window::setSize( const spec::dreamcast::Window::vector_t& size ) { int e = 0; - int p = PM_RGB565; + vid_pixel_mode_t p = PM_RGB565; if ( size.x == 320 && size.y == 240 ) e = DM_320x240; else if ( size.x == 640 && size.y == 480 ) e = DM_640x480; - else if ( size.x == 800 && size.y == 608 ) e = DM_800x608; + //else if ( size.x == 800 && size.y == 608 ) e = DM_800x608; else if ( size.x == 256 && size.y == 256 ) e = DM_256x256; else if ( size.x == 768 && size.y == 480 ) e = DM_768x480; else if ( size.x == 768 && size.y == 576 ) e = DM_768x576; diff --git a/engine/src/utils/debug/checkpoint.cpp b/engine/src/utils/debug/checkpoint.cpp index 1482ea50..9302d719 100644 --- a/engine/src/utils/debug/checkpoint.cpp +++ b/engine/src/utils/debug/checkpoint.cpp @@ -50,7 +50,11 @@ uf::stl::string uf::checkpoint::traverse( pod::Checkpoint* checkpoint ) { case pod::Checkpoint::BEGIN: type = "BEGIN"; break; case pod::Checkpoint::END: type = "END"; break; } + #if UF_USE_FMT res.emplace( res.begin(), ::fmt::format("[{}] [{}]: {}", type, checkpoint->info, checkpoint->name) ); + #else + res.emplace( res.begin(), "[" + type + "] [" + checkpoint->info + "]: " + checkpoint->name ); + #endif checkpoint = checkpoint->previous; } diff --git a/engine/src/utils/io/console.cpp b/engine/src/utils/io/console.cpp index fd9c385a..723e6ac9 100644 --- a/engine/src/utils/io/console.cpp +++ b/engine/src/utils/io/console.cpp @@ -53,12 +53,14 @@ void uf::console::initialize() { // this could probably be its own function uf::stl::string s_result = ""; + #if UF_USE_FMT for ( auto i = 0; i < results.size(); ++i ) { auto& res = results[i]; if ( res.is() ) s_result += ::fmt::format("\n[{}] => {}", i, res.as()); else if ( res.is() ) s_result += ::fmt::format("\n[{}] => {}", i, ext::json::encode( res.as() )); else s_result += ::fmt::format("\n[{}] => Userdata: {}", i, (void*) res); } + #endif return "Hook executed: " + match[1] + s_result; }); @@ -98,7 +100,11 @@ void uf::console::initialize() { }; for ( uf::Scene* scene : uf::scene::scenes ) { if ( !scene ) continue; + #if UF_USE_FMT res += ::fmt::format("Scene: {}: {}\n", scene->getName(), scene->getUid()); + #else + res += "Scene: " + scene->getName() + ": " + std::to_string(scene->getUid()) + "\n"; + #endif scene->process(filter, 1); } diff --git a/engine/src/utils/io/inputs.cpp b/engine/src/utils/io/inputs.cpp index 4d0591ff..47b65d41 100644 --- a/engine/src/utils/io/inputs.cpp +++ b/engine/src/utils/io/inputs.cpp @@ -1,4 +1,5 @@ #include +#include uf::inputs::state_t uf::inputs::kbm::states::LShift = false; uf::inputs::state_t uf::inputs::kbm::states::RShift = false; diff --git a/engine/src/utils/math/physics.cpp b/engine/src/utils/math/physics.cpp index 05edaca3..73060317 100644 --- a/engine/src/utils/math/physics.cpp +++ b/engine/src/utils/math/physics.cpp @@ -1,5 +1,6 @@ -#include +#include #include +#include #include /* diff --git a/ext/behaviors/craeture/behavior.cpp b/ext/behaviors/craeture/behavior.cpp index 6fc0a743..20c3cd80 100644 --- a/ext/behaviors/craeture/behavior.cpp +++ b/ext/behaviors/craeture/behavior.cpp @@ -49,6 +49,7 @@ namespace { } void load_migoto( uf::Object& self, const uf::Serializer& json ) { + #if !UF_ENV_DREAMCAST struct Position { pod::Vector3f position; pod::Vector3f normal; @@ -130,6 +131,7 @@ namespace { mesh.insertIndices( indices ); uf::graph::convert( self ); + #endif } } void ext::CraetureBehavior::initialize( uf::Object& self ) { diff --git a/ext/behaviors/gui/glyph/behavior.cpp b/ext/behaviors/gui/glyph/behavior.cpp index f13805db..a2e9d4f0 100644 --- a/ext/behaviors/gui/glyph/behavior.cpp +++ b/ext/behaviors/gui/glyph/behavior.cpp @@ -69,8 +69,13 @@ namespace { }; struct { + #if UF_USE_FREETYPE ext::freetype::Glyph glyph; uf::stl::unordered_map> cache; + #else + char glyph; + uf::stl::unordered_map> cache; + #endif } glyphs; struct { @@ -96,12 +101,14 @@ namespace { } uf::stl::vector<::GlyphBox> generateGlyphs( uf::Object& self, const uf::stl::string& _string ) { + uf::stl::vector<::GlyphBox> gs; + + #if UF_USE_FREETYPE auto& glyphs = ::glyphs; auto& metadata = this->getComponent(); auto& metadataGui = this->getComponent(); auto& transform = this->getComponent>(); - uf::stl::vector<::GlyphBox> gs; auto string = _string == "" ? metadata.string : _string; auto font = uf::io::root+"/fonts/" + metadata.font; @@ -311,6 +318,7 @@ namespace { gs.push_back(g); } + #endif return gs; } @@ -354,6 +362,7 @@ void ext::GuiGlyphBehavior::initialize( uf::Object& self ) { metadataGui.scaleMode = "none"; // generate texture + #if UF_USE_FREETYPE { atlas.clear(); @@ -393,6 +402,7 @@ void ext::GuiGlyphBehavior::initialize( uf::Object& self ) { atlas.generate(); atlas.clear(false); } + #endif // generate mesh { diff --git a/ext/behaviors/player/behavior.cpp b/ext/behaviors/player/behavior.cpp index 413696ff..bd398ef9 100644 --- a/ext/behaviors/player/behavior.cpp +++ b/ext/behaviors/player/behavior.cpp @@ -414,10 +414,12 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { TIMER(0.25, keys.vee ) { bool state = !stats.noclipped; metadata.system.noclipped = state; + #if UF_USE_REACTPHYSICS if ( collider.body ) { collider.body->enableGravity(!state); uf::physics::impl::activateCollision(collider, !state); } + #endif stats.noclipped = state; UF_MSG_DEBUG( "{}abled noclip: {}", (state ? "En" : "Dis"), uf::vector::toString(transform.position)); diff --git a/ext/behaviors/scene/behavior.cpp b/ext/behaviors/scene/behavior.cpp index eacb5485..f4dfffa1 100644 --- a/ext/behaviors/scene/behavior.cpp +++ b/ext/behaviors/scene/behavior.cpp @@ -14,6 +14,8 @@ #include #include +#include +#include #include #include @@ -330,7 +332,11 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) { for ( uf::Scene* scene : uf::scene::scenes ) { if ( !scene ) continue; + #if UF_USE_FMT uf::iostream << ::fmt::format("Scene: {}\n", uf::string::toString( *scene )); + #else + uf::iostream << "Scene: " << uf::string::toString( *scene ) << "\n"; + #endif scene->process([]( uf::Entity* entity, int depth ) { uf::stl::string indent = ""; for ( auto i = 1; i < depth; ++i ) indent += "\t"; uf::stl::string location = ""; @@ -340,7 +346,11 @@ void ext::ExtSceneBehavior::tick( uf::Object& self ) { location = uf::string::toString( t.position ) + " " + uf::string::toString( t.orientation ); } + #if UF_USE_FMT uf::iostream << ::fmt::format("{} {} {}\n", indent, uf::string::toString( *entity ), location ); + #else + uf::iostream << indent << " " << uf::string::toString( *entity ) << " " << location << "\n"; + #endif }, 1); } } diff --git a/ext/main.cpp b/ext/main.cpp index 8d812832..909fc63c 100644 --- a/ext/main.cpp +++ b/ext/main.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,8 @@ #include #include +#include + #include #include #include @@ -107,7 +108,11 @@ namespace { } void EXT_API ext::load() { +#if UF_ENV_DREAMCAST + ext::config.readFromFile("/cd/data/config.json"); +#else ext::config.readFromFile(uf::io::root+"/config.json"); +#endif } void EXT_API ext::load( ext::json::Value& json ) { ::config.engine.gc.enabled = json["engine"]["debug"]["garbage collection"]["enabled"].as(::config.engine.gc.enabled); diff --git a/makefiles/dreamcast.gcc.make b/makefiles/dreamcast.gcc.make index 2e05a6f1..c95d1db9 100644 --- a/makefiles/dreamcast.gcc.make +++ b/makefiles/dreamcast.gcc.make @@ -6,6 +6,6 @@ RENDERER = opengl TARGET_EXTENSION = elf OPTIMIZATIONS = -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -fstrict-aliasing -ffast-math -fno-unroll-all-loops -fno-optimize-sibling-calls -fschedule-insns2 -fomit-frame-pointer -DUF_NO_EXCEPTIONS -fno-exceptions # -g # -flto WARNINGS = -Wno-attributes -Wno-conversion-null -FLAGS += $(KOS_CPPFLAGS) -std=c++17 $(OPTIMIZATIONS) $(WARNINGS) -fdiagnostics-color=always +FLAGS += $(KOS_CPPFLAGS) -m4-single-only -std=c++17 $(OPTIMIZATIONS) $(WARNINGS) -fdiagnostics-color=always INCS += $(KOS_INC_PATHS) -I/opt/dreamcast/sh-elf/sh-elf/include LIBS += $(KOS_LIB_PATHS) -L/opt/dreamcast/sh-elf/sh-elf/lib \ No newline at end of file