changeset 314:325823d1b61e

did: add "playing" query to public API
author Sam <sam@basx.dev>
date Sun, 09 Jul 2023 17:40:46 +0700
parents 210cab7958ab
children 4921ec86dcb4
files src/semicongine/scene.nim
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/scene.nim	Sun Jul 09 17:07:36 2023 +0700
+++ b/src/semicongine/scene.nim	Sun Jul 09 17:40:46 2023 +0700
@@ -52,18 +52,25 @@
   animation.player.stop()
   animation.player.resetPlayer()
 
+func playing*(animation: EntityAnimation): bool =
+  animation.player.playing
+
 func update*(animation: EntityAnimation, dt: float32) =
   animation.player.advance(dt)
 
 func parent(entity: Entity): Entity =
   entity.parent
 
+# TODO: this is wrong: transfrom setter + getter are not "symetric"
 func transform*(entity: Entity): Mat4 =
   result = entity.internal_transform
   for component in entity.components.mvalues:
     if component of EntityAnimation and EntityAnimation(component).player.playing:
       result = result * EntityAnimation(component).player.currentValue
 
+func `transform=`*(entity: Entity, value: Mat4) =
+  entity.internal_transform = value
+
 # TODO: position-setter
 func position*(entity: Entity): Vec3f =
   return entity.transform.col(3)
@@ -71,9 +78,6 @@
 func originalTransform*(entity: Entity): Mat4 =
   entity.internal_transform
 
-func `transform=`*(entity: Entity, value: Mat4) =
-  entity.internal_transform = value
-
 func getModelTransform*(entity: Entity): Mat4 =
   result = entity.transform
   if not entity.parent.isNil: