-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added initial lua scripting component using sol2 library * Added external file script support with hot reload * Improved scripting, added serialization for scripts * Added exported property support for lua scripts * Should fix the resulting merge issues * Moved lua state into LuaScriptManager * Script properties are now serialized * More bindings and fixes * Push script as well * More script bindings * Attempt to fix build issues * Many bug fixes related to/uncovered by scripting * Fixed a bunch of issues + no more autosave * Many adjustments * Update thirdparty license file * Smaller fixes * Smaller adjustments * Update build.yml * Some improvements * Fixed the import of a scene from mesh * Improved CPU performance for scenes with many meshes * More performance improvements * Graphics queue submission can now be done async * Fixed the pipeline again + more improvements * Fixed many issues * Keyboard bindings for lua * Fix code smells and scene * More changes and an ongoing investigation into Vulkan queues * Fixed some synchronization/threading issues * Even more fixes * Many fixes and improvements * Trying to find out why artifacts won't run * Fix build pipeline issue * Final updates * More fixes --------- Co-authored-by: Simon Tippe <[email protected]>
- Loading branch information
Showing
185 changed files
with
4,701 additions
and
1,527 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,6 @@ data/emissive mesh | |
data/flying world | ||
data/living room | ||
data/mis | ||
data/ancient | ||
data/farm | ||
data/town |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
-- This is a comment | ||
|
||
ScriptProperties = { | ||
animationLength = { type = "double", value = 30.0 }, | ||
animationActive = { type = "boolean", value = false } | ||
} | ||
|
||
animationTime = 0.0 | ||
|
||
function Update(delta) | ||
|
||
local entity = GetThisEntity() | ||
local scene = GetThisScene() | ||
|
||
if scene:HasMainCamera() ~= true or ScriptProperties.animationActive.value ~= true then | ||
return | ||
end | ||
|
||
local camera = scene:GetMainCamera() | ||
local hierarchy = entity:GetHierarchyComponent() | ||
|
||
local children = hierarchy:GetChildren() | ||
|
||
if children == nil then | ||
return | ||
end | ||
|
||
if #children <= 1 then | ||
return | ||
end | ||
|
||
animationTime = animationTime + Atlas.Clock.GetDelta() | ||
|
||
local animationProgress = animationTime / ScriptProperties.animationLength.value | ||
if animationProgress >= 1.0 then | ||
return | ||
end | ||
|
||
local childProgress = animationProgress * (#children - 1.0) | ||
|
||
local lowerChildIndex = math.floor(childProgress) | ||
local upperChildIndex = math.ceil(childProgress) | ||
local childFraction = childProgress - lowerChildIndex | ||
|
||
local lowerChildEntity = children[lowerChildIndex + 1] | ||
local upperChildEntity = children[upperChildIndex + 1] | ||
|
||
local lowerChildCamera = lowerChildEntity:GetCameraComponent() | ||
local upperChildCamera = upperChildEntity:GetCameraComponent() | ||
|
||
camera.location = Glm.Mix(lowerChildCamera:GetLocation(), upperChildCamera:GetLocation(), childFraction) | ||
camera.rotation = Glm.Mix(lowerChildCamera.rotation, upperChildCamera.rotation, childFraction) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
-- This is a comment | ||
|
||
ScriptProperties = { | ||
spawnEntityName = { type = "string", value = "" }, | ||
spawnRate = { type = "double", value = 1.0 } | ||
} | ||
|
||
lastSpawn = 0.0 | ||
|
||
function Update(delta) | ||
|
||
local entity = GetThisEntity() | ||
local scene = GetThisScene() | ||
local spawnEntity = scene:GetEntityByName(ScriptProperties.spawnEntityName.value) | ||
|
||
if not spawnEntity:IsValid() then | ||
return | ||
end | ||
|
||
transform = entity:GetTransformComponent() | ||
|
||
spawnTransform = spawnEntity:GetTransformComponent() | ||
spawnRigidBody = spawnEntity:GetRigidBodyComponent() | ||
|
||
if spawnTransform == nil or spawnRigidBody == nil or transform == nil then | ||
return | ||
end | ||
|
||
local time = Atlas.Clock.Get() | ||
local spawnFraction = 1.0 / ScriptProperties.spawnRate.value | ||
|
||
if time - lastSpawn > spawnFraction then | ||
local decomp = Atlas.MatrixDecomposition(transform.globalMatrix) | ||
|
||
local spawnCenter = decomp.translation | ||
|
||
local deg = math.random(0.0, 1.0) * 2.0 * 3.14159 | ||
local dist = math.random(0.0, 1.0) + math.random(0.0, 1.0) | ||
|
||
if dist > 1.0 then | ||
dist = 2.0 - dist | ||
end | ||
|
||
local dir = Glm.Vec3(math.cos(deg), 0.0, math.sin(deg)) * dist * 5.0 | ||
|
||
local spawnPoint = dir + spawnCenter | ||
local matrix = Glm.Translate(spawnPoint) | ||
|
||
local newEntity = scene:DuplicateEntity(spawnEntity) | ||
|
||
local newTransform = newEntity:GetTransformComponent() | ||
local newRigidBody = newEntity:GetRigidBodyComponent() | ||
|
||
newRigidBody:SetLinearVelocity(dir) | ||
newTransform:Set(matrix) | ||
|
||
lastSpawn = time | ||
|
||
Atlas.Log.Warning("New spawn") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- This is a comment | ||
|
||
ScriptProperties = { | ||
duplicateEntityName = { type = "string", value = "" } | ||
} | ||
|
||
function Update(delta) | ||
entity = GetThisEntity() | ||
|
||
transform = entity:GetTransformComponent() | ||
rigidBody = entity:GetRigidBodyComponent() | ||
|
||
local time = Atlas.Clock.Get() | ||
|
||
local offset = Glm.Vec3(0.0, math.sin(time), 0.0) + Glm.Vec3(0.0, 5.0, 0.0) | ||
local matrix = Glm.Translate(offset) | ||
|
||
Atlas.Log.Warning(tostring(offset.y)) | ||
|
||
transform:Set(matrix) | ||
|
||
-- ~= is equal to != in most other languages | ||
if rigidBody ~= nil then | ||
rigidBody:SetLinearVelocity(Glm.Vec3(0.0)) | ||
rigidBody:SetAngularVelocity(Glm.Vec3(0.0)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- This is a comment | ||
|
||
ScriptProperties = { | ||
spawnEntityName = { type = "string", value = "" }, | ||
spawnRate = { type = "double", value = 1.0 } | ||
} | ||
|
||
lastSpawn = 0.0 | ||
|
||
function Update(delta) | ||
|
||
-- Only update the player rotation if there is input | ||
local playerInput = (Atlas.KeyboardMap.IsKeyPressed(Atlas.Keycode.KeyW, true) or | ||
Atlas.KeyboardMap.IsKeyPressed(Atlas.Keycode.KeyA, true) or | ||
Atlas.KeyboardMap.IsKeyPressed(Atlas.Keycode.KeyS, true) or | ||
Atlas.KeyboardMap.IsKeyPressed(Atlas.Keycode.KeyD, true)) | ||
|
||
if playerInput ~= true then | ||
return | ||
end | ||
|
||
local entity = GetThisEntity() | ||
local scene = GetThisScene() | ||
|
||
local camera = entity:GetCameraComponent() | ||
local transform = entity:GetTransformComponent() | ||
local player = entity:GetPlayerComponent() | ||
|
||
local rotationMatrix = Glm.Rotate(Glm.Mat4(1.0), camera.rotation.x, Glm.Vec3(0.0, 1.0, 0.0)) | ||
local recomposed = Atlas.MatrixDecomposition(rotationMatrix) | ||
|
||
player:SetRotation(Glm.Quat(recomposed.rotation)) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.