diff --git a/Makefile b/Makefile index 68bfc674..0c507da1 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ EXT_LIB_NAME += ext #VULKAN_SDK_PATH += /c/VulkanSDK/1.3.211.0/ #VULKAN_SDK_PATH += /c/VulkanSDK/1.3.216.0/ VULKAN_SDK_PATH += /c/VulkanSDK/1.3.224.1/ +#VULKAN_SDK_PATH += /c/VulkanSDK/1.3.231.1/ GLSLC += $(VULKAN_SDK_PATH)/Bin/glslc SPV_OPTIMIZER += $(VULKAN_SDK_PATH)/Bin/spirv-opt @@ -59,17 +60,15 @@ LINKS += $(UF_LIBS) $(EXT_LIBS) $(DEPS) DEPS += ifneq (,$(findstring win64,$(ARCH))) - ifneq (,$(findstring zig,$(CC))) - REQ_DEPS += $(RENDERER) json:nlohmann toml png zlib luajit reactphysics meshoptimizer xatlas simd ctti gltf imgui fmt curl freetype openal ogg ffx:fsr # ncurses openvr draco discord bullet ultralight-ux - else - REQ_DEPS += $(RENDERER) json:nlohmann toml png zlib luajit reactphysics meshoptimizer xatlas simd ctti gltf imgui fmt curl freetype openal ogg ffx:fsr # ncurses openvr draco discord bullet ultralight-ux - endif + REQ_DEPS += $(RENDERER) json:nlohmann toml png zlib luajit reactphysics meshoptimizer xatlas simd ctti gltf imgui fmt curl freetype openal ogg # ffx:fsr ncurses openvr draco discord bullet ultralight-ux FLAGS += -DUF_ENV_WINDOWS -DUF_ENV_WIN64 -DWIN32_LEAN_AND_MEAN DEPS += -lgdi32 -ldwmapi LINKS += #-Wl,-subsystem,windows + 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 # ogg openal aldc gltf freetype bullet meshoptimizer draco luajit ultralight-ux ncurses curl openvr discord + INCS := -I./dep/dreamcast/include $(INCS) endif ifneq (,$(findstring vulkan,$(REQ_DEPS))) FLAGS += -DVK_USE_PLATFORM_WIN32_KHR -DUF_USE_VULKAN diff --git a/bin/data/config.json b/bin/data/config.json index fcf06cf4..8f2b07f5 100644 --- a/bin/data/config.json +++ b/bin/data/config.json @@ -1,11 +1,11 @@ { "engine": { "scenes": { - "start": "SourceEngine", + "start": "StartMenu", "matrix": { "reverseInfinite": true }, "meshes": { "interleaved": false }, "lights": { "enabled": true, - "useLightmaps": true, + "useLightmaps": false, "max": 16, "shadows": { "enabled": true, @@ -92,7 +92,7 @@ }, "framebuffer": { "msaa": 1, - "size": 0.75 // 1 + "size": 1 // "size": [ 640, 480, "NEAREST" ] // "size": [ 1280, 720 ] // "size": [ 960, 540 ] @@ -109,8 +109,8 @@ "deferred": true, "vsync": false, "hdr": false, - "vxgi": true, - "culling": true, + "vxgi": false, + "culling": false, "bloom": false, "rt": false, "postProcess": false, diff --git a/bin/data/entities/burger.json b/bin/data/entities/burger.json index f207132c..df96f577 100644 --- a/bin/data/entities/burger.json +++ b/bin/data/entities/burger.json @@ -1,7 +1,7 @@ { "type": "Object", "name": "Burger", - "ignore": false, + "ignore": true, "import": "/model.json", "assets": [ // "/burger/burger.glb" @@ -12,6 +12,7 @@ "behaviors": [], "transform": { "position": [ -0.574743, 2.3547, -5.05161 ], + // "position": [ -4.66561, 0.0736207, -5.98057 ], "rotation": { "axis": [ 0, 1, 0 ], "angle": 0 diff --git a/bin/data/entities/light.json b/bin/data/entities/light.json index 55f24d58..4b07bfa5 100644 --- a/bin/data/entities/light.json +++ b/bin/data/entities/light.json @@ -26,7 +26,7 @@ "bias": { "constant": 1.25, "slope": 1.75, - "shader": 0.000025 // 0.000005 //0.000000005 + "shader": 0.00000005 // 0.000005 //0.000000005 }, "radius": [0.25, 0], "resolution": 256, diff --git a/bin/data/entities/model.json b/bin/data/entities/model.json index 18e81d5d..a245e19b 100644 --- a/bin/data/entities/model.json +++ b/bin/data/entities/model.json @@ -38,7 +38,7 @@ }, "baking": { "enabled": true, - "resolution": 4096, + "resolution": 2048, "shadows": 1024, "layers": 1, "trigger": { "mode": "rendered", "quit": true }, diff --git a/bin/data/entities/playerModel.json b/bin/data/entities/playerModel.json index 4a340d63..c8f1796e 100644 --- a/bin/data/entities/playerModel.json +++ b/bin/data/entities/playerModel.json @@ -1,7 +1,7 @@ { "type": "Object", "name": "Player: Model", - "ignore": false, + "ignore": true, "import": "/model.json", "assets": [ "/player/bear.glb" diff --git a/bin/data/scenes/cornell/cornell.json b/bin/data/scenes/cornell/cornell.json deleted file mode 100644 index 560b1091..00000000 --- a/bin/data/scenes/cornell/cornell.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "import": "/model.json", - "assets": [ - // { "filename": "./models/cornell.glb" } - // { "filename": "./models/cornell/graph.json" } - - // { "filename": "./models/sponza.glb" } - // { "filename": "./models/sponza/graph.json" } - - // { "filename": "./models/sponza-cornell.glb" } - { "filename": "./models/sponza-cornell/graph.json" } - ], - "metadata": { - "graph": { - "baking": { - "enabled": false, - "resolution": 2048, - "settings": { - "useInputMeshUvs": false - } - }, - "tags": { - "/^Mesh_/": { - "physics": { "type": "mesh", "static": true }, - // "grid": { "size": [3,1,3], "epsilon": 0.0001, "cleanup": true, "print": true }, - // "optimize mesh": { "simplify": 0 }, - "unwrap mesh": true - }, - "Camera": { - "action": "attach", - "filename": "./player.json", - "preserve orientation": true - } - } - } - } -} \ No newline at end of file diff --git a/bin/data/scenes/cornell/loading.json b/bin/data/scenes/cornell/loading.json deleted file mode 100644 index 3a818433..00000000 --- a/bin/data/scenes/cornell/loading.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "Gui: Loading", - "type": "Object", - "behaviors": [ - "GuiBehavior" - ], - "assets": [ - { "filename": "./cornell.json", "delay": 0 } - ], - "ignore": false, - "transform": { - "position": [ -0.830591, -0.699509, 0 ], - "rotation": { - "axis": [ 1, 0, 0 ], - "angle": 0 - }, - "scale": [ 0.258737, 0.115371, 1 ] - }, - "metadata": { - "uv": [ 0, 0, 1, 1 ], - "color": [ 1, 1, 1, 0.1 ], - "location": "", - "scaling": "relative", - "text settings": { - "stroke": [ 1, 0.749, 0.368, 1 ], - "color": [ 1, 0.749, 0.368, 1 ], - - "string": "Loading...", - "string1": "コマンド" - } - } -} \ No newline at end of file diff --git a/bin/data/scenes/cornell/player.json b/bin/data/scenes/cornell/player.json deleted file mode 100644 index ddfc0fa3..00000000 --- a/bin/data/scenes/cornell/player.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "import": "/player.json", - "assets": [ - // { "filename": "/gui/hud/hud.json", "delay": 0 } - ], - "metadata": { - "physics": { - "collider": false, - "gravity": [ 0, 0, 0 ] - } - } -} \ No newline at end of file diff --git a/bin/data/scenes/cornell/scene.json b/bin/data/scenes/cornell/scene.json deleted file mode 100644 index f20f895e..00000000 --- a/bin/data/scenes/cornell/scene.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "import": "/scene.json", - "assets": [ - // "./loading.json" - "./cornell.json" - ], - "metadata": { - "light": { - // "ambient": [ 0.0, 0.0, 0.0 ], - "ambient": [ 0.5, 0.5, 0.5 ] - } - } -} \ No newline at end of file diff --git a/bin/data/scenes/sm64/sm64.json b/bin/data/scenes/sm64/sm64.json index c22151dd..6ccfe8c8 100644 --- a/bin/data/scenes/sm64/sm64.json +++ b/bin/data/scenes/sm64/sm64.json @@ -1,8 +1,8 @@ { "import": "/model.json", "assets": [ - // { "filename": "./models/sm64_bbb.glb" } - { "filename": "./models/sm64_bbb/graph.json" } + { "filename": "./models/sm64_bbb.glb" } + // { "filename": "./models/sm64_bbb/graph.json" } ], "metadata": { "graph": { @@ -14,7 +14,7 @@ "tags": { "/^worldspawn/": { "physics": { "type": "mesh", "static": true }, - "grid": { "size": [9,1,9], "epsilon": 1.0, "cleanup": true, "print": true }, + "grid": { "size": [3,1,3], "epsilon": 1.0, "cleanup": true, "print": true }, "optimize mesh": { "simplify": 0 }, "unwrap mesh": true }, @@ -23,7 +23,7 @@ "Material.071_574B138E_c.bmp": { "material": { "modeAlpha": "blend" } }, "Material.070_41A41EE3_c.bmp": { "material": { "modeAlpha": "blend" } }, - "light_sun": { "light": { "power": 25000 } } + "light_sun": { "light": { "power": 25000000 } } } } } diff --git a/bin/data/scenes/sourceengine/base_sourceengine.json b/bin/data/scenes/sourceengine/base_sourceengine.json index 9b3f7ea6..c1f787d5 100644 --- a/bin/data/scenes/sourceengine/base_sourceengine.json +++ b/bin/data/scenes/sourceengine/base_sourceengine.json @@ -24,11 +24,12 @@ "bias": { "constant": 1.25, "slope": 1.75, - "shader": 0.0000025 + "shader": 0.000000000005 }, - "radius": [0.95, 0], - "resolution": 8196 + "radius": [50, 0], + "resolution": 1024 } }, + // "/^light_[^e]/": { "ignore": true }, // regexp matches "/^worldspawn_/": { "physics": { "type": "mesh", "static": true } }, diff --git a/bin/data/scenes/sourceengine/mds_mcdonalds.json b/bin/data/scenes/sourceengine/mds_mcdonalds.json index 77b02685..844787ad 100644 --- a/bin/data/scenes/sourceengine/mds_mcdonalds.json +++ b/bin/data/scenes/sourceengine/mds_mcdonalds.json @@ -3,6 +3,7 @@ "assets": [ // { "filename": "./models/mds_mcdonalds.glb" } { "filename": "./models/mds_mcdonalds/graph.json" } + // { "filename": "/burger.json", "delay": 1 } ], "metadata": { "graph": { diff --git a/bin/data/scenes/sourceengine/sh2_mcdonalds.json b/bin/data/scenes/sourceengine/sh2_mcdonalds.json index 8e0488dc..0577f307 100644 --- a/bin/data/scenes/sourceengine/sh2_mcdonalds.json +++ b/bin/data/scenes/sourceengine/sh2_mcdonalds.json @@ -2,13 +2,12 @@ "import": "./base_sourceengine.json", "assets": [ // { "filename": "./models/sh2_mcdonalds.glb" } - { "filename": "./models/sh2_mcdonalds/graph.json" }, - { "filename": "/burger.json", "delay": 1 } + { "filename": "./models/sh2_mcdonalds/graph.json" } ], "metadata": { "graph": { "lights": { - // "scale": 4.0 + "scale": 1 }, "assets": [ "./audio/soundscape/sh2_ambience.ogg" @@ -32,19 +31,6 @@ "func_door_rotating_5584": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } }, "func_door_rotating_9120": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [0,0,1] } } }, - "light_environment": { "transform": { "orientation": [0,0,0,1] }, "light": { - "color": [0.05, 0.05, 0.05], - "power": 10, - "global": true, - "bias": { - "constant": 1.25, - "slope": 1.75, - "shader": 0.000005 - }, - "radius": [0.95, 0], - "resolution": 1536 - } }, - // regex matches // "/^prop_physics_[^o]/": { "action": "load", "payload": { "import": "/prop.json" } }, // "/^prop_physics_override/": { "action": "load", "payload": {} }, diff --git a/bin/data/scenes/sourceengine/sourceengine.json b/bin/data/scenes/sourceengine/sourceengine.json index 2b4ed634..5000b680 100644 --- a/bin/data/scenes/sourceengine/sourceengine.json +++ b/bin/data/scenes/sourceengine/sourceengine.json @@ -1,7 +1,7 @@ { // "import": "./rp_downtown_v2.json" // "import": "./ss2_medsci1.json" - "import": "./sh2_mcdonalds.json" -// "import": "./mds_mcdonalds.json" +// "import": "./sh2_mcdonalds.json" + "import": "./mds_mcdonalds.json" // "import": "./gm_construct.json" } \ No newline at end of file diff --git a/bin/data/scenes/ss2/medsci.json b/bin/data/scenes/ss2/medsci.json index 1d93406d..4b9a5e9f 100644 --- a/bin/data/scenes/ss2/medsci.json +++ b/bin/data/scenes/ss2/medsci.json @@ -7,8 +7,8 @@ // { "filename": "./models/tiny_msci.glb" } // { "filename": "./models/tiny_msci/graph.json" } - { "filename": "./models/micro_sci.glb" } - // { "filename": "./models/micro_sci/graph.json" } + // { "filename": "./models/micro_sci.glb" } + { "filename": "./models/micro_sci/graph.json" } // { "filename": "./models/msci.glb" } // { "filename": "./models/msci/graph.json" } @@ -28,7 +28,7 @@ "tags": { "/^worldspawn/": { "physics": { "type": "mesh", "static": true }, - // "grid": { "size": [3,1,3], "epsilon": 0.0001, "cleanup": true, "print": true }, + "grid": { "size": [3,1,3], "epsilon": 0.0001, "cleanup": true, "print": true }, "optimize mesh": { "simplify": 0 }, "unwrap mesh": true }, diff --git a/bin/data/scenes/ss2/scene.json b/bin/data/scenes/ss2/scene.json index d3b411ba..0ff5dafe 100644 --- a/bin/data/scenes/ss2/scene.json +++ b/bin/data/scenes/ss2/scene.json @@ -7,8 +7,8 @@ ], "metadata": { "light": { - "ambient": [ 0.0, 0.0, 0.0 ], - // "ambient": [ 0.1, 0.1, 0.2 ], + // "ambient": [1.0,1.0,1.0 ], + "ambient": [ 0.1, 0.1, 0.2 ], "fog": { "color": [ 0.025, 0.025, 0.1 ], diff --git a/bin/data/scripts/main.lua b/bin/data/scripts/main.lua index e69de29b..b5ce3b8f 100644 --- a/bin/data/scripts/main.lua +++ b/bin/data/scripts/main.lua @@ -0,0 +1,2 @@ +local orientation = Quaternion() +print( orientation, orientation.x ) \ No newline at end of file diff --git a/bin/data/shaders/graph/baking/frag.h b/bin/data/shaders/graph/baking/frag.h index 4c12e5bf..0abc2c25 100644 --- a/bin/data/shaders/graph/baking/frag.h +++ b/bin/data/shaders/graph/baking/frag.h @@ -141,8 +141,8 @@ void main() { { surface.normal.eye = surface.normal.eye; surface.position.eye = surface.position.eye; - pbr(); - /* + // pbr(); + const vec3 F0 = mix(vec3(0.04), surface.material.albedo.rgb, surface.material.metallic); for ( uint i = 0; i < min(ubo.lights, lights.length()); ++i ) { const Light light = lights[i]; @@ -187,7 +187,6 @@ void main() { surface.light.rgb += (diffuse + specular) * Lr * cosLi; surface.light.a += light.power * La * Ls; } - */ } #define EXPOSURE 0 #define GAMMA 0 diff --git a/engine/inc/uf/ext/lua/lua.inl b/engine/inc/uf/ext/lua/lua.inl index 4e0fbc62..3d4a4b8c 100644 --- a/engine/inc/uf/ext/lua/lua.inl +++ b/engine/inc/uf/ext/lua/lua.inl @@ -18,7 +18,14 @@ namespace {\ });\ });\ } +/* +namespace sol {\ + template <>\ + struct is_automagical : std::false_type {};\ +}\ + +*/ #define UF_LUA_REGISTER_USERTYPE(type, ...) \ namespace {\ @@ -31,6 +38,7 @@ namespace {\ #define UF_LUA_REGISTER_USERTYPE_DEFINE(k, v) #k, v #define UF_LUA_REGISTER_USERTYPE_MEMBER(member) UF_NS_GET_LAST(member), &member +//#define UF_LUA_REGISTER_USERTYPE_MEMBER(member) UF_NS_GET_LAST(member), sol::as_function(&member) #define UF_LUA_REGISTER_USERTYPE_MEMBER_FUN(member) UF_NS_GET_LAST(member), UF_LUA_C_FUN(member) #define UF_LUA_C_FUN(x) sol::c_call diff --git a/engine/inc/uf/utils/io/fmt.h b/engine/inc/uf/utils/io/fmt.h index df1f59a8..fdbec91b 100644 --- a/engine/inc/uf/utils/io/fmt.h +++ b/engine/inc/uf/utils/io/fmt.h @@ -3,11 +3,10 @@ #if UF_USE_FMT #if UF_ENV_DREAMCAST #define FMT_HEADER_ONLY - #include - #else - // #include #endif + #include #include + #include #endif #include diff --git a/engine/src/engine/graph/decode.cpp b/engine/src/engine/graph/decode.cpp index 157fd439..9782a70a 100644 --- a/engine/src/engine/graph/decode.cpp +++ b/engine/src/engine/graph/decode.cpp @@ -236,7 +236,7 @@ namespace { // remove extraneous buffers uf::stl::vector attributesKept = ext::json::vector(graph.metadata["decode"]["attributes"]); - #if 1 + #if 0 if ( !mesh.isInterleaved() ) { uf::stl::vector remove; remove.reserve(mesh.vertex.attributes.size()); @@ -252,7 +252,7 @@ namespace { mesh.vertex.attributes.erase(mesh.vertex.attributes.begin() + i); } } else { - UF_MSG_DEBUG("Attribute removal requested yet mesh is not interleaved, ignoring..."); + UF_MSG_DEBUG("Attribute removal requested yet mesh is interleaved, ignoring..."); } #endif diff --git a/engine/src/engine/graph/graph.cpp b/engine/src/engine/graph/graph.cpp index f055b1a2..4f5918e8 100644 --- a/engine/src/engine/graph/graph.cpp +++ b/engine/src/engine/graph/graph.cpp @@ -102,7 +102,8 @@ void uf::graph::initializeGraphics( pod::Graph& graph, uf::Object& entity, uf::M if ( uf::matrix::reverseInfiniteProjection ) { graphic.descriptor.frontFace = graph.metadata["renderer"]["invert"].as(true) ? uf::renderer::enums::Face::CW : uf::renderer::enums::Face::CCW; } else { - graphic.descriptor.frontFace = graph.metadata["renderer"]["invert"].as(true) ? uf::renderer::enums::Face::CCW : uf::renderer::enums::Face::CW; + graphic.descriptor.frontFace = graph.metadata["renderer"]["invert"].as(true) ? uf::renderer::enums::Face::CW : uf::renderer::enums::Face::CCW; + // graphic.descriptor.frontFace = graph.metadata["renderer"]["invert"].as(true) ? uf::renderer::enums::Face::CCW : uf::renderer::enums::Face::CW; } } else UF_MSG_WARNING("Invalid Face enum string specified: {}", mode); @@ -386,6 +387,8 @@ void uf::graph::initializeGraphics( pod::Graph& graph, uf::Object& entity, uf::M { "samplerCubemaps", maxCubemaps }, }); + // shader.buffers.emplace_back( uf::graph::storage.buffers.camera.alias() ); + shader.aliasBuffer( "camera", uf::graph::storage.buffers.camera ); shader.buffers.emplace_back( uf::graph::storage.buffers.drawCommands.alias() ); shader.buffers.emplace_back( uf::graph::storage.buffers.instance.alias() ); shader.buffers.emplace_back( uf::graph::storage.buffers.instanceAddresses.alias() ); @@ -503,7 +506,7 @@ void uf::graph::process( pod::Graph& graph ) { // process lightmap UF_DEBUG_TIMER_MULTITRACE("Parsing lightmaps"); - { + if ( true ) { constexpr const char* UF_GRAPH_DEFAULT_LIGHTMAP = "./lightmap.%i.png"; uf::stl::unordered_map filenames; uf::stl::unordered_map lightmapIDs; diff --git a/engine/src/ext/ffx/fsr.cpp b/engine/src/ext/ffx/fsr.cpp index 16ab3f8d..23898632 100644 --- a/engine/src/ext/ffx/fsr.cpp +++ b/engine/src/ext/ffx/fsr.cpp @@ -1,7 +1,7 @@ -#include - #if UF_USE_FFX_FSR +#include + #include #include diff --git a/engine/src/ext/json/json.cpp b/engine/src/ext/json/json.cpp index a1f2918c..aa455f0f 100644 --- a/engine/src/ext/json/json.cpp +++ b/engine/src/ext/json/json.cpp @@ -1,5 +1,6 @@ #include #include +#include #include uf::stl::string ext::json::PREFERRED_COMPRESSION = ""; diff --git a/engine/src/ext/lua/lua.cpp b/engine/src/ext/lua/lua.cpp index 5c532a15..9cccc174 100644 --- a/engine/src/ext/lua/lua.cpp +++ b/engine/src/ext/lua/lua.cpp @@ -115,6 +115,7 @@ namespace binds { } namespace io { void print( sol::variadic_args va ) { + #if UF_USE_FMT size_t count = va.size(); for ( auto value : va ) { uf::stl::string str = ext::lua::state["tostring"]( value ); @@ -123,6 +124,16 @@ namespace binds { } fmt::print("\n"); std::cout.flush(); + #else + size_t count = va.size(); + for ( auto value : va ) { + uf::stl::string str = ext::lua::state["tostring"]( value ); + std::cout << str; + if ( --count != 0 ) std::cout << "\t"; + } + std::cout <<"\n"); + std::cout.flush(); + #endif }; } namespace math { diff --git a/engine/src/ext/lua/usertypes/physics.cpp b/engine/src/ext/lua/usertypes/physics.cpp index 7060d5cb..e754682b 100644 --- a/engine/src/ext/lua/usertypes/physics.cpp +++ b/engine/src/ext/lua/usertypes/physics.cpp @@ -27,10 +27,8 @@ UF_LUA_REGISTER_USERTYPE(pod::Physics, UF_LUA_REGISTER_USERTYPE_DEFINE( rotationalVelocity, UF_LUA_C_FUN(::binds::rotationalVelocity) ), UF_LUA_REGISTER_USERTYPE_DEFINE( setLinearVelocity, UF_LUA_C_FUN(::binds::setLinearVelocity) ), - UF_LUA_REGISTER_USERTYPE_DEFINE( setRotationalVelocity, UF_LUA_C_FUN(::binds::setRotationalVelocity) ) -) + UF_LUA_REGISTER_USERTYPE_DEFINE( setRotationalVelocity, UF_LUA_C_FUN(::binds::setRotationalVelocity) ), -UF_LUA_REGISTER_USERTYPE(pod::PhysicsState, UF_LUA_REGISTER_USERTYPE_DEFINE( setVelocity, UF_LUA_C_FUN(uf::physics::impl::setVelocity) ), UF_LUA_REGISTER_USERTYPE_DEFINE( setImpulse, UF_LUA_C_FUN(uf::physics::impl::setImpulse) ), UF_LUA_REGISTER_USERTYPE_DEFINE( applyImpulse, UF_LUA_C_FUN(uf::physics::impl::applyImpulse) ), diff --git a/engine/src/ext/lua/usertypes/quaternion.cpp b/engine/src/ext/lua/usertypes/quaternion.cpp index 83d690d5..77b45903 100644 --- a/engine/src/ext/lua/usertypes/quaternion.cpp +++ b/engine/src/ext/lua/usertypes/quaternion.cpp @@ -2,77 +2,81 @@ #if UF_USE_LUA #include +namespace { + typedef pod::Quaternion<> Quaternion; +} + namespace binds { - float index( const pod::Quaternion<>& self, size_t index ) { + float index( const ::Quaternion& self, size_t index ) { return self[index]; } - pod::Quaternion<> lookAt( const pod::Vector3f& at, const pod::Vector3f& up ) { + ::Quaternion lookAt( const pod::Vector3f& at, const pod::Vector3f& up ) { return uf::quaternion::lookAt( at, up ); } - pod::Quaternion<> normalize( const pod::Quaternion<>& self ) { + ::Quaternion normalize( const ::Quaternion& self ) { return uf::quaternion::normalize( self ); } - pod::Quaternion<> multiply( const pod::Quaternion<>& left, const pod::Quaternion<>& right ) { + ::Quaternion multiply( const ::Quaternion& left, const ::Quaternion& right ) { return uf::quaternion::multiply( left, right ); } - pod::Quaternion<> axisAngle( sol::object arg, float angle ){ + ::Quaternion axisAngle( sol::object arg, float angle ){ if ( arg.is() ) { return uf::quaternion::axisAngle( arg.as(), angle ); } else if ( arg.is() ) { sol::table table = arg.as(); return uf::quaternion::axisAngle( pod::Vector3f{ table[0], table[1], table[2] }, angle ); } - return pod::Quaternion<>{}; + return ::Quaternion{}; } - pod::Vector3f rotate( const pod::Quaternion<>& left, const pod::Vector3f& right ) { + pod::Vector3f rotate( const ::Quaternion& left, const pod::Vector3f& right ) { return uf::quaternion::rotate( left, right ); } - pod::Quaternion<> eulerAngles( const pod::Quaternion<>& quaternion ) { + ::Quaternion eulerAngles( const ::Quaternion& quaternion ) { return uf::quaternion::eulerAngles( quaternion ); } - pod::Quaternion<> conjugate( const pod::Quaternion<>& quaternion ) { + ::Quaternion conjugate( const ::Quaternion& quaternion ) { return uf::quaternion::conjugate( quaternion ); } - pod::Quaternion<> inverse( const pod::Quaternion<>& quaternion ) { + ::Quaternion inverse( const ::Quaternion& quaternion ) { return uf::quaternion::inverse( quaternion ); } - float pitch( const pod::Quaternion<>& quaternion ) { + float pitch( const ::Quaternion& quaternion ) { return uf::quaternion::pitch( quaternion ); } - float yaw( const pod::Quaternion<>& quaternion ) { + float yaw( const ::Quaternion& quaternion ) { return uf::quaternion::yaw( quaternion ); } - float roll( const pod::Quaternion<>& quaternion ) { + float roll( const ::Quaternion& quaternion ) { return uf::quaternion::roll( quaternion ); } - pod::Quaternion<> slerp( const pod::Quaternion<>& left, const pod::Quaternion<>& right, float a ) { + ::Quaternion slerp( const ::Quaternion& left, const ::Quaternion& right, float a ) { return uf::quaternion::slerp( left, right, a ); } - pod::Matrix4f matrix( const pod::Quaternion<>& q ) { + pod::Matrix4f matrix( const ::Quaternion& q ) { return uf::quaternion::matrix( q ); } - uf::stl::string __tostring( const pod::Quaternion<>& self ) { + uf::stl::string __tostring( const ::Quaternion& self ) { return uf::string::toString( self ); } } -UF_LUA_REGISTER_USERTYPE(pod::Quaternion<>, +UF_LUA_REGISTER_USERTYPE(::Quaternion, sol::call_constructor, sol::initializers( - []( pod::Quaternion<>& self ) { + []( ::Quaternion& self ) { return self = {0,0,0,1}; }, - []( pod::Quaternion<>& self, const pod::Quaternion<>& copy ) { + []( ::Quaternion& self, const ::Quaternion& copy ) { return self = copy; }, - []( pod::Quaternion<>& self, float x, float y, float z, float w ) { + []( ::Quaternion& self, float x, float y, float z, float w ) { return self = uf::vector::create(x, y, z, w); } ), - UF_LUA_REGISTER_USERTYPE_MEMBER(pod::Quaternion<>::x), - UF_LUA_REGISTER_USERTYPE_MEMBER(pod::Quaternion<>::y), - UF_LUA_REGISTER_USERTYPE_MEMBER(pod::Quaternion<>::z), - UF_LUA_REGISTER_USERTYPE_MEMBER(pod::Quaternion<>::w), + UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::x), + UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::y), + UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::z), + UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::w), UF_LUA_REGISTER_USERTYPE_DEFINE( v, UF_LUA_C_FUN(::binds::index) ), UF_LUA_REGISTER_USERTYPE_DEFINE( lookAt, UF_LUA_C_FUN(::binds::lookAt) ), diff --git a/engine/src/ext/lua/usertypes/vector.cpp b/engine/src/ext/lua/usertypes/vector.cpp index 89645f1d..bc0024b2 100644 --- a/engine/src/ext/lua/usertypes/vector.cpp +++ b/engine/src/ext/lua/usertypes/vector.cpp @@ -124,6 +124,7 @@ UF_LUA_REGISTER_USERTYPE(pod::Vector3f, UF_LUA_REGISTER_USERTYPE_DEFINE( dot, UF_LUA_C_FUN(::binds::v3f::dot) ), UF_LUA_REGISTER_USERTYPE_DEFINE( __tostring, UF_LUA_C_FUN(::binds::v3f::toString) ) ) +/* UF_LUA_REGISTER_USERTYPE(pod::Vector4f, sol::call_constructor, sol::initializers( []( pod::Vector4f& self ) { @@ -156,4 +157,5 @@ UF_LUA_REGISTER_USERTYPE(pod::Vector4f, UF_LUA_REGISTER_USERTYPE_DEFINE( dot, UF_LUA_C_FUN(::binds::v4f::dot) ), UF_LUA_REGISTER_USERTYPE_DEFINE( __tostring, UF_LUA_C_FUN(::binds::v4f::toString) ) ) +*/ #endif \ No newline at end of file diff --git a/engine/src/ext/opengl/commands.cpp b/engine/src/ext/opengl/commands.cpp index 9f6bb99e..d99a44ad 100644 --- a/engine/src/ext/opengl/commands.cpp +++ b/engine/src/ext/opengl/commands.cpp @@ -300,6 +300,10 @@ void ext::opengl::CommandBuffer::drawIndexed( const ext::opengl::CommandBuffer:: GL_ERROR_CHECK(glBindTexture(drawInfo.textures.primary.viewType, drawInfo.textures.primary.image)); GL_ERROR_CHECK(glTexCoordPointer(2, GL_FLOAT, drawInfo.attributes.uv.stride, (static_cast(drawInfo.attributes.uv.pointer) + drawInfo.attributes.uv.stride * drawInfo.descriptor.inputs.vertex.first))); + if ( drawInfo.textures.secondary.image && drawInfo.attributes.st.pointer ) { + GL_ERROR_CHECK(glTexCoordPointer(2, GL_FLOAT, drawInfo.attributes.st.stride, (static_cast(drawInfo.attributes.st.pointer) + drawInfo.attributes.st.stride * drawInfo.descriptor.inputs.vertex.first))); + } + /* if ( !(drawInfo.textures.secondary.image && drawInfo.attributes.st.pointer) ) { GL_ERROR_CHECK(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)); } else { @@ -314,6 +318,7 @@ void ext::opengl::CommandBuffer::drawIndexed( const ext::opengl::CommandBuffer:: GL_ERROR_CHECK(glTexCoordPointer(2, GL_FLOAT, drawInfo.attributes.st.stride, (static_cast(drawInfo.attributes.st.pointer) + drawInfo.attributes.st.stride * drawInfo.descriptor.inputs.vertex.first))); } + */ } if ( drawInfo.attributes.normal.pointer ) GL_ERROR_CHECK(glNormalPointer(GL_FLOAT, drawInfo.attributes.normal.stride, (static_cast(drawInfo.attributes.normal.pointer) + drawInfo.attributes.normal.stride * drawInfo.descriptor.inputs.vertex.first))); diff --git a/engine/src/ext/reactphysics/reactphysics.cpp b/engine/src/ext/reactphysics/reactphysics.cpp index 5f473198..de120cd8 100644 --- a/engine/src/ext/reactphysics/reactphysics.cpp +++ b/engine/src/ext/reactphysics/reactphysics.cpp @@ -464,7 +464,11 @@ void ext::reactphysics::syncTo() { float mass = body->getMass(); switch ( ext::reactphysics::gravity::mode ) { case ext::reactphysics::gravity::Mode::PER_OBJECT: if ( body->isGravityEnabled() ) { + #if UF_ENV_DREAMCAST + body->applyForceToCenterOfMass( ::convert(state.stats.gravity * mass) ); + #else body->applyLocalForceAtCenterOfMass( ::convert(state.stats.gravity * mass) ); + #endif } break; case ext::reactphysics::gravity::Mode::UNIVERSAL: if ( mass > 0 ) { auto transform = ::convert( body->getTransform() ); @@ -492,8 +496,13 @@ void ext::reactphysics::syncTo() { const float r2 = uf::vector::distanceSquared( b1.position, b2.position ); const float F = G * m1 * m2 / r2; + #if UF_ENV_DREAMCAST + if ( b1.body ) b1.body->applyForceToCenterOfMass(direction * F); + if ( b2.body ) b2.body->applyForceToCenterOfMass(direction * -F); + #else if ( b1.body ) b1.body->applyLocalForceAtCenterOfMass(direction * F); if ( b2.body ) b2.body->applyLocalForceAtCenterOfMass(direction * -F); + #endif } } } @@ -555,9 +564,10 @@ void ext::reactphysics::syncFrom( float interp ) { // apply impulse void ext::reactphysics::setImpulse( pod::PhysicsState& state, const pod::Vector3f& v ) { if ( !state.body ) return; - +#if !UF_ENV_DREAMCAST state.body->resetForce(); state.body->resetTorque(); +#endif state.body->setLinearVelocity( ::convert(pod::Vector3f{}) ); state.body->setAngularVelocity( ::convert(pod::Vector3f{}) ); // ext::reactphysics::applyImpulse( state, v ); @@ -565,7 +575,11 @@ void ext::reactphysics::setImpulse( pod::PhysicsState& state, const pod::Vector3 void ext::reactphysics::applyImpulse( pod::PhysicsState& state, const pod::Vector3f& v ) { if ( !state.body ) return; +#if UF_ENV_DREAMCAST + state.body->applyForceToCenterOfMass( ::convert(v) ); +#else state.body->applyLocalForceAtCenterOfMass( ::convert(v) ); +#endif } // directly move a transform void ext::reactphysics::applyMovement( pod::PhysicsState& state, const pod::Vector3f& v ) { diff --git a/engine/src/ext/vulkan/rendermodes/deferred.cpp b/engine/src/ext/vulkan/rendermodes/deferred.cpp index 50b080bf..c4491ebb 100644 --- a/engine/src/ext/vulkan/rendermodes/deferred.cpp +++ b/engine/src/ext/vulkan/rendermodes/deferred.cpp @@ -319,7 +319,7 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) { shader.aliasAttachment("scratch", this, VK_IMAGE_LAYOUT_GENERAL); } - if ( settings::pipelines::culling ) { + if ( false && settings::pipelines::culling ) { uf::stl::string computeShaderFilename = uf::io::resolveURI(uf::io::root+"/shaders/display/depth-pyramid/comp.spv"); blitter.material.attachShader(computeShaderFilename, uf::renderer::enums::Shader::COMPUTE, "depth-pyramid"); @@ -414,7 +414,7 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) { } } - if ( settings::pipelines::culling ) { + if ( false && settings::pipelines::culling ) { descriptor.aux = uf::vector::mips( pod::Vector2ui{ width, height } ); descriptor.pipeline = "depth-pyramid"; descriptor.subpass = 0; @@ -440,7 +440,7 @@ void ext::vulkan::DeferredRenderMode::tick() { rebuild = true; renderTarget.initialize( *renderTarget.device ); - if ( settings::pipelines::culling ) { + if ( false && settings::pipelines::culling ) { auto& shader = blitter.material.getShader("compute", "depth-pyramid"); auto attachment = this->getAttachment("depth"); auto mips = uf::vector::mips( pod::Vector2ui{ width, height } ); @@ -538,7 +538,7 @@ void ext::vulkan::DeferredRenderMode::tick() { } } - if ( settings::pipelines::culling ) { + if ( false && settings::pipelines::culling ) { descriptor.aux = uf::vector::mips( pod::Vector2ui{ width, height } ); descriptor.pipeline = "depth-pyramid"; descriptor.subpass = 0; @@ -794,8 +794,8 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto ::transitionAttachmentsFrom( this, shader, commandBuffer ); } - // construct depth-pyramid - if ( settings::pipelines::culling && blitter.material.hasShader("compute", "depth-pyramid") ) { + // construct depth-pyramid + if ( false && settings::pipelines::culling && blitter.material.hasShader("compute", "depth-pyramid") ) { auto& shader = blitter.material.getShader("compute", "depth-pyramid"); // auto mips = attachment.descriptor.mips; // uf::vector::mips( pod::Vector2ui{ renderTarget.width, renderTarget.height } ); auto mips = uf::vector::mips( pod::Vector2ui{ width, height } ); diff --git a/ext/behaviors/scene/behavior.cpp b/ext/behaviors/scene/behavior.cpp index f144451a..040637cb 100644 --- a/ext/behaviors/scene/behavior.cpp +++ b/ext/behaviors/scene/behavior.cpp @@ -33,8 +33,6 @@ #include "../../ext.h" #include "../../gui/gui.h" -#include - UF_BEHAVIOR_REGISTER_CPP(ext::ExtSceneBehavior) UF_BEHAVIOR_TRAITS_CPP(ext::ExtSceneBehavior, ticks = true, renders = false, multithread = false) // hangs on initialization #define this ((uf::Scene*) &self) diff --git a/makefiles/win64.clang.make b/makefiles/win64.clang.make index da3b73db..cef7776c 100644 --- a/makefiles/win64.clang.make +++ b/makefiles/win64.clang.make @@ -2,7 +2,7 @@ ARCH = win64 CDIR = CC = clang CXX = clang++ -OPTIMIZATIONS = -O3 -fstrict-aliasing -DUF_NO_EXCEPTIONS -march=native -flto +OPTIMIZATIONS = -O3 -fstrict-aliasing -DUF_NO_EXCEPTIONS -flto # -march=native WARNINGS = -g -Wall -Wno-pointer-arith -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-reorder-ctor -Wno-ignored-attributes -Wno-c++11-narrowing -Wno-unknown-pragmas -Wno-nullability-completeness -Wno-defaulted-function-deleted -Wno-mismatched-tags SANITIZE = -fuse-ld=lld # -fsanitize=address -fno-omit-frame-pointer FLAGS += -std=c++17 $(OPTIMIZATIONS) $(WARNINGS) $(SANITIZE) -fcolor-diagnostics -fansi-escape-codes \ No newline at end of file diff --git a/makefiles/win64.gcc.make b/makefiles/win64.gcc.make index b081d1d4..a6ea7e15 100644 --- a/makefiles/win64.gcc.make +++ b/makefiles/win64.gcc.make @@ -2,6 +2,6 @@ ARCH = win64 CDIR = CC = gcc CXX = g++ -OPTIMIZATIONS = -O3 -g -fstrict-aliasing -DUF_NO_EXCEPTIONS -march=native # -flto +OPTIMIZATIONS = -O3 -g -fstrict-aliasing -DUF_NO_EXCEPTIONS # -march=native # -flto WARNINGS = -Wall -Wno-unknown-pragmas -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-reorder -Wno-sign-compare -Wno-unused-but-set-variable -Wno-ignored-attributes -Wno-narrowing -Wno-misleading-indentation FLAGS += -std=c++20 $(OPTIMIZATIONS) $(WARNINGS) -fdiagnostics-color=always \ No newline at end of file