From 3c11536d7f729ec73ccdc5b807d471888ddd7622 Mon Sep 17 00:00:00 2001 From: mrq Date: Sat, 31 Jul 2021 18:05:00 -0500 Subject: [PATCH] Commit for 2021.07.31 18-05-16.7z --- bin/data/config.json | 4 +- bin/data/entities/model.json | 51 ++++ bin/data/entities/player.json | 32 +- bin/data/scenes/construct/gm_construct.json | 56 +--- bin/data/scenes/construct/loading.json | 2 +- bin/data/scenes/construct/scene.json | 5 +- bin/data/scenes/mcdonalds/door.json | 9 + bin/data/scenes/mcdonalds/mcdonalds.json | 77 +---- bin/data/scenes/sh2_mcdonalds/door.json | 8 + .../scenes/sh2_mcdonalds/sh2_mcdonalds.json | 79 +---- bin/data/scenes/ss2/camera.json | 13 + bin/data/scenes/ss2/lift.json | 12 + bin/data/scenes/ss2/loading.json | 2 +- bin/data/scenes/ss2/medsci.json | 78 +---- bin/data/scenes/ss2/scripts/lift.lua | 10 +- engine/inc/uf/ext/bullet/bullet.h | 21 +- engine/inc/uf/ext/bullet/bullet.inl | 84 ------ engine/src/engine/graph/graph.cpp | 273 ++++++++---------- engine/src/engine/object/behavior.cpp | 43 +-- engine/src/ext/bullet/bullet.cpp | 113 ++++---- engine/src/ext/lua/usertypes/bullet.cpp | 15 + engine/src/ext/lua/usertypes/object.cpp | 12 + engine/src/ext/lua/usertypes/physics.cpp | 20 ++ ext/behaviors/baking/behavior.cpp | 87 ++---- ext/behaviors/player/behavior.cpp | 152 +++++----- ext/behaviors/player/behavior.h | 23 +- ext/behaviors/scene/behavior.cpp | 8 +- makefiles/win64.gcc.make | 2 +- 28 files changed, 530 insertions(+), 761 deletions(-) create mode 100644 bin/data/entities/model.json create mode 100644 bin/data/scenes/mcdonalds/door.json create mode 100644 bin/data/scenes/sh2_mcdonalds/door.json create mode 100644 bin/data/scenes/ss2/camera.json create mode 100644 bin/data/scenes/ss2/lift.json delete mode 100644 engine/inc/uf/ext/bullet/bullet.inl create mode 100644 engine/src/ext/lua/usertypes/bullet.cpp create mode 100644 engine/src/ext/lua/usertypes/physics.cpp diff --git a/bin/data/config.json b/bin/data/config.json index 503fcf3c..19b1a878 100644 --- a/bin/data/config.json +++ b/bin/data/config.json @@ -1,7 +1,7 @@ { "engine": { "scenes": { - "start": "SS2", + "start": "Construct", "meshes": { "interleave": false }, @@ -18,7 +18,7 @@ "max": 6, "samples": 2, "experimental mode": 1 - }, + }, "textures": { "max": { "2D": 1024, diff --git a/bin/data/entities/model.json b/bin/data/entities/model.json new file mode 100644 index 00000000..abd299f6 --- /dev/null +++ b/bin/data/entities/model.json @@ -0,0 +1,51 @@ +{ + "name": "Graph", + "type": "Object", + "ignore": false, + "behaviors": [ "LoadingBehavior" ], + "transform": { + "position": [ 0, 0, 0 ], + "rotation": { "axis": [ 0, 1, 0 ], "angle": 0 }, + "scale": [ 1, 1, 1 ] + }, + "metadata": { + "model": { + "debug": { + "no cleanup": false, + "print tree": false, + "print stats": false + }, + "export": { + "should": true, + "pretty": false, + "compress": true, + "quantize": false, + "precision": 4, + "combined": false, + "encode buffers": true, + "unwrap": true + }, + "baking": { + "enabled": false, + "resolution": 8192, + "shadows": 1024, + "trigger": { "mode": "rendered" }, + "output": "./lightmap.png" + }, + // "lightmap": "./lightmap.min.png", + "lightmap": "./lightmap.png", + "filter": "NEAREST", + "flags": { + "ATLAS": false, + "INVERT": false, + "TRANSFORM": false, + "SKINNED": false, + + "RENDER": true, + "SEPARATE": false, + "NORMALS": false + }, + "lights": { "shadows": true } + } + } +} \ No newline at end of file diff --git a/bin/data/entities/player.json b/bin/data/entities/player.json index 006fbeb6..b5eb218f 100644 --- a/bin/data/entities/player.json +++ b/bin/data/entities/player.json @@ -19,22 +19,32 @@ ], "system": { "physics": { - "collision": 1.0, - "impulse": true, + "movement": { + "walk": 1, + "move": 8, + "run": 16, + "rotate": 1.5, + "air": 0.1, + + "crouch": 1, + "jump": [ 0, 4, 0 ] + }, + "gravity": [ 0, -9.81, 0 ], "inertia": [ 10, 10, 10 ], - "walk": 1, - "move": 8, - "run": 12, - "rotate": 2, - "crouch": 1, - "jump": [ 0, 6, 0 ], - "type": "Capsule", + "type": "capsule", "radius": 1, "height": 2, + "mass": 100, + "friction": 0.8, + "restitution": 0.0, + "shared": false + }, + "hot reload": { + "enabled": true } }, "metadata": { @@ -54,10 +64,6 @@ "enabled": false } }, - "region": { - "track": true, - "persist": true - }, "audio": { "footstep": { "volume": 0.5, diff --git a/bin/data/scenes/construct/gm_construct.json b/bin/data/scenes/construct/gm_construct.json index 94484a0a..06217a2f 100644 --- a/bin/data/scenes/construct/gm_construct.json +++ b/bin/data/scenes/construct/gm_construct.json @@ -1,66 +1,14 @@ { - "type": "Object", - "name": "gm_construct", - "ignore": false, + "import": "/model.json", "assets": [ { "filename": "./models/gm_construct.glb", "delay": 0, "single threaded": false } // { "filename": "./models/gm_construct/graph.json", "delay": 0, "single threaded": false, "category": "models" } // { "filename": "./models/gm_construct/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" } ], - "behaviors": [ - "LoadingBehavior" - ], - "transform": { - "position": [ 0, 0, 0 ], - "rotation": { - "axis": [ 0, 1, 0 ], - "angle": 0 - }, - "scale": [ 1, 1, 1 ] - }, "metadata": { "model": { - "debug": { - "no cleanup": false, - "print tree": false, - "print stats": false - }, - "export": { - "should": true, - "pretty": false, - "compress": true, - "quantize": false, - "precision": 4, - "combined": false, - "encode buffers": true, - "unwrap": true - }, - "baking": { - "enabled": false, - "resolution": 8192, - "shadows": 1024, - "trigger": { "mode": "rendered" }, - "output": "./lightmap.png" - }, - "flags": { - "ATLAS": false, - "INVERT": false, - "TRANSFORM": false, - "SKINNED": false, - - "RENDER": true, - "SEPARATE": false, - "NORMALS": false - }, - // "filter": "NEAREST", - "lights": { - "shadows": true - }, - "lights": { - "shadows": false - }, "tags": { - "worldspawn_2": { "collision": { "type": "mesh", "dynamic": false } }, + "worldspawn_2": { "physics": { "type": "mesh", "dynamic": false } }, "info_player_spawn": { "action": "attach", "filename": "./player.json", diff --git a/bin/data/scenes/construct/loading.json b/bin/data/scenes/construct/loading.json index 425afa40..1a3dd301 100644 --- a/bin/data/scenes/construct/loading.json +++ b/bin/data/scenes/construct/loading.json @@ -2,7 +2,7 @@ "name": "Gui: Loading", "type": "Object", "behaviors": [ - // "GuiBehavior" + "GuiBehavior" ], "assets": [ { "filename": "./gm_construct.json", "delay": 0 } diff --git a/bin/data/scenes/construct/scene.json b/bin/data/scenes/construct/scene.json index 882923ce..b321ad07 100644 --- a/bin/data/scenes/construct/scene.json +++ b/bin/data/scenes/construct/scene.json @@ -9,7 +9,7 @@ }, "renderer": { "clear values": [ - [ 1, 1, 1, 0 ] + [ 0, 0, 0, 0 ] ], "shader": { "mode": 1, @@ -19,9 +19,6 @@ } }, "metadata": { - "debug": { - "target": 0 - }, "menus": { "pause": "/gui/pause/menu.json" }, diff --git a/bin/data/scenes/mcdonalds/door.json b/bin/data/scenes/mcdonalds/door.json new file mode 100644 index 00000000..41caf066 --- /dev/null +++ b/bin/data/scenes/mcdonalds/door.json @@ -0,0 +1,9 @@ +{ + "assets": ["./scripts/door.lua"], + "system": { + "physics": { + "type": "bounding box", + "recenter": true + } + } +} \ No newline at end of file diff --git a/bin/data/scenes/mcdonalds/mcdonalds.json b/bin/data/scenes/mcdonalds/mcdonalds.json index f17c8b28..10aad45f 100644 --- a/bin/data/scenes/mcdonalds/mcdonalds.json +++ b/bin/data/scenes/mcdonalds/mcdonalds.json @@ -1,7 +1,5 @@ { - "type": "Object", - "name": "Map", - "ignore": false, + "import": "/model.json", "assets": [ // { "filename": "./static.json", "delay": 8 }, @@ -9,72 +7,23 @@ // { "filename": "./models/mcdonalds/graph.json", "delay": 0, "single threaded": false, "category": "models" } { "filename": "./models/mcdonalds/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" } ], - "behaviors": [ - "LoadingBehavior" - ], - "transform": { - "position": [ 0, 0, 0 ], - "rotation": { - "axis": [ 0, 1, 0 ], - "angle": 0 - }, - "scale": [ 1, 1, 1 ] - }, "metadata": { "model": { - "debug": { - "no cleanup": false, - "print tree": false, - "print stats": false - }, - "export": { - "should": true, - "pretty": false, - "compress": true, - "quantize": false, - "precision": 4, - "combined": false, - "encode buffers": true, - "unwrap": true - }, - "baking": { - "enabled": false, - "resolution": 8192, - "shadows": 1024, - "trigger": { "mode": "rendered" }, - "output": "./lightmap.png" - }, - "flags": { - "ATLAS": false, - "INVERT": false, - "TRANSFORM": false, - "SKINNED": false, - - "RENDER": true, - "SEPARATE": false, - "NORMALS": false - }, - "lightmap": "./lightmap.png", - // "cull mode": "none", - "filter": "NEAREST", - "lights": { - "shadows": true - }, "tags": { - "worldspawn": { "collision": { "type": "mesh", "static": true } }, + "worldspawn": { "physics": { "type": "mesh", "static": true } }, "info_player_spawn": { "action": "attach", "filename": "./player.json", "preserve orientation": true }, - "func_door_rotating_5409": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5487": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle": 1.570795 } } }, - "func_door_rotating_5495": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle": 1.570795 } } }, - "func_door_rotating_5568": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5576": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle": 1.570795 } } }, - "func_door_rotating_5584": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5656": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle": 1.570795 } } }, - "func_door_rotating_5664": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5689": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5698": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5712": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } } + "func_door_rotating_5409": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5487": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795 } } }, + "func_door_rotating_5495": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795 } } }, + "func_door_rotating_5568": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5576": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795 } } }, + "func_door_rotating_5584": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5656": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795 } } }, + "func_door_rotating_5664": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5689": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5698": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5712": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } } } } } diff --git a/bin/data/scenes/sh2_mcdonalds/door.json b/bin/data/scenes/sh2_mcdonalds/door.json new file mode 100644 index 00000000..572a45a2 --- /dev/null +++ b/bin/data/scenes/sh2_mcdonalds/door.json @@ -0,0 +1,8 @@ +{ + "assets": ["./scripts/door.lua"], + "system": { + "physics": { + "type": "bounding box" + } + } +} \ No newline at end of file diff --git a/bin/data/scenes/sh2_mcdonalds/sh2_mcdonalds.json b/bin/data/scenes/sh2_mcdonalds/sh2_mcdonalds.json index 931480c1..56edbf5d 100644 --- a/bin/data/scenes/sh2_mcdonalds/sh2_mcdonalds.json +++ b/bin/data/scenes/sh2_mcdonalds/sh2_mcdonalds.json @@ -1,7 +1,5 @@ { - "type": "Object", - "name": "Map", - "ignore": false, + "import": "/model.json", "assets": [ // { "filename": "./static.json", "delay": 8 }, @@ -9,74 +7,23 @@ // { "filename": "./models/sh_mcd/graph.json", "delay": 0, "single threaded": false, "category": "models" } // { "filename": "./models/sh_mcd/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" } ], - "behaviors": [ - "LoadingBehavior" - ], - "transform": { - "position": [ 0, 0, 0 ], - "rotation": { - "axis": [ 0, 1, 0 ], - "angle": 0 - }, - "scale": [ 1, 1, 1 ] - }, "metadata": { "model": { - "debug": { - "no cleanup": false, - "print tree": false, - "print stats": false - }, - "export": { - "should": true, - "pretty": false, - "compress": true, - "quantize": false, - "precision": 4, - "combined": false, - "encode buffers": true, - "unwrap": true - }, - "baking": { - "enabled": false, - "resolution": 8192, - "shadows": 1024, - "trigger": { "mode": "rendered" }, - "output": "./lightmap.png" - }, - "flags": { - "ATLAS": false, - "INVERT": false, - "TRANSFORM": false, - "SKINNED": false, - - "RENDER": true, - "SEPARATE": false, - "NORMALS": false - }, - "cull mode": "none", - - // "lightmap": "./lightmap.png", - // "ambient": [ 0.25, 0.25, 0.25 ], - "lights": { - // "renderMode": { "target": "worldspawn_1" }, - "shadows": true - }, "tags": { - "worldspawn": { "collision": { "type": "mesh", "static": true } }, + "worldspawn": { "physics": { "type": "mesh", "static": true } }, "info_player_spawn": { "action": "attach", "filename": "./player.json", "preserve orientation": true }, - "func_door_rotating_5409": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5487": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle": 1.570795 } } }, - "func_door_rotating_5495": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle": 1.570795 } } }, - "func_door_rotating_5568": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5576": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle": 1.570795 } } }, - "func_door_rotating_5584": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5656": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle": 1.570795 } } }, - "func_door_rotating_5664": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5689": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5698": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } }, - "func_door_rotating_5712": { "collision": { "type": "bounding box", "recenter": true }, "action": "load", "payload": { "assets": ["./scripts/door.lua"], "metadata": { "angle":-1.570795 } } } + "func_door_rotating_5409": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5487": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795 } } }, + "func_door_rotating_5495": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795 } } }, + "func_door_rotating_5568": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5576": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795 } } }, + "func_door_rotating_5584": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5656": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle": 1.570795 } } }, + "func_door_rotating_5664": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5689": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5698": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } }, + "func_door_rotating_5712": { "action": "load", "payload": { "import": "./door.json", "metadata": { "angle":-1.570795 } } } } } } diff --git a/bin/data/scenes/ss2/camera.json b/bin/data/scenes/ss2/camera.json new file mode 100644 index 00000000..20a35341 --- /dev/null +++ b/bin/data/scenes/ss2/camera.json @@ -0,0 +1,13 @@ +{ + "assets": [ + "./scripts/camera.lua", + "./audio/soundscape/camera.ogg" + ], + "metadata": { + "audio": { + "rolloffFactor": 4, + "volume": 1.0 + }, + "sensitivity": 10 + } +} \ No newline at end of file diff --git a/bin/data/scenes/ss2/lift.json b/bin/data/scenes/ss2/lift.json new file mode 100644 index 00000000..cd72388e --- /dev/null +++ b/bin/data/scenes/ss2/lift.json @@ -0,0 +1,12 @@ +{ + "assets": [ "./scripts/lift.lua" ], + "system": { + "physics": { + "type": "bounding box", + + "mass": 100, + "restitution": 0, + "friction": 1 + } + } +} \ No newline at end of file diff --git a/bin/data/scenes/ss2/loading.json b/bin/data/scenes/ss2/loading.json index 786164dd..84c3288a 100644 --- a/bin/data/scenes/ss2/loading.json +++ b/bin/data/scenes/ss2/loading.json @@ -2,7 +2,7 @@ "name": "Gui: Loading", "type": "Object", "behaviors": [ - // "GuiBehavior" + "GuiBehavior" ], "assets": [ { "filename": "./medsci.json", "delay": 0 } diff --git a/bin/data/scenes/ss2/medsci.json b/bin/data/scenes/ss2/medsci.json index 5653fb97..3ecc99d9 100644 --- a/bin/data/scenes/ss2/medsci.json +++ b/bin/data/scenes/ss2/medsci.json @@ -1,81 +1,23 @@ { - "type": "Object", - "name": "MedSci", - "ignore": false, + "import": "/model.json", "assets": [ // { "filename": "./models/micro_sci.glb", "delay": 0, "single threaded": false, "category": "models" } // { "filename": "./models/micro_sci/graph.json", "delay": 0, "single threaded": false, "category": "models" } - { "filename": "./models/micro_sci/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" } + // { "filename": "./models/micro_sci/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" } // { "filename": "./models/msci.glb", "delay": 0, "single threaded": false, "category": "models" } // { "filename": "./models/msci/graph.json", "delay": 0, "single threaded": false, "category": "models" } - // { "filename": "./models/msci/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" } + { "filename": "./models/msci/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" } // { "filename": "./models/medsci.glb", "delay": 0, "single threaded": false } // { "filename": "./models/medsci/graph.json", "delay": 0, "single threaded": false, "category": "models" } // { "filename": "./models/medsci/graph.json.gz", "delay": 0, "single threaded": false, "category": "models" } ], - "behaviors": [ - "LoadingBehavior" - ], - "transform": { - "position": [ 0, 0, 0 ], - "rotation": { - "axis": [ 0, 1, 0 ], - "angle": 0 - }, - "scale": [ 1, 1, 1 ] - }, "metadata": { "model": { - "debug": { - "no cleanup": false, - "print tree": false, - "print stats": false - }, - "export": { - "should": true, - "pretty": false, - "compress": true, - "quantize": false, - "precision": 4, - "combined": false, - "encode buffers": true, - "unwrap": true - }, - "baking": { - "enabled": false, - "resolution": 8192, - "shadows": 1024, - "trigger": { "mode": "rendered" }, - "output": "./lightmap.png" - }, - "ambient": [ 0, 0, 0 ], - /* - "grid": { - "center": [19.2895, 2.42479, 3.91724], - "size": [5, 1, 5] - }, - */ - // "lightmap": "./lightmap.min.png", - // "lightmap": "./lightmap.png", - "filter": "NEAREST", - "flags": { - "ATLAS": false, - "INVERT": false, - "TRANSFORM": false, - "SKINNED": false, - - "RENDER": true, - "SEPARATE": false, - "NORMALS": false - }, - "lights": { - "shadows": true - }, "tags": { - "worldspawn": { "collision": { "type": "mesh", "static": true } }, - // "worldspawn": { "collision": { "type": "bounding boxes", "static": true } }, + "worldspawn": { "physics": { "type": "mesh", "static": true } }, + // "worldspawn": { "physics": { "type": "bounding boxes", "static": true } }, "info_player_spawn": { "action": "attach", "filename": "./player.json", @@ -87,11 +29,11 @@ "prop_camera_103001_light": { "light": { "shadows": false, "static": false, "dynamic": true, "power": 30 } }, "prop_camera_103118_light": { "light": { "shadows": false, "static": false, "dynamic": true, "power": 30 } }, - "prop_camera_103001": { "action": "load", "payload": { "import": "./ambience.json", "assets": [ "./scripts/camera.lua", "./audio/soundscape/camera.ogg" ], "metadata": { "audio": { "rolloffFactor": 4, "volume": 1.0 }, "sensitivity": 10 }, "collision": { "type": "bounding box" } } }, - "prop_camera_103118": { "action": "load", "payload": { "import": "./ambience.json", "assets": [ "./scripts/camera.lua", "./audio/soundscape/camera.ogg" ], "metadata": { "audio": { "rolloffFactor": 4, "volume": 1.0 }, "sensitivity": 10 }, "collision": { "type": "bounding box" } } }, - "func_movelinear_57637": { "action": "load", "payload": { "assets": [ "./scripts/lift.lua" ], "metadata": { "delta": [ 0,8.6,0 ] } }, "collision": { "type": "bounding box" } }, - "func_movelinear_82820": { "action": "load", "payload": { "assets": [ "./scripts/lift.lua" ], "metadata": { "delta": [ 0,9.2,0 ] } }, "collision": { "type": "bounding box" } }, - "func_movelinear_103114": { "action": "load", "payload": { "assets": [ "./scripts/lift.lua" ], "metadata": { "delta": [ 0,-3.0,0 ] } }, "collision": { "type": "bounding box" } } + "prop_camera_103001": { "action": "load", "payload": { "import": "./camera.json" } }, + "prop_camera_103118": { "action": "load", "payload": { "import": "./camera.json" } }, + "func_movelinear_57637": { "action": "load", "payload": { "import": "./lift.json", "metadata": { "delta": [ 0,8.6,0 ] } } }, + "func_movelinear_82820": { "action": "load", "payload": { "import": "./lift.json", "metadata": { "delta": [ 0,9.2,0 ] } } }, + "func_movelinear_103114": { "action": "load", "payload": { "import": "./lift.json", "metadata": { "delta": [ 0,-3.0,0 ] } } } } } } diff --git a/bin/data/scenes/ss2/scripts/lift.lua b/bin/data/scenes/ss2/scripts/lift.lua index 4d67979e..b8210432 100644 --- a/bin/data/scenes/ss2/scripts/lift.lua +++ b/bin/data/scenes/ss2/scripts/lift.lua @@ -9,6 +9,9 @@ end local target = Vector3f(0,0,0) local transform = ent:getComponent("Transform") local metadata = ent:getComponent("Metadata") +local physics = ent:getComponent("Physics") +local bullet = ent:getComponent("Bullet") +local velocty = physics:linearVelocity() local speed = metadata["speed"] or 1.0 local starting = transform.position + Vector3f(0,0,0) local ending = transform.position + Vector3f( metadata["delta"][1], metadata["delta"][2], metadata["delta"][3] ) @@ -54,6 +57,7 @@ end soundEmitter:getComponent("Transform"):setReference( transform ) -- on tick ent:bind( "tick", function(self) + if wait > 0 then wait = wait - time.delta() else @@ -69,8 +73,12 @@ ent:bind( "tick", function(self) stopSound("lift_start") playSound("lift_stop") startingSound = true + -- bullet:setVelocity( Vector3f(0,0,0) ) + -- physics:setLinearVelocity( Vector3f(0,0,0) ) + else + -- bullet:setVelocity( Vector3f(0,direction,0) ) + -- physics:setLinearVelocity( Vector3f(0,direction / math.abs(direction),0) ) end end transform.position = Vector3f.lerp( starting, ending, alpha ) - end ) \ No newline at end of file diff --git a/engine/inc/uf/ext/bullet/bullet.h b/engine/inc/uf/ext/bullet/bullet.h index 913d816f..d9e339ba 100644 --- a/engine/inc/uf/ext/bullet/bullet.h +++ b/engine/inc/uf/ext/bullet/bullet.h @@ -9,16 +9,15 @@ #if UF_USE_BULLET #include +#include "BulletCollision/CollisionDispatch/btInternalEdgeUtility.h" #endif namespace pod { struct UF_API Bullet { size_t uid = 0; uf::Object* pointer = NULL; - float mass = 0.0f; - pod::Vector3f inertia = {}; pod::Transform<> transform; - bool shared = false; // share control of the transform both in-engine and bullet, set to true if you're directly modifying the transform + #if UF_USE_BULLET btRigidBody* body = NULL; btCollisionShape* shape = NULL; @@ -26,6 +25,14 @@ namespace pod { void* body = NULL; void* shape = NULL; #endif + + struct { + float mass = 0.0f; + float friction = 0.8f; + float restitution = 0.0f; + pod::Vector3f inertia = {}; + pod::Vector3f gravity = {}; + } stats; }; } #if UF_USE_BULLET @@ -65,10 +72,10 @@ namespace ext { // collider for mesh (static or dynamic) pod::Bullet& create( uf::Object&, const uf::Mesh&, bool ); // collider for boundingbox - pod::Bullet& UF_API create( uf::Object&, const pod::Vector3f&, float ); - uf::stl::vector& UF_API create( uf::Object&, const uf::stl::vector&, float ); + pod::Bullet& UF_API create( uf::Object&, const pod::Vector3f& ); + uf::stl::vector& UF_API create( uf::Object&, const uf::stl::vector& ); // collider for capsule - pod::Bullet& UF_API create( uf::Object&, float, float, float ); + pod::Bullet& UF_API create( uf::Object&, float, float ); // synchronize engine transforms to bullet transforms void UF_API syncToBullet(); @@ -98,6 +105,4 @@ namespace ext { void UF_API debugDraw( uf::Object& ); } } - -#include "bullet.inl" #endif \ No newline at end of file diff --git a/engine/inc/uf/ext/bullet/bullet.inl b/engine/inc/uf/ext/bullet/bullet.inl deleted file mode 100644 index e98315f0..00000000 --- a/engine/inc/uf/ext/bullet/bullet.inl +++ /dev/null @@ -1,84 +0,0 @@ -#include "BulletCollision/CollisionDispatch/btInternalEdgeUtility.h" -#if 0 -template -pod::Bullet& ext::bullet::create( uf::Object& object, const uf::Mesh& mesh, bool dynamic ) { - auto& transform = object.getComponent>(); - auto model = uf::transform::model( transform ); - - auto& collider = ext::bullet::create( object ); - - btTriangleMesh* bMesh = new btTriangleMesh( true, false ); - bMesh->preallocateVertices( mesh.vertices.size() ); - for ( auto& vertex : mesh.vertices ) { - bMesh->findOrAddVertex( btVector3(vertex.position.x, vertex.position.y, vertex.position.z), false ); - } - - if ( mesh.attributes.index.pointer ) { - bMesh->preallocateIndices( mesh.indices.size() ); - for ( auto& index : mesh.indices ) bMesh->addIndex( index ); - bMesh->getIndexedMeshArray()[0].m_numTriangles = mesh.indices.size() / 3; - } - - collider.shape = new btBvhTriangleMeshShape(bMesh, true); - ext::bullet::attach( collider ); - - btTransform t = collider.body->getWorldTransform(); - t.setFromOpenGLMatrix(&model[0]); - collider.body->setWorldTransform(t); - collider.body->setCenterOfMassTransform(t); - - btBvhTriangleMeshShape* triangleMeshShape = (btBvhTriangleMeshShape*) collider.shape; - btTriangleInfoMap* triangleInfoMap = new btTriangleInfoMap(); - triangleInfoMap->m_edgeDistanceThreshold = 0.01f; - triangleInfoMap->m_maxEdgeAngleThreshold = SIMD_HALF_PI*0.25; - if ( !false ) btGenerateInternalEdgeInfo( triangleMeshShape, triangleInfoMap ); - collider.body->setCollisionFlags(collider.body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); - - return collider; -#if 0 - auto& collider = ext::bullet::create( object ); - btTriangleMesh* bMesh = new btTriangleMesh(); - auto& transform = object.getComponent>(); - auto model = uf::transform::model( transform ); - auto expanded = mesh; - expanded.expand(); - for ( size_t i = 0; i < expanded.vertices.size() / 3; ++i ) { - if ( i * 3 + 2 >= expanded.vertices.size() ) break; - auto a = expanded.vertices[i*3+0].position; - auto b = expanded.vertices[i*3+1].position; - auto c = expanded.vertices[i*3+2].position; - if ( applyTransform ) { - a = uf::matrix::multiply( model, a ); - b = uf::matrix::multiply( model, b ); - c = uf::matrix::multiply( model, c ); - } - - if ( windingOrder == -1 ) { - bMesh->addTriangle(btVector3(a.x, a.y, a.z), btVector3(b.x, b.y, b.z), btVector3(c.x, c.y, c.z)); - } else if ( windingOrder == 0 ) { - bMesh->addTriangle(btVector3(a.x, a.y, a.z), btVector3(b.x, b.y, b.z), btVector3(c.x, c.y, c.z)); - bMesh->addTriangle(btVector3(a.x, a.y, a.z), btVector3(c.x, c.y, c.z), btVector3(b.x, b.y, b.z)); - } else if ( windingOrder == 1 ) { - bMesh->addTriangle(btVector3(a.x, a.y, a.z), btVector3(c.x, c.y, c.z), btVector3(b.x, b.y, b.z)); - } - } - collider.shape = new btBvhTriangleMeshShape(bMesh, true); - ext::bullet::attach( collider ); - { - btTransform t = collider.body->getWorldTransform(); - t.setFromOpenGLMatrix(&model[0]); - collider.body->setWorldTransform(t); - collider.body->setCenterOfMassTransform(t); - } - return collider; - /* - if ( applyTransform ) { - auto transformed = uf::matrix::multiply( model, vertex.position ); - queue.emplace_back( transformed.x, transformed.y, transformed.z ); - } else { - queue.emplace_back( vertex.position.x, vertex.position.y, vertex.position.z ); - } - */ -#endif -} -#endif \ No newline at end of file diff --git a/engine/src/engine/graph/graph.cpp b/engine/src/engine/graph/graph.cpp index 4fa96d3f..7e0e1313 100644 --- a/engine/src/engine/graph/graph.cpp +++ b/engine/src/engine/graph/graph.cpp @@ -40,10 +40,43 @@ UF_VERTEX_DESCRIPTOR(uf::graph::mesh::Skinned, ); namespace { - void initializeShaders( pod::Graph& graph, uf::Object& entity ) { + void initializeGraphics( pod::Graph& graph, uf::Object& entity ) { + auto& scene = uf::scene::getCurrentScene(); + auto& sceneTextures = scene.getComponent(); + auto& sceneMetadataJson = scene.getComponent(); + auto& graphic = entity.getComponent(); - if ( graphic.material.shaders.size() > 0 ) return; + graphic.device = &uf::renderer::device; + graphic.material.device = &uf::renderer::device; + graphic.descriptor.frontFace = uf::renderer::enums::Face::CCW; + graphic.descriptor.cullMode = !(graph.metadata["flags"]["INVERT"].as()) ? uf::renderer::enums::CullMode::BACK : uf::renderer::enums::CullMode::FRONT; + if ( graph.metadata["cull mode"].is() ) { + if ( graph.metadata["cull mode"].as() == "back" ) { + graphic.descriptor.cullMode = uf::renderer::enums::CullMode::BACK; + } else if ( graph.metadata["cull mode"].as() == "front" ) { + graphic.descriptor.cullMode = uf::renderer::enums::CullMode::FRONT; + } else if ( graph.metadata["cull mode"].as() == "none" ) { + graphic.descriptor.cullMode = uf::renderer::enums::CullMode::NONE; + } else if ( graph.metadata["cull mode"].as() == "both" ) { + graphic.descriptor.cullMode = uf::renderer::enums::CullMode::BOTH; + } + } + { + for ( auto& i : graph.images ) graphic.material.textures.emplace_back().aliasTexture( uf::graph::storage.texture2Ds.map[i] ); + for ( auto& s : graph.samplers ) graphic.material.samplers.emplace_back( uf::graph::storage.samplers.map[s] ); + // bind scene's voxel texture + if ( uf::renderer::settings::experimental::vxgi ) { + auto& scene = uf::scene::getCurrentScene(); + auto& sceneTextures = scene.getComponent(); + for ( auto& t : sceneTextures.voxels.id ) graphic.material.textures.emplace_back().aliasTexture(t); + for ( auto& t : sceneTextures.voxels.normal ) graphic.material.textures.emplace_back().aliasTexture(t); + for ( auto& t : sceneTextures.voxels.uv ) graphic.material.textures.emplace_back().aliasTexture(t); + for ( auto& t : sceneTextures.voxels.radiance ) graphic.material.textures.emplace_back().aliasTexture(t); + for ( auto& t : sceneTextures.voxels.depth ) graphic.material.textures.emplace_back().aliasTexture(t); + } + } + uf::stl::string root = uf::io::directory( graph.name ); size_t texture2Ds = 0; size_t texture3Ds = 0; @@ -189,8 +222,6 @@ namespace { graphic.material.attachShader(geometryShaderFilename, uf::renderer::enums::Shader::GEOMETRY, "vxgi"); } { - auto& scene = uf::scene::getCurrentScene(); - auto& sceneTextures = scene.getComponent(); uint32_t voxelTypes = 0; if ( !sceneTextures.voxels.id.empty() ) ++voxelTypes; if ( !sceneTextures.voxels.normal.empty() ) ++voxelTypes; @@ -220,6 +251,58 @@ namespace { } } + shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.instance ); + shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.material ); + shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.texture ); + shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.light ); + } + } + // baking pipeline + if ( graph.metadata["baking"]["enabled"].as() ) { + { + graphic.material.metadata.autoInitializeUniforms = false; + uf::stl::string vertexShaderFilename = uf::io::resolveURI("/graph/baking/bake.vert.spv"); + uf::stl::string fragmentShaderFilename = uf::io::resolveURI("/graph/baking/bake.frag.spv"); + graphic.material.attachShader(vertexShaderFilename, uf::renderer::enums::Shader::VERTEX, "baking"); + graphic.material.attachShader(fragmentShaderFilename, uf::renderer::enums::Shader::FRAGMENT, "baking"); + graphic.material.metadata.autoInitializeUniforms = true; + } + { + uint32_t maxPasses = 6; + + auto& shader = graphic.material.getShader("vertex", "baking"); + uint32_t* specializationConstants = (uint32_t*) (void*) shader.specializationConstants; + for ( auto pair : shader.metadata.definitions.specializationConstants ) { + auto& sc = pair.second; + if ( sc.name == "PASSES" ) sc.value.ui = (specializationConstants[sc.index] = maxPasses); + } + + // shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.camera ); + // shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.drawCommands ); + shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.instance ); + shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.joint ); + } + { + size_t maxTextures = sceneMetadataJson["system"]["config"]["engine"]["scenes"]["textures"]["max"]["2D"].as(512); + size_t maxCubemaps = sceneMetadataJson["system"]["config"]["engine"]["scenes"]["textures"]["max"]["cube"].as(128); + size_t maxTextures3D = sceneMetadataJson["system"]["config"]["engine"]["scenes"]["textures"]["max"]["3D"].as(128); + + auto& shader = graphic.material.getShader("fragment", "baking"); + uint32_t* specializationConstants = (uint32_t*) (void*) shader.specializationConstants; + for ( auto pair : shader.metadata.definitions.specializationConstants ) { + auto& sc = pair.second; + if ( sc.name == "TEXTURES" ) sc.value.ui = (specializationConstants[sc.index] = maxTextures); + else if ( sc.name == "CUBEMAPS" ) sc.value.ui = (specializationConstants[sc.index] = maxCubemaps); + } + for ( auto pair : shader.metadata.definitions.textures ) { + auto& tx = pair.second; + for ( auto& layout : shader.descriptorSetLayoutBindings ) { + if ( layout.binding != tx.binding ) continue; + if ( tx.name == "samplerTextures" ) layout.descriptorCount = maxTextures; + else if ( tx.name == "samplerCubemaps" ) layout.descriptorCount = maxCubemaps; + } + } + shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.instance ); shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.material ); shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.texture ); @@ -227,40 +310,9 @@ namespace { } } #endif - } - void initializeGraphics( pod::Graph& graph, uf::Object& entity ) { - auto& graphic = entity.getComponent(); - graphic.device = &uf::renderer::device; - graphic.material.device = &uf::renderer::device; - graphic.descriptor.frontFace = uf::renderer::enums::Face::CCW; - graphic.descriptor.cullMode = !(graph.metadata["flags"]["INVERT"].as()) ? uf::renderer::enums::CullMode::BACK : uf::renderer::enums::CullMode::FRONT; - if ( graph.metadata["cull mode"].is() ) { - if ( graph.metadata["cull mode"].as() == "back" ) { - graphic.descriptor.cullMode = uf::renderer::enums::CullMode::BACK; - } else if ( graph.metadata["cull mode"].as() == "front" ) { - graphic.descriptor.cullMode = uf::renderer::enums::CullMode::FRONT; - } else if ( graph.metadata["cull mode"].as() == "none" ) { - graphic.descriptor.cullMode = uf::renderer::enums::CullMode::NONE; - } else if ( graph.metadata["cull mode"].as() == "both" ) { - graphic.descriptor.cullMode = uf::renderer::enums::CullMode::BOTH; - } - } - { - for ( auto& i : graph.images ) graphic.material.textures.emplace_back().aliasTexture( uf::graph::storage.texture2Ds.map[i] ); - for ( auto& s : graph.samplers ) graphic.material.samplers.emplace_back( uf::graph::storage.samplers.map[s] ); - // bind scene's voxel texture - if ( uf::renderer::settings::experimental::vxgi ) { - auto& scene = uf::scene::getCurrentScene(); - auto& sceneTextures = scene.getComponent(); - for ( auto& t : sceneTextures.voxels.id ) graphic.material.textures.emplace_back().aliasTexture(t); - for ( auto& t : sceneTextures.voxels.normal ) graphic.material.textures.emplace_back().aliasTexture(t); - for ( auto& t : sceneTextures.voxels.uv ) graphic.material.textures.emplace_back().aliasTexture(t); - for ( auto& t : sceneTextures.voxels.radiance ) graphic.material.textures.emplace_back().aliasTexture(t); - for ( auto& t : sceneTextures.voxels.depth ) graphic.material.textures.emplace_back().aliasTexture(t); - } - } - - initializeShaders( graph, entity ); + + uf::instantiator::bind( "GraphBehavior", entity ); + uf::instantiator::unbind( "RenderBehavior", entity ); } } @@ -310,13 +362,15 @@ void uf::graph::process( pod::Graph& graph ) { #else #define UF_GRAPH_DEFAULT_LIGHTMAP "" #endif - bool lightmapped = false; { + { const uf::stl::string lightmapFilename = graph.metadata["lightmap"].as(UF_GRAPH_DEFAULT_LIGHTMAP); // load lightmap, if requested if ( lightmapFilename != "" && !uf::renderer::settings::experimental::deferredSampling ) { // check if valid filename, if not it's a texture name uf::stl::string f = uf::io::sanitize( lightmapFilename, uf::io::directory( graph.name ) ); - if ( (lightmapped = uf::io::exists( f )) ) { + if ( uf::io::exists( f ) ) { + graph.metadata["baking"]["enabled"] = false; + // auto materialID = graph.materials.size(); auto textureID = graph.textures.size(); auto imageID = graph.images.size(); @@ -585,7 +639,7 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent ) size_t objectID = uf::graph::storage.entities.keys.size(); uf::graph::storage.entities[std::to_string(objectID)] = &entity; -#if 1 + if ( 0 <= node.mesh && node.mesh < graph.meshes.size() ) { auto model = uf::transform::model( transform ); auto& mesh = uf::graph::storage.meshes.map[graph.meshes[node.mesh]]; @@ -625,126 +679,38 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent ) initializeGraphics( graph, entity ); } - #if 1 if ( !ext::json::isNull( graph.metadata["tags"][node.name] ) ) { - auto& info = graph.metadata["tags"][node.name]; - if ( ext::json::isObject( info["collision"] ) ) { - uf::stl::string type = info["collision"]["type"].as(); - float mass = info["collision"]["mass"].as(); - bool dynamic = !info["collision"]["static"].as(); - bool recenter = info["collision"]["recenter"].as(); - - auto min = uf::matrix::multiply( model, bounds.min, 1.0f ); - auto max = uf::matrix::multiply( model, bounds.max, 1.0f ); - - pod::Vector3f center = (max + min) * 0.5f; - pod::Vector3f corner = (max - min) * 0.5f; - - #if UF_USE_BULLET - if ( type == "mesh" ) { - auto& collider = ext::bullet::create( entity.as(), mesh, dynamic ); - if ( recenter ) collider.transform.position = center; - } else if ( type == "bounding box" ) { - auto& collider = ext::bullet::create( entity.as(), corner, mass ); - collider.shared = true; - if ( recenter ) collider.transform.position = center - transform.position; - } else if ( type == "capsule" ) { - float radius = info["collision"]["radius"].as(); - float height = info["collision"]["height"].as(); - auto& collider = ext::bullet::create( entity.as(), radius, height, mass ); - collider.shared = true; - if ( recenter ) collider.transform.position = center - transform.position; - } - #endif - } - } - #endif - } -#else - if ( 0 <= node.mesh && node.mesh < graph.meshes.size() ) { - auto model = uf::transform::model( transform ); - auto flatten = uf::transform::flatten( transform ); - auto& mesh = uf::graph::storage.meshes.map[graph.meshes[node.mesh]]; - auto& primitives = uf::graph::storage.primitives.map[graph.primitives[node.mesh]]; - - pod::Instance::Bounds bounds; - uf::stl::vector corners; - // setup instances - for ( auto i = 0; i < primitives.size(); ++i ) { - auto& primitive = primitives[i]; - - size_t instanceID = uf::graph::storage.instances.keys.size(); - auto& instance = uf::graph::storage.instances[graph.instances.emplace_back(std::to_string(instanceID))]; - instance = primitive.instance; - - instance.model = model; - instance.objectID = objectID; - instance.jointID = node.skin; - - auto& corner = corners.emplace_back(instance.bounds); - - bounds.min = uf::vector::min( bounds.min, instance.bounds.min ); - bounds.max = uf::vector::max( bounds.max, instance.bounds.max ); - - if ( mesh.indirect.count && mesh.indirect.count <= primitives.size() ) { - auto& attribute = mesh.indirect.attributes.front(); - auto& buffer = mesh.buffers[mesh.isInterleaved(mesh.indirect.interleaved) ? mesh.indirect.interleaved : attribute.buffer]; - pod::DrawCommand* drawCommands = (pod::DrawCommand*) buffer.data(); - auto& drawCommand = drawCommands[i]; - drawCommand.instanceID = instanceID; - } - } - if ( (graph.metadata["flags"]["SEPARATE"].as()) && graph.metadata["flags"]["RENDER"].as() ) { - uf::instantiator::bind("RenderBehavior", entity); - - auto& graphic = entity.getComponent(); - graphic.initialize(); - graphic.initializeMesh( mesh ); - graphic.process = true; + auto info = graph.metadata["tags"][node.name]["physics"]; + if ( !ext::json::isObject( info ) ) info = metadataJson["system"]["physics"]; + else metadataJson["system"]["physics"] = info; - initializeGraphics( graph, entity ); - } - - #if 1 - if ( !ext::json::isNull( graph.metadata["tags"][node.name] ) ) { - auto& info = graph.metadata["tags"][node.name]; - if ( ext::json::isObject( info["collision"] ) ) { - uf::stl::string type = info["collision"]["type"].as(); - float mass = info["collision"]["mass"].as(); - bool dynamic = !info["collision"]["static"].as(); - bool recenter = info["collision"]["recenter"].as(); - - auto min = uf::matrix::multiply( model, bounds.min, 1.0f ); - auto max = uf::matrix::multiply( model, bounds.max, 1.0f ); - - pod::Vector3f center = (max + min) * 0.5f; - pod::Vector3f corner = (max - min) * 0.5f; - - // center = uf::matrix::multiply( model, center, 1.0f ); - // corner = uf::matrix::multiply( model, corner, 0.0f ); + if ( ext::json::isObject( info ) ) { + uf::stl::string type = info["type"].as(); #if UF_USE_BULLET + if ( type == "mesh" ) { - auto& collider = ext::bullet::create( entity.as(), mesh, dynamic ); - if ( recenter ) collider.transform.position = center; - } else if ( type == "bounding box" ) { - auto& collider = ext::bullet::create( entity.as(), corner, mass ); - collider.shared = true; - if ( recenter ) collider.transform.position = center - transform.position; - } else if ( type == "capsule" ) { - float radius = info["collision"]["radius"].as(); - float height = info["collision"]["height"].as(); - auto& collider = ext::bullet::create( entity.as(), radius, height, mass ); - collider.shared = true; - if ( recenter ) collider.transform.position = center - transform.position; - } else if ( type == "bounding boxes" ) { - // auto& colliders = ext::bullet::create( entity.as(), corners, mass ); + auto& collider = entity.getComponent(); + collider.stats.mass = info["mass"].as(collider.stats.mass); + collider.stats.friction = info["friction"].as(collider.stats.friction); + collider.stats.restitution = info["restitution"].as(collider.stats.restitution); + collider.stats.inertia = uf::vector::decode( info["inertia"], collider.stats.inertia ); + collider.stats.gravity = uf::vector::decode( info["gravity"], collider.stats.gravity ); + + ext::bullet::create( entity.as(), mesh, !info["static"].as(true) ); + } else { + auto min = uf::matrix::multiply( model, bounds.min, 1.0f ); + auto max = uf::matrix::multiply( model, bounds.max, 1.0f ); + + pod::Vector3f center = (max + min) * 0.5f; + pod::Vector3f corner = (max - min) * 0.5f; + + metadataJson["system"]["physics"]["center"] = uf::vector::encode( center ); + metadataJson["system"]["physics"]["corner"] = uf::vector::encode( corner ); } #endif } } - #endif } -#endif //UF_MSG_DEBUG( "Loaded " << node.name ); for ( auto index : node.children ) uf::graph::process( graph, index, entity ); } @@ -796,6 +762,8 @@ void uf::graph::initialize( pod::Graph& graph ) { graph.root.entity->initialize(); graph.root.entity->process([&]( uf::Entity* entity ) { + if ( entity->getUid() == 0 ) entity->initialize(); + /* //UF_MSG_DEBUG( "Initializing... " << uf::string::toString( entity->as() ) ); if ( !entity->hasComponent() ) { if ( entity->getUid() == 0 ) entity->initialize(); @@ -808,6 +776,7 @@ void uf::graph::initialize( pod::Graph& graph ) { uf::instantiator::unbind( "RenderBehavior", *entity ); if ( entity->getUid() == 0 ) entity->initialize(); //UF_MSG_DEBUG( "Initialized " << uf::string::toString( entity->as() ) ); + */ }); } diff --git a/engine/src/engine/object/behavior.cpp b/engine/src/engine/object/behavior.cpp index 84e94db0..814ee3f2 100644 --- a/engine/src/engine/object/behavior.cpp +++ b/engine/src/engine/object/behavior.cpp @@ -19,6 +19,7 @@ void uf::ObjectBehavior::initialize( uf::Object& self ) { auto& scene = uf::scene::getCurrentScene(); auto& assetLoader = scene.getComponent(); auto& metadataJson = this->getComponent(); + auto& transform = this->getComponent>(); // { @@ -115,27 +116,26 @@ void uf::ObjectBehavior::initialize( uf::Object& self ) { #if UF_USE_BULLET if ( ext::json::isObject(metadataJson["system"]["physics"]) ) { - float mass = metadataJson["system"]["physics"]["mass"].as(); auto& collider = this->getComponent(); - if ( !ext::json::isNull( metadataJson["system"]["physics"]["inertia"] ) ) { - collider.inertia = uf::vector::decode( metadataJson["system"]["physics"]["inertia"], pod::Vector3f{} ); - } - if ( metadataJson["system"]["physics"]["type"].as() == "BoundingBox" ) { + collider.stats.mass = metadataJson["system"]["physics"]["mass"].as(collider.stats.mass); + collider.stats.restitution = metadataJson["system"]["physics"]["restitution"].as(collider.stats.restitution); + collider.stats.friction = metadataJson["system"]["physics"]["friction"].as(collider.stats.friction); + collider.stats.inertia = uf::vector::decode( metadataJson["system"]["physics"]["inertia"], collider.stats.inertia ); + collider.stats.gravity = uf::vector::decode( metadataJson["system"]["physics"]["gravity"], collider.stats.gravity ); + + if ( metadataJson["system"]["physics"]["type"].as() == "bounding box" ) { + pod::Vector3f center = uf::vector::decode( metadataJson["system"]["physics"]["center"], pod::Vector3f{} ); pod::Vector3f corner = uf::vector::decode( metadataJson["system"]["physics"]["corner"], pod::Vector3f{0.5, 0.5, 0.5} ); - ext::bullet::create( *this, corner, mass ); - } else if ( metadataJson["system"]["physics"]["type"].as() == "Capsule" ) { + + ext::bullet::create( *this, corner ); + + if ( metadataJson["system"]["physics"]["recenter"].as() ) collider.transform.position = center - transform.position; + + } else if ( metadataJson["system"]["physics"]["type"].as() == "capsule" ) { float radius = metadataJson["system"]["physics"]["radius"].as(); float height = metadataJson["system"]["physics"]["height"].as(); - ext::bullet::create( *this, radius, height, mass ); - } else { - return; - } - if ( !ext::json::isNull( metadataJson["system"]["physics"]["gravity"] ) ) { - pod::Vector3f v = uf::vector::decode( metadataJson["system"]["physics"]["gravity"], pod::Vector3f{} ); - collider.body->setGravity( btVector3( v.x, v.y, v.z ) ); - } - if ( metadataJson["system"]["physics"]["shared"].is() ) { - collider.shared = metadataJson["system"]["physics"]["shared"].as(); + + ext::bullet::create( *this, radius, height ); } } #endif @@ -220,6 +220,15 @@ void uf::ObjectBehavior::tick( uf::Object& self ) { transform.position = uf::transform::flatten( parentTransform ).position + metadata.transform.initial.position; } +/* + if ( this->hasComponent() && this->hasComponent() ) { + auto& collider = this->getComponent(); + auto& transform = this->getComponent>(); + auto& physics = this->getComponent(); + UF_MSG_DEBUG( this->getName() << ": " << this->getUid() << " " << uf::vector::toString( physics.linear.velocity ) << " " << uf::vector::toString( transform.position ) ); + } +*/ + auto& queue = metadata.hooks.queue; if ( !uf::Object::timer.running() ) uf::Object::timer.start(); float curTime = uf::Object::timer.elapsed().asDouble(); diff --git a/engine/src/ext/bullet/bullet.cpp b/engine/src/ext/bullet/bullet.cpp index da80d82d..47a42bd8 100644 --- a/engine/src/ext/bullet/bullet.cpp +++ b/engine/src/ext/bullet/bullet.cpp @@ -100,21 +100,22 @@ namespace ext { #if !UF_ENV_DREAMCAST static bool contactCallback(btManifoldPoint &ManifoldPoint, const btCollisionObjectWrapper *Object0, int PartID0, int Index0, const btCollisionObjectWrapper *Object1, int PartID1, int Index1) { if( Object1->getCollisionShape()->getShapeType() != TRIANGLE_SHAPE_PROXYTYPE ) return false; - +/* pod::Vector3f Before = { ManifoldPoint.m_normalWorldOnB.getX(), ManifoldPoint.m_normalWorldOnB.getY(), ManifoldPoint.m_normalWorldOnB.getZ(), }; +*/ btAdjustInternalEdgeContacts(ManifoldPoint, Object1, Object0, PartID1, Index1); btAdjustInternalEdgeContacts(ManifoldPoint, Object0, Object1, PartID0, Index0); - +/* pod::Vector3f After = { ManifoldPoint.m_normalWorldOnB.getX(), ManifoldPoint.m_normalWorldOnB.getY(), ManifoldPoint.m_normalWorldOnB.getZ(), }; - +*/ return false; } #endif @@ -138,7 +139,7 @@ void ext::bullet::initialize() { mesh.bind(); #if !UF_ENV_DREAMCAST - gContactAddedCallback = contactCallback; +// gContactAddedCallback = contactCallback; #endif } void ext::bullet::tick( float delta ) { if ( delta == 0.0f ) delta = uf::physics::time::delta; @@ -186,25 +187,20 @@ void ext::bullet::syncToBullet() { if ( !entity || !entity->isValid() || !entity->hasComponent() ) continue; auto& collider = entity->getComponent(); - if ( !collider.shared ) continue; - { - auto& physics = entity->getComponent(); - body->setLinearVelocity( btVector3( physics.linear.velocity.x, physics.linear.velocity.y, physics.linear.velocity.z ) ); - } - { - auto model = uf::transform::model( collider.transform ); - - btTransform t; - t = body->getWorldTransform(); - t.setFromOpenGLMatrix(&model[0]); + + auto& physics = entity->getComponent(); + auto model = uf::transform::model( collider.transform ); + + btTransform t; + t = body->getWorldTransform(); + t.setFromOpenGLMatrix(&model[0]); + // t.setOrigin( btVector3( transform.position.x, transform.position.y, transform.position.z ) ); + // t.setRotation( btQuaternion( transform.orientation.x, transform.orientation.y, transform.orientation.z, transform.orientation.w ) ); - // t.setOrigin( btVector3( transform.position.x, transform.position.y, transform.position.z ) ); - // t.setRotation( btQuaternion( transform.orientation.x, transform.orientation.y, transform.orientation.z, transform.orientation.w ) ); - - body->setWorldTransform(t); - body->setCenterOfMassTransform(t); - } + body->setWorldTransform(t); + body->setCenterOfMassTransform(t); + body->setLinearVelocity( btVector3( physics.linear.velocity.x, physics.linear.velocity.y, physics.linear.velocity.z ) ); } } void ext::bullet::syncFromBullet() { @@ -253,7 +249,7 @@ pod::Bullet& ext::bullet::create( uf::Object& object ) { collider.uid = object.getUid(); collider.pointer = &object; collider.transform.reference = &object.getComponent>(); - collider.shared = false; + collider.shared = true; return collider; } void ext::bullet::attach( pod::Bullet& collider ) { @@ -266,17 +262,21 @@ void ext::bullet::attach( pod::Bullet& collider ) { // t.setOrigin(btVector3(collider.transform->position.x, collider.transform->position.y, collider.transform->position.z)); // t.setRotation(btQuaternion(collider.transform->orientation.x, collider.transform->orientation.y, collider.transform->orientation.z, collider.transform->orientation.w)); - btVector3 inertia(collider.inertia.x, collider.inertia.y, collider.inertia.z); + btVector3 inertia(collider.stats.inertia.x, collider.stats.inertia.y, collider.stats.inertia.z); btDefaultMotionState* motion = new btDefaultMotionState(t); - if ( collider.mass != 0.0f ) collider.shape->calculateLocalInertia(collider.mass, inertia); - btRigidBody::btRigidBodyConstructionInfo info(collider.mass, motion, collider.shape, inertia); + if ( collider.stats.mass != 0.0f ) collider.shape->calculateLocalInertia(collider.stats.mass, inertia); + btRigidBody::btRigidBodyConstructionInfo info(collider.stats.mass, motion, collider.shape, inertia); collider.body = new btRigidBody(info); collider.body->setUserPointer((void*) collider.pointer); + collider.body->setRestitution(collider.stats.restitution); + collider.body->setFriction(collider.stats.friction); + collider.body->setGravity( btVector3( collider.stats.gravity.x, collider.stats.gravity.y, collider.stats.gravity.z ) ); - if ( collider.mass > 0 ) { - collider.body->activate(true); - collider.body->setActivationState(DISABLE_DEACTIVATION); + if ( collider.stats.mass > 0 ) { +// collider.body->setCollisionFlags(collider.body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); +// collider.body->activate(true); +// collider.body->setActivationState(DISABLE_DEACTIVATION); } ext::bullet::dynamicsWorld->addRigidBody(collider.body); @@ -408,9 +408,8 @@ pod::Bullet& ext::bullet::create( uf::Object& object, const void* verticesPointe return collider; } */ -pod::Bullet& ext::bullet::create( uf::Object& object, const pod::Vector3f& corner, float mass ) { +pod::Bullet& ext::bullet::create( uf::Object& object, const pod::Vector3f& corner ) { auto& collider = ext::bullet::create( object ); - collider.mass = mass; collider.shape = new btBoxShape(btVector3(corner.x, corner.y, corner.z)); ext::bullet::attach( collider ); @@ -423,7 +422,7 @@ pod::Bullet& ext::bullet::create( uf::Object& object, const pod::Vector3f& corne collider.body->setCcdSweptSphereRadius(0.25 * 0.2); return collider; } -uf::stl::vector& ext::bullet::create( uf::Object& object, const uf::stl::vector& bounds, float mass ) { +uf::stl::vector& ext::bullet::create( uf::Object& object, const uf::stl::vector& bounds ) { auto& colliders = object.getComponent>(); colliders.reserve(colliders.size() + bounds.size()); @@ -431,25 +430,6 @@ uf::stl::vector& ext::bullet::create( uf::Object& object, const uf: auto flatten = uf::transform::flatten( transform ); auto model = uf::transform::model( transform ); for ( auto bound : bounds ) { - /* - pod::Vector3f corners[8] = { - uf::matrix::multiply( model, pod::Vector3f{ -bound.min.x, bound.min.y, bound.min.z }, 1.0f ), - uf::matrix::multiply( model, pod::Vector3f{ -bound.max.x, bound.min.y, bound.min.z }, 1.0f ), - uf::matrix::multiply( model, pod::Vector3f{ -bound.max.x, bound.max.y, bound.min.z }, 1.0f ), - uf::matrix::multiply( model, pod::Vector3f{ -bound.min.x, bound.max.y, bound.min.z }, 1.0f ), - - uf::matrix::multiply( model, pod::Vector3f{ -bound.min.x, bound.min.y, bound.max.z }, 1.0f ), - uf::matrix::multiply( model, pod::Vector3f{ -bound.max.x, bound.min.y, bound.max.z }, 1.0f ), - uf::matrix::multiply( model, pod::Vector3f{ -bound.max.x, bound.max.y, bound.max.z }, 1.0f ), - uf::matrix::multiply( model, pod::Vector3f{ -bound.min.x, bound.max.y, bound.max.z }, 1.0f ), - }; - bound = {}; - - FOR_ARRAY( corners ) { - bound.min = uf::vector::min( bound.min, corners[i] ); - bound.max = uf::vector::max( bound.max, corners[i] ); - } - */ pod::Vector3f center = (bound.max + bound.min) * 0.5f; pod::Vector3f corner = (bound.max - bound.min) * 0.5f; center.x = -center.x; @@ -461,7 +441,6 @@ uf::stl::vector& ext::bullet::create( uf::Object& object, const uf: collider.transform = flatten; collider.transform.position = center; collider.transform.reference = NULL; - collider.mass = mass; collider.shape = new btBoxShape(btVector3(corner.x, corner.y, corner.z)); ext::bullet::attach( collider ); @@ -473,9 +452,8 @@ uf::stl::vector& ext::bullet::create( uf::Object& object, const uf: return colliders; } -pod::Bullet& ext::bullet::create( uf::Object& object, float radius, float height, float mass ) { +pod::Bullet& ext::bullet::create( uf::Object& object, float radius, float height ) { auto& collider = ext::bullet::create( object ); - collider.mass = mass; collider.shape = new btCapsuleShape(radius, height); ext::bullet::attach( collider ); @@ -492,15 +470,24 @@ pod::Bullet& ext::bullet::create( uf::Object& object, float radius, float height void UF_API ext::bullet::setVelocity( pod::Bullet& collider, const pod::Vector3f& v ) { if ( !collider.body ) return; - collider.body->setLinearVelocity( btVector3( v.x, v.y, v.z ) ); + collider.body->activate(true); + if ( collider.shared ) { + auto& physics = collider.pointer->getComponent(); + physics.linear.velocity = v; + } else { + collider.body->setLinearVelocity( btVector3( v.x, v.y, v.z ) ); + } } void UF_API ext::bullet::applyImpulse( pod::Bullet& collider, const pod::Vector3f& v ) { if ( !collider.body ) return; + collider.body->activate(true); collider.body->applyCentralImpulse( btVector3( v.x, v.y, v.z ) /** uf::physics::time::delta*/ ); } void UF_API ext::bullet::applyMovement( pod::Bullet& collider, const pod::Vector3f& v ) { if ( !collider.body ) return; btTransform transform; + collider.body->activate(true); + collider.body->getMotionState()->getWorldTransform(transform); transform.setOrigin( transform.getOrigin() + btVector3( v.x, v.y, v.z ) * uf::physics::time::delta ); @@ -510,14 +497,28 @@ void UF_API ext::bullet::applyMovement( pod::Bullet& collider, const pod::Vector } void UF_API ext::bullet::applyVelocity( pod::Bullet& collider, const pod::Vector3f& v ) { if ( !collider.body ) return; - collider.body->setLinearVelocity( collider.body->getLinearVelocity() + btVector3( v.x, v.y, v.z ) ); + collider.body->activate(true); + + if ( collider.shared ) { + auto& physics = collider.pointer->getComponent(); + physics.linear.velocity += v; + } else { + collider.body->setLinearVelocity( collider.body->getLinearVelocity() + btVector3( v.x, v.y, v.z ) ); + } } void UF_API ext::bullet::applyRotation( pod::Bullet& collider, const pod::Vector3f& axis, float delta ) { - if ( !collider.body ) return; ext::bullet::applyRotation( collider, uf::quaternion::axisAngle( axis, delta ) ); } void UF_API ext::bullet::applyRotation( pod::Bullet& collider, const pod::Quaternion<>& q ) { if ( !collider.body ) return; + collider.body->activate(true); + + if ( collider.shared ) { + auto& transform = collider.pointer->getComponent>(); + uf::transform::rotate( transform, q ); + return; + } + btTransform transform; collider.body->getMotionState()->getWorldTransform(transform); diff --git a/engine/src/ext/lua/usertypes/bullet.cpp b/engine/src/ext/lua/usertypes/bullet.cpp new file mode 100644 index 00000000..6d9996bf --- /dev/null +++ b/engine/src/ext/lua/usertypes/bullet.cpp @@ -0,0 +1,15 @@ +#include +#if UF_USE_LUA && UF_USE_BULLET +#include +#include + +UF_LUA_REGISTER_USERTYPE(pod::Bullet, + UF_LUA_REGISTER_USERTYPE_DEFINE( setVelocity, UF_LUA_C_FUN(ext::bullet::setVelocity) ), + UF_LUA_REGISTER_USERTYPE_DEFINE( applyImpulse, UF_LUA_C_FUN(ext::bullet::applyImpulse) ), + UF_LUA_REGISTER_USERTYPE_DEFINE( applyMovement, UF_LUA_C_FUN(ext::bullet::applyMovement) ), + UF_LUA_REGISTER_USERTYPE_DEFINE( applyVelocity, UF_LUA_C_FUN(ext::bullet::applyVelocity) ), +// UF_LUA_REGISTER_USERTYPE_DEFINE( applyRotation, UF_LUA_C_FUN(ext::bullet::applyRotation) ), + UF_LUA_REGISTER_USERTYPE_DEFINE( activateCollision, UF_LUA_C_FUN(ext::bullet::activateCollision) ) +) + +#endif \ No newline at end of file diff --git a/engine/src/ext/lua/usertypes/object.cpp b/engine/src/ext/lua/usertypes/object.cpp index 8e349d67..67499068 100644 --- a/engine/src/ext/lua/usertypes/object.cpp +++ b/engine/src/ext/lua/usertypes/object.cpp @@ -5,7 +5,11 @@ #include #include #include +#include #include +#if UF_USE_BULLET + #include +#endif namespace binds { uf::stl::string formatHookName(uf::Object& self, const uf::stl::string n ){ @@ -27,6 +31,10 @@ namespace binds { UF_LUA_RETRIEVE_COMPONENT(uf::Audio) UF_LUA_RETRIEVE_COMPONENT(uf::Asset) UF_LUA_RETRIEVE_COMPONENT(uf::Camera) + UF_LUA_RETRIEVE_COMPONENT(pod::Physics) + #if UF_USE_BULLET + UF_LUA_RETRIEVE_COMPONENT(pod::Bullet) + #endif return sol::make_object( ext::lua::state, sol::lua_nil ); } void setComponent(uf::Object& self, const uf::stl::string& type, sol::object value ) { @@ -47,6 +55,10 @@ namespace binds { UF_LUA_UPDATE_COMPONENT(uf::Audio) UF_LUA_UPDATE_COMPONENT(uf::Asset) UF_LUA_UPDATE_COMPONENT(uf::Camera) + UF_LUA_UPDATE_COMPONENT(pod::Physics) + #if UF_USE_BULLET + UF_LUA_UPDATE_COMPONENT(pod::Bullet) + #endif } bool bind(uf::Object& self, const uf::stl::string& type, sol::protected_function fun ) { // if ( !self.hasBehavior({.type = uf::LuaBehavior::type}) ) uf::instantiator::bind( "LuaBehavior", self ); diff --git a/engine/src/ext/lua/usertypes/physics.cpp b/engine/src/ext/lua/usertypes/physics.cpp new file mode 100644 index 00000000..e6f187ec --- /dev/null +++ b/engine/src/ext/lua/usertypes/physics.cpp @@ -0,0 +1,20 @@ +#include +#if UF_USE_LUA +#include + +namespace binds { + pod::Vector3f& linearVelocity( pod::Physics& self ) { return self.linear.velocity; } + pod::Quaternion<>& rotationalVelocity( pod::Physics& self ) { return self.rotational.velocity; } + + void setLinearVelocity( pod::Physics& self, const pod::Vector3f& v ) { self.linear.velocity = v; } + void setRotationalVelocity( pod::Physics& self, const pod::Quaternion<>& v ) { self.rotational.velocity = v; } +} + +UF_LUA_REGISTER_USERTYPE(pod::Physics, + UF_LUA_REGISTER_USERTYPE_DEFINE( linearVelocity, UF_LUA_C_FUN(::binds::linearVelocity) ), + 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) ) +) +#endif \ No newline at end of file diff --git a/ext/behaviors/baking/behavior.cpp b/ext/behaviors/baking/behavior.cpp index 14043d04..8019301d 100644 --- a/ext/behaviors/baking/behavior.cpp +++ b/ext/behaviors/baking/behavior.cpp @@ -18,14 +18,22 @@ UF_BEHAVIOR_TRAITS_CPP(ext::BakingBehavior, ticks = true, renders = false, multi #define this (&self) void ext::BakingBehavior::initialize( uf::Object& self ) { #if UF_USE_VULKAN - this->addHook( "entity:PostInitialization.%UID%", [&]( ext::json::Value& ){ - auto& metadataJson = this->getComponent(); - auto& metadata = this->getComponent(); - auto& scene = uf::scene::getCurrentScene(); - auto& sceneMetadata = scene.getComponent(); - auto& controller = scene.getController(); - auto& controllerTransform = controller.getComponent>(); + auto& metadataJson = this->getComponent(); + auto& metadata = this->getComponent(); + auto& scene = uf::scene::getCurrentScene(); + auto& sceneMetadata = scene.getComponent(); + auto& controller = scene.getController(); + auto& controllerTransform = controller.getComponent>(); + metadata.previous.lights = sceneMetadata.light.max; + metadata.previous.shadows = sceneMetadata.shadow.max; + metadata.previous.update = sceneMetadata.shadow.update; + sceneMetadata.light.max = metadata.max.shadows; + sceneMetadata.shadow.max = metadata.max.shadows; + sceneMetadata.shadow.update = metadata.max.shadows; + UF_MSG_DEBUG("Temporarily altering shadow limits..."); + + this->addHook( "entity:PostInitialization.%UID%", [&]( ext::json::Value& ){ metadata.output = this->grabURI( metadataJson["baking"]["output"].as(), metadataJson["baking"]["root"].as() ); metadata.renderModeName = "B:" + std::to_string((int) this->getUid()); @@ -39,14 +47,6 @@ void ext::BakingBehavior::initialize( uf::Object& self ) { metadata.cull = metadataJson["baking"]["cull"].as(); - metadata.previous.lights = sceneMetadata.light.max; - metadata.previous.shadows = sceneMetadata.shadow.max; - metadata.previous.update = sceneMetadata.shadow.update; - sceneMetadata.light.max = metadata.max.shadows; - sceneMetadata.shadow.max = metadata.max.shadows; - sceneMetadata.shadow.update = metadata.max.shadows; - UF_MSG_DEBUG("Temporarily altering shadow limits..."); - auto& renderMode = this->getComponent(); uf::renderer::addRenderMode( &renderMode, metadata.renderModeName ); @@ -72,62 +72,11 @@ void ext::BakingBehavior::initialize( uf::Object& self ) { scene.process([&]( uf::Entity* entity ) { if ( !entity->hasComponent() ) return; - auto& graphic = entity->getComponent(); - { - graphic.material.metadata.autoInitializeUniforms = false; - uf::stl::string vertexShaderFilename = uf::io::resolveURI("/graph/baking/bake.vert.spv"); - uf::stl::string fragmentShaderFilename = uf::io::resolveURI("/graph/baking/bake.frag.spv"); - graphic.material.attachShader(vertexShaderFilename, uf::renderer::enums::Shader::VERTEX, "baking"); - graphic.material.attachShader(fragmentShaderFilename, uf::renderer::enums::Shader::FRAGMENT, "baking"); - graphic.material.metadata.autoInitializeUniforms = true; - } - { - uint32_t maxPasses = 6; + auto& shader = graphic.material.getShader("fragment", "baking"); - auto& shader = graphic.material.getShader("vertex", "baking"); - uint32_t* specializationConstants = (uint32_t*) (void*) shader.specializationConstants; - for ( auto pair : shader.metadata.definitions.specializationConstants ) { - auto& sc = pair.second; - if ( sc.name == "PASSES" ) sc.value.ui = (specializationConstants[sc.index] = maxPasses); - } - - // uf::renderer::Buffer* indirect = NULL; - // for ( auto& buffer : graphic.buffers ) if ( !indirect && buffer.usage & uf::renderer::enums::Buffer::INDIRECT ) indirect = &buffer; - - // shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.camera ); - // shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.drawCommands ); - shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.instance ); - shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.joint ); - } - { - uint32_t maxTextures = textures2D.size(); - uint32_t maxCubemaps = texturesCube.size(); - - auto& shader = graphic.material.getShader("fragment", "baking"); - uint32_t* specializationConstants = (uint32_t*) (void*) shader.specializationConstants; - for ( auto pair : shader.metadata.definitions.specializationConstants ) { - auto& sc = pair.second; - if ( sc.name == "TEXTURES" ) sc.value.ui = (specializationConstants[sc.index] = maxTextures); - else if ( sc.name == "CUBEMAPS" ) sc.value.ui = (specializationConstants[sc.index] = maxCubemaps); - } - for ( auto pair : shader.metadata.definitions.textures ) { - auto& tx = pair.second; - for ( auto& layout : shader.descriptorSetLayoutBindings ) { - if ( layout.binding != tx.binding ) continue; - if ( tx.name == "samplerTextures" ) layout.descriptorCount = maxTextures; - else if ( tx.name == "samplerCubemaps" ) layout.descriptorCount = maxCubemaps; - } - } - - shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.instance ); - shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.material ); - shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.texture ); - shader.buffers.emplace_back().aliasBuffer( uf::graph::storage.buffers.light ); - - for ( auto& t : textures2D ) shader.textures.emplace_back().aliasTexture( t ); - for ( auto& t : texturesCube ) shader.textures.emplace_back().aliasTexture( t ); - } + for ( auto& t : textures2D ) shader.textures.emplace_back().aliasTexture( t ); + for ( auto& t : texturesCube ) shader.textures.emplace_back().aliasTexture( t ); }); UF_MSG_DEBUG("Finished initialiation."); }); diff --git a/ext/behaviors/player/behavior.cpp b/ext/behaviors/player/behavior.cpp index 0143957e..c8c5e517 100644 --- a/ext/behaviors/player/behavior.cpp +++ b/ext/behaviors/player/behavior.cpp @@ -79,9 +79,9 @@ void ext::PlayerBehavior::initialize( uf::Object& self ) { if ( metadata.camera.invert.x ) relta.x *= -1; metadata.camera.limit.current.x += relta.x; if ( metadata.camera.limit.current.x != metadata.camera.limit.current.x || ( metadata.camera.limit.current.x < metadata.camera.limit.max.x && metadata.camera.limit.current.x > metadata.camera.limit.min.x ) ) { - #if UF_USE_BULLET - if ( collider.body && !collider.shared ) ext::bullet::applyRotation( collider, transform.up, relta.x ); else - #endif + #if UF_USE_BULLET + if ( collider.body ) ext::bullet::applyRotation( collider, transform.up, relta.x ); else + #endif uf::transform::rotate( transform, transform.up, relta.x ); } else metadata.camera.limit.current.x -= relta.x; } @@ -188,7 +188,6 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { bool deltaCrouch = false; bool walking = false; bool floored = true; - bool impulse = true; bool noclipped = false; uf::stl::string menu = ""; uf::stl::string targetAnimation = ""; @@ -200,7 +199,6 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { metadata.deserialize(self, metadataJson); #endif stats.menu = metadata.system.menu; - stats.impulse = metadata.system.physics.impulse; stats.noclipped = metadata.system.noclipped; stats.floored = stats.noclipped; #if UF_USE_BULLET @@ -215,11 +213,14 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { float run = 8; float rotate = 1; float friction = 0.8f; + float air = 1.0f; } speed; { - speed.rotate = metadata.system.physics.rotate * uf::physics::time::delta; - speed.move = metadata.system.physics.move; - speed.run = metadata.system.physics.run; - speed.walk = metadata.system.physics.walk; + speed.rotate = metadata.movement.rotate * uf::physics::time::delta; + speed.move = metadata.movement.move; + speed.run = metadata.movement.run; + speed.walk = metadata.movement.walk; + speed.friction = metadata.movement.friction; + speed.air = metadata.movement.air; if ( stats.noclipped ) { speed.move *= 4.0; @@ -228,9 +229,6 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { if ( !stats.floored || stats.noclipped ) speed.friction = 1; if ( stats.noclipped ) physics.linear.velocity = {}; } - if ( !metadata.system.physics.collision ) { - stats.impulse = true; - } if ( keys.running ) speed.move = speed.run; else if ( keys.walk ) speed.move = speed.walk; @@ -252,6 +250,31 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { } metadata.system.menu = stats.menu; + pod::Transform<> translator = transform; +#if UF_USE_OPENVR + // use the orientation of our controller to determine our target + if ( ext::openvr::context ) { + bool useController = true; + translator.orientation = uf::quaternion::multiply( transform.orientation, useController ? ext::openvr::controllerQuaternion( vr::Controller_Hand::Hand_Right ) : ext::openvr::hmdQuaternion() ); + translator = uf::transform::reorient( translator ); + + // flatten if not noclipped + if ( !stats.noclipped ) { + translator.forward *= { 1, 0, 1 }; + translator.right *= { 1, 0, 1 }; + } + + translator.forward = uf::vector::normalize( translator.forward ); + translator.right = uf::vector::normalize( translator.right ); + } else +#endif + // un-flatted if noclipped + if ( stats.noclipped ){ + auto& cameraTransform = camera.getTransform(); + translator.forward.y += cameraTransform.forward.y; + translator.forward = uf::vector::normalize( translator.forward ); + } + if ( metadata.system.control ) { // noclip handler TIMER(0.25, keys.vee && ) { @@ -264,7 +287,6 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { if ( collider.body ) { collider.body->setGravity(btVector3(0,0.0,0)); collider.body->setCollisionFlags(collider.body->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); - collider.body->setActivationState(DISABLE_SIMULATION); } #endif } else { @@ -272,64 +294,32 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { if ( collider.body ) { collider.body->setGravity(btVector3(0,-9.81,0)); collider.body->setCollisionFlags(collider.body->getCollisionFlags() & ~btCollisionObject::CF_NO_CONTACT_RESPONSE); - collider.body->setActivationState(DISABLE_DEACTIVATION); } #endif } stats.noclipped = state; } // movement handler - { - pod::Transform<> translator = transform; + // setup desired direction + pod::Vector3f target = {}; + if ( keys.forward ^ keys.backwards ) target += translator.forward * (keys.forward ? 1 : -1); + if ( keys.left ^ keys.right ) target += translator.right * (keys.right ? 1 : -1); + target = uf::vector::normalize( target ); - #if UF_USE_OPENVR - // use the orientation of our controller to determine our target - if ( ext::openvr::context ) { - bool useController = true; - translator.orientation = uf::quaternion::multiply( transform.orientation, useController ? ext::openvr::controllerQuaternion( vr::Controller_Hand::Hand_Right ) : ext::openvr::hmdQuaternion() ); - translator = uf::transform::reorient( translator ); - - // flatten if not noclipped - if ( !stats.noclipped ) { - translator.forward *= { 1, 0, 1 }; - translator.right *= { 1, 0, 1 }; - } + physics.linear.velocity *= { speed.friction, 1, speed.friction }; - translator.forward = uf::vector::normalize( translator.forward ); - translator.right = uf::vector::normalize( translator.right ); - } else - #endif - // un-flatted if noclipped - if ( stats.noclipped ){ - auto& cameraTransform = camera.getTransform(); - translator.forward.y += cameraTransform.forward.y; - translator.forward = uf::vector::normalize( translator.forward ); - } - - // setup desired direction - pod::Vector3f target = {}; - if ( keys.forward ^ keys.backwards ) target += translator.forward * (keys.forward ? 1 : -1); - if ( keys.left ^ keys.right ) target += translator.right * (keys.right ? 1 : -1); - target = uf::vector::normalize( target ); - - physics.linear.velocity *= { speed.friction, 1, speed.friction }; - - stats.walking = (keys.forward ^ keys.backwards) || (keys.left ^ keys.right); - if ( stats.walking ) { - if ( !true && stats.noclipped ) { - physics.linear.velocity = target * speed.move; - } else { - physics.linear.velocity += target * std::clamp( speed.move * (stats.floored ? 1.0f : 0.5f) - uf::vector::dot( physics.linear.velocity, target ), 0.0f, speed.move * 10 * uf::physics::time::delta ); - } - } - if ( !stats.floored ) stats.walking = false; + stats.walking = (keys.forward ^ keys.backwards) || (keys.left ^ keys.right); + if ( stats.walking ) { + float factor = stats.floored || stats.noclipped ? 1.0f : speed.air; + physics.linear.velocity += target * std::clamp( speed.move * factor - uf::vector::dot( physics.linear.velocity, target ), 0.0f, speed.move * 10 * uf::physics::time::delta ); } + if ( !stats.floored ) stats.walking = false; } if ( stats.floored && keys.jump ) { - physics.linear.velocity += metadata.system.physics.jump; + physics.linear.velocity += translator.up * metadata.movement.jump; } if ( keys.crouch ) { - if ( stats.noclipped ) physics.linear.velocity -= metadata.system.physics.jump; + if ( stats.noclipped ) physics.linear.velocity -= translator.up * metadata.movement.jump; else { if ( !metadata.system.crouching ) stats.deltaCrouch = true; metadata.system.crouching = true; @@ -341,20 +331,20 @@ void ext::PlayerBehavior::tick( uf::Object& self ) { if ( keys.lookRight ^ keys.lookLeft ) { #if UF_USE_BULLET - if ( collider.body && !collider.shared ) ext::bullet::applyRotation( collider, transform.up, speed.rotate * (keys.lookRight ? 1 : -1) ); else + if ( collider.body ) ext::bullet::applyRotation( collider, transform.up, speed.rotate * (keys.lookRight ? 1 : -1) ); else #endif - uf::transform::rotate( transform, transform.up, speed.rotate ); + uf::transform::rotate( transform, transform.up, speed.rotate * (keys.lookRight ? 1 : -1) ); } { #if UF_USE_BULLET - if ( collider.body && !collider.shared ) ext::bullet::setVelocity( collider, physics.linear.velocity ); else + if ( collider.body ) ext::bullet::setVelocity( collider, physics.linear.velocity ); else #endif transform.position += physics.linear.velocity * uf::physics::time::delta; } if ( stats.deltaCrouch ) { - float delta = metadata.system.physics.crouch; + float delta = metadata.movement.crouch; if ( metadata.system.crouching ) camera.getTransform().position.y -= delta; else camera.getTransform().position.y += delta; } @@ -450,6 +440,7 @@ void ext::PlayerBehavior::destroy( uf::Object& self ){} void ext::PlayerBehavior::Metadata::serialize( uf::Object& self, uf::Serializer& serializer ){ auto& serializerSystem = serializer["system"]; auto& serializerSystemPhysics = serializerSystem["physics"]; + auto& serializerSystemPhysicsMovement = serializerSystemPhysics["movement"]; auto& serializerAudioFootstep = serializer["audio"]["footstep"]; auto& serializerCamera = serializer["camera"]; auto& serializerCameraLimit = serializerCamera["limit"]; @@ -458,14 +449,14 @@ void ext::PlayerBehavior::Metadata::serialize( uf::Object& self, uf::Serializer& serializerSystem["control"] = /*this->*/system.control; serializerSystem["crouching"] = /*this->*/system.crouching; serializerSystem["noclipped"] = /*this->*/system.noclipped; - serializerSystemPhysics["impulse"] = /*this->*/system.physics.impulse; - serializerSystemPhysics["rotate"] = /*this->*/system.physics.rotate; - serializerSystemPhysics["move"] = /*this->*/system.physics.move; - serializerSystemPhysics["run"] = /*this->*/system.physics.run; - serializerSystemPhysics["walk"] = /*this->*/system.physics.walk; - serializerSystemPhysics["collision"] = /*this->*/system.physics.collision; - serializerSystemPhysics["jump"] = uf::vector::encode(/*this->*/system.physics.jump); - serializerSystemPhysics["crouch"] = /*this->*/system.physics.crouch; + serializerSystemPhysics["friction"] = /*this->*/movement.friction; + serializerSystemPhysicsMovement["rotate"] = /*this->*/movement.rotate; + serializerSystemPhysicsMovement["move"] = /*this->*/movement.move; + serializerSystemPhysicsMovement["run"] = /*this->*/movement.run; + serializerSystemPhysicsMovement["walk"] = /*this->*/movement.walk; + serializerSystemPhysicsMovement["air"] = /*this->*/movement.air; + serializerSystemPhysicsMovement["jump"] = uf::vector::encode(/*this->*/movement.jump); + serializerSystemPhysicsMovement["crouch"] = /*this->*/movement.crouch; serializerAudioFootstep["list"] = /*this->*/audio.footstep.list; serializerAudioFootstep["volume"] = /*this->*/audio.footstep.volume; serializerCamera["invert"] = uf::vector::encode(/*this->*/camera.invert); @@ -477,6 +468,7 @@ void ext::PlayerBehavior::Metadata::deserialize( uf::Object& self, uf::Serialize auto& serializerSystem = serializer["system"]; auto& serializerAudioFootstep = serializer["audio"]["footstep"]; auto& serializerSystemPhysics = serializerSystem["physics"]; + auto& serializerSystemPhysicsMovement = serializerSystemPhysics["movement"]; auto& serializerCamera = serializer["camera"]; auto& serializerCameraLimit = serializerCamera["limit"]; @@ -484,14 +476,14 @@ void ext::PlayerBehavior::Metadata::deserialize( uf::Object& self, uf::Serialize /*this->*/system.control = serializerSystem["control"].as(); /*this->*/system.crouching = serializerSystem["crouching"].as(); /*this->*/system.noclipped = serializerSystem["noclipped"].as(); - /*this->*/system.physics.impulse = serializerSystemPhysics["impulse"].as(); - /*this->*/system.physics.rotate = serializerSystemPhysics["rotate"].as(); - /*this->*/system.physics.move = serializerSystemPhysics["move"].as(); - /*this->*/system.physics.run = serializerSystemPhysics["run"].as(); - /*this->*/system.physics.walk = serializerSystemPhysics["walk"].as(); - /*this->*/system.physics.collision = serializerSystemPhysics["collision"].as(); - /*this->*/system.physics.jump = uf::vector::decode(serializerSystemPhysics["jump"], pod::Vector3f{}); - /*this->*/system.physics.crouch = serializerSystemPhysics["crouch"].as(); + /*this->*/movement.friction = serializerSystemPhysics["friction"].as(); + /*this->*/movement.rotate = serializerSystemPhysicsMovement["rotate"].as(); + /*this->*/movement.move = serializerSystemPhysicsMovement["move"].as(); + /*this->*/movement.run = serializerSystemPhysicsMovement["run"].as(); + /*this->*/movement.walk = serializerSystemPhysicsMovement["walk"].as(); + /*this->*/movement.air = serializerSystemPhysicsMovement["air"].as(); + /*this->*/movement.jump = uf::vector::decode(serializerSystemPhysicsMovement["jump"], pod::Vector3f{}); + /*this->*/movement.crouch = serializerSystemPhysicsMovement["crouch"].as(); ext::json::forEach( serializerAudioFootstep["list"], [&]( const ext::json::Value& value ){ /*this->*/audio.footstep.list.emplace_back(value); }); @@ -501,9 +493,5 @@ void ext::PlayerBehavior::Metadata::deserialize( uf::Object& self, uf::Serialize /*this->*/camera.limit.current = uf::vector::decode( serializerCameraLimit["current"], pod::Vector3f{NAN, NAN, NAN} ); /*this->*/camera.limit.min = uf::vector::decode( serializerCameraLimit["minima"], pod::Vector3f{NAN, NAN, NAN} ); /*this->*/camera.limit.max = uf::vector::decode( serializerCameraLimit["maxima"], pod::Vector3f{NAN, NAN, NAN} ); - -// for ( uint_fast8_t i = 0; i < 3; ++i ) this->camera.limit.current[i] = serializerCameraLimit["current"][i].as(NAN); -// for ( uint_fast8_t i = 0; i < 3; ++i ) this->camera.limit.min[i] = serializerCameraLimit["minima"][i].as(NAN); -// for ( uint_fast8_t i = 0; i < 3; ++i ) this->camera.limit.max[i] = serializerCameraLimit["maxima"][i].as(NAN); } #undef this \ No newline at end of file diff --git a/ext/behaviors/player/behavior.h b/ext/behaviors/player/behavior.h index 75fd27a5..1ed4f6c4 100644 --- a/ext/behaviors/player/behavior.h +++ b/ext/behaviors/player/behavior.h @@ -13,24 +13,21 @@ namespace ext { EXT_BEHAVIOR_DEFINE_FUNCTIONS(); UF_BEHAVIOR_DEFINE_METADATA( struct { - struct { - bool collision = true; - bool impulse = true; - float crouch = -1.0f; - float rotate = 1.0f; - float move = 1.0f; - float run = 1.0f; - float walk = 1.0f; - pod::Vector3f jump = {0,8,0}; - - pod::Vector3f velocity = {0,0,0}; - } physics; - bool control = true; uf::stl::string menu = ""; bool crouching = false; bool noclipped = false; } system; + struct { + float crouch = -1.0f; + float rotate = 1.0f; + float move = 1.0f; + float run = 1.0f; + float walk = 1.0f; + float friction = 0.8f; + float air = 1.0f; + pod::Vector3f jump = {0,8,0}; + } movement; struct { struct { pod::Vector3f current = {NAN, NAN, NAN}; diff --git a/ext/behaviors/scene/behavior.cpp b/ext/behaviors/scene/behavior.cpp index 05430c7e..80e5fec7 100644 --- a/ext/behaviors/scene/behavior.cpp +++ b/ext/behaviors/scene/behavior.cpp @@ -523,7 +523,6 @@ void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Seriali /*this->*/max.textures2D = ext::config["engine"]["scenes"]["textures"]["max"]["2D"].as(/*this->*/max.textures2D); /*this->*/max.texturesCube = ext::config["engine"]["scenes"]["textures"]["max"]["cube"].as(/*this->*/max.texturesCube); /*this->*/max.textures3D = ext::config["engine"]["scenes"]["textures"]["max"]["3D"].as(/*this->*/max.textures3D); - /*this->*/light.max = ext::config["engine"]["scenes"]["lights"]["max"].as(/*this->*/light.max); /*this->*/shadow.enabled = ext::config["engine"]["scenes"]["shadows"]["enabled"].as(true) && serializer["light"]["shadows"].as(true); /*this->*/shadow.samples = ext::config["engine"]["scenes"]["shadows"]["samples"].as(); @@ -532,6 +531,7 @@ void ext::ExtSceneBehavior::Metadata::deserialize( uf::Object& self, uf::Seriali /*this->*/shadow.experimentalMode = ext::config["engine"]["scenes"]["shadows"]["experimental mode"].as(0); /*this->*/light.enabled = ext::config["engine"]["scenes"]["lights"]["enabled"].as(true) && serializer["light"]["should"].as(true); + /*this->*/light.max = ext::config["engine"]["scenes"]["lights"]["max"].as(/*this->*/light.max); /*this->*/light.ambient = uf::vector::decode( serializer["light"]["ambient"], pod::Vector4f{ 1, 1, 1, 1 } ); /*this->*/light.specular = uf::vector::decode( serializer["light"]["specular"], pod::Vector4f{ 1, 1, 1, 1 } ); /*this->*/light.exposure = serializer["light"]["exposure"].as(1.0f); @@ -825,8 +825,6 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, const uf::stl::string auto& graphic = *blitter; if ( !graphic.initialized ) continue; - auto& shader = graphic.material.getShader(isCompute ? "compute" : "fragment"); - uf::stl::vector previousTextures; for ( auto& texture : graphic.material.textures ) previousTextures.emplace_back(texture.image); graphic.material.textures.clear(); @@ -839,11 +837,11 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, const uf::stl::string // trigger an update when we have differing bound texture sizes bool shouldUpdate = metadata.shader.invalidated || graphic.material.textures.size() != previousTextures.size(); for ( uint32_t i = 0; !shouldUpdate && i < previousTextures.size() && i < graphic.material.textures.size(); ++i ) { - if ( previousTextures[i] != graphic.material.textures[i].image ) - shouldUpdate = true; + if ( previousTextures[i] != graphic.material.textures[i].image ) shouldUpdate = true; } if ( shouldUpdate ) graphic.updatePipelines(); + auto& shader = graphic.material.getShader(isCompute ? "compute" : "fragment"); shader.updateBuffer( uniforms, shader.getUniformBuffer("UBO") ); } #endif diff --git a/makefiles/win64.gcc.make b/makefiles/win64.gcc.make index 60a6d23d..126dab6f 100644 --- a/makefiles/win64.gcc.make +++ b/makefiles/win64.gcc.make @@ -2,6 +2,6 @@ ARCH = win64 CDIR = CC = gcc CXX = g++ -OPTIMIZATIONS = -O3 -fstrict-aliasing # -flto +OPTIMIZATIONS = # -fstrict-aliasing # -flto WARNINGS = -g -Wall -Wno-pointer-arith -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++17 $(OPTIMIZATIONS) $(WARNINGS) -fdiagnostics-color=always \ No newline at end of file