Prevent cycles with ARC by adding {.cursor.} to all "back" references.

TODO: Use destructors to set all cursors of children objects to `nil`.
This commit is contained in:
Alberto Torres 2024-08-29 00:07:09 +02:00
parent 1557d59d0f
commit 3ff1d663a2

View file

@ -98,7 +98,7 @@ type
GameObject* = ref object of RootObj
# TODO: remove otype
otype*: ObjectType ## private
engine*: MyouEngine ## private
engine* {.cursor.}: MyouEngine ## private
debug*: bool ## private
position*: Vec3
rotation*: Quat
@ -110,12 +110,12 @@ type
object_color*: Vec4
# alpha*: float
matrix_parent_inverse*: Mat4
scene*: Scene
scene* {.cursor.}: Scene
source_scene_name*: string
# data_dir*: string
# dupli_group*: unknown
visible*: bool
parent*: GameObject
parent* {.cursor.}: GameObject
children*: seq[GameObject]
auto_update_matrix*: bool
world_matrix*: Mat4
@ -158,7 +158,8 @@ type
# most fields should be private
MeshData* = ref object
engine*: MyouEngine
engine* {.cursor.}: MyouEngine
# TODO: seq of {.cursor.}s?
users*: seq[GameObject] ## private
hash*: string
varrays*: seq[ArrRef[float32]]
@ -287,8 +288,8 @@ type
# shadows
ShadowManager* = ref object of RootObj
engine*: MyouEngine
light*: Light
engine* {.cursor.}: MyouEngine
light* {.cursor.}: Light
framebuffer*: Framebuffer
texture*: Texture
sampler_type*: string
@ -330,7 +331,7 @@ type
padding3: float32
Scene* = ref object
engine*: MyouEngine
engine* {.cursor.}: MyouEngine
name*: string
enabled*: bool
children*: seq[GameObject]
@ -406,7 +407,7 @@ type
viewport_size*, viewport_size_inv*: Vec2
RenderManager* = ref object
engine*: MyouEngine
engine* {.cursor.}: MyouEngine
initialized*: bool
# temporary_framebuffers*: Table[int, ByteFramebuffer]
render_tick*: int
@ -492,7 +493,7 @@ type
# ubo.nim
UBO* = ref object
renderer*: RenderManager
renderer* {.cursor.}: RenderManager
name*: string
size32*: int
byte_storage*: ArrRef[byte]
@ -529,7 +530,7 @@ type
EsPrecisionHigh
Material* = ref object
engine*: MyouEngine
engine* {.cursor.}: MyouEngine
name*: string
textures*: OrderedTable[string, Texture]
ubos*: seq[UBO]
@ -560,7 +561,7 @@ type
# TODO: choose better names
Shader* = ref object
engine*: MyouEngine # do we need this?
engine* {.cursor.}: MyouEngine # do we need this?
id*: int
program*: GLuint
material*: Material # do we need this?
@ -639,7 +640,7 @@ type
tile_size*: Vec2
Texture* = ref object of RootObj
engine*: MyouEngine
engine* {.cursor.}: MyouEngine
name*: string
storage*: TextureStorage ## private
loaded*: bool
@ -660,7 +661,7 @@ type
DepthTexture
Framebuffer* = ref object of RootObj
engine*: MyouEngine
engine* {.cursor.}: MyouEngine
width*, height*: int
format*: TextureFormat
depth_type*: FramebufferDepthType
@ -752,7 +753,7 @@ type
# loader_base.nim
Loader* = ref object of RootObj
engine*: MyouEngine
engine* {.cursor.}: MyouEngine
shader_library*: string
shader_textures*: Table[string, Texture]
# on_destroy*: OnDestroy
@ -777,7 +778,7 @@ type
Body* = ref object
Screen* = ref object of RootObj
engine*: MyouEngine
engine* {.cursor.}: MyouEngine
width*, height*: int32
orientation*: int8
viewports*: seq[Viewport]