Remove elvis and replace remaining nimble dependencies by git submodules.
This commit is contained in:
parent
addaf2a9e2
commit
f1768275f4
13 changed files with 45 additions and 59 deletions
6
.gitmodules
vendored
6
.gitmodules
vendored
|
@ -7,3 +7,9 @@
|
||||||
[submodule "libs/stb_image_nim"]
|
[submodule "libs/stb_image_nim"]
|
||||||
path = libs/stb_image_nim
|
path = libs/stb_image_nim
|
||||||
url = https://gitlab.com/kungfoobar/stb_image-Nim.git
|
url = https://gitlab.com/kungfoobar/stb_image-Nim.git
|
||||||
|
[submodule "libs/tinyre"]
|
||||||
|
path = libs/tinyre
|
||||||
|
url = https://github.com/khchen/tinyre
|
||||||
|
[submodule "libs/nglfw"]
|
||||||
|
path = libs/nglfw
|
||||||
|
url = https://github.com/DiThi/nglfw
|
||||||
|
|
1
libs/nglfw
Submodule
1
libs/nglfw
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 4ffed95fde502a86fd694b99e755300984d13ae1
|
|
@ -1,3 +0,0 @@
|
||||||
import ../pixie/src/pixie
|
|
||||||
export pixie
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 84589810078f5b9ca85b510393e0cf1364481e65
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 11e49d00741d755e5bbc940cea8c98e16713653f
|
Subproject commit 57212e9dccd0bc4506a34101d69c32565eefa8fc
|
1
libs/tinyre
Submodule
1
libs/tinyre
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 77469f58916369bc3863194cabb05238577fb257
|
|
@ -61,7 +61,6 @@ proc use*(self: Shader): GLuint {.inline,discardable.}
|
||||||
proc destroy*(self: Shader)
|
proc destroy*(self: Shader)
|
||||||
# End forward declarations
|
# End forward declarations
|
||||||
|
|
||||||
import elvis
|
|
||||||
import tinyre
|
import tinyre
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import std/strformat
|
import std/strformat
|
||||||
|
@ -439,13 +438,13 @@ proc initShader*(self: Shader, engine: MyouEngine, material: Material,
|
||||||
glDeleteShader(fragment_shader)
|
glDeleteShader(fragment_shader)
|
||||||
if "ERROR: 0:" in gl_log:
|
if "ERROR: 0:" in gl_log:
|
||||||
# Show engine for first error
|
# Show engine for first error
|
||||||
let line = error_msg.split(":")[2].parseInt ?: 0
|
let line = try: error_msg.split(":")[2].parseInt except: 0
|
||||||
# TODO: show only 4 lines of engine but also the previous
|
# TODO: show only 4 lines of engine but also the previous
|
||||||
# line without indent to know which function it is
|
# line without indent to know which function it is
|
||||||
for i in max(1, line - 1000) ..< min(line + 4, lines.len):
|
for i in max(1, line - 1000) ..< min(line + 4, lines.len):
|
||||||
console_error(&"{i} {lines[i - 1]}")
|
console_error(&"{i} {lines[i - 1]}")
|
||||||
elif gl_log.startsWith "0(":
|
elif gl_log.startsWith "0(":
|
||||||
let line = error_msg.split({'(',')'})[1].parseInt ?: 0
|
let line = try: error_msg.split({'(',')'})[1].parseInt except: 0
|
||||||
for i in max(1, line - 1000) ..< min(line + 4, lines.len):
|
for i in max(1, line - 1000) ..< min(line + 4, lines.len):
|
||||||
console_error(&"{i} {lines[i - 1]}")
|
console_error(&"{i} {lines[i - 1]}")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -51,7 +51,6 @@ proc draw_cubemap*(self: RenderManager, scene: Scene, cubemap_fb: Framebuffer, c
|
||||||
proc get_render_uniform_blocks*(): string
|
proc get_render_uniform_blocks*(): string
|
||||||
# End forward declarations
|
# End forward declarations
|
||||||
|
|
||||||
import elvis
|
|
||||||
import std/algorithm
|
import std/algorithm
|
||||||
import std/options
|
import std/options
|
||||||
import std/strformat
|
import std/strformat
|
||||||
|
@ -266,7 +265,7 @@ proc draw_mesh*(self: RenderManager, mesh: Mesh, mesh2world: Mat4, cam_data: Ren
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var mat = if material_override == nil:
|
var mat = if material_override == nil:
|
||||||
amesh.materials.get_or_default(submesh_idx) ?: self.no_material
|
amesh.materials.get_or_default(submesh_idx, self.no_material)
|
||||||
else:
|
else:
|
||||||
material_override
|
material_override
|
||||||
|
|
||||||
|
@ -417,7 +416,10 @@ proc draw_quad*(self: RenderManager, material: Material, scene: Scene, cam_data:
|
||||||
|
|
||||||
proc draw_viewport*(self: RenderManager, viewport: Viewport, rect: (int32,int32,int32,int32), dest_buffer: Framebuffer, passes: seq[int]) =
|
proc draw_viewport*(self: RenderManager, viewport: Viewport, rect: (int32,int32,int32,int32), dest_buffer: Framebuffer, passes: seq[int]) =
|
||||||
# Configure camera data
|
# Configure camera data
|
||||||
let cam = viewport.debug_camera ?: viewport.camera
|
let cam = if viewport.debug_camera.nonNil:
|
||||||
|
viewport.debug_camera
|
||||||
|
else:
|
||||||
|
viewport.camera
|
||||||
let scene = cam.scene
|
let scene = cam.scene
|
||||||
if self.was_right_eye != viewport.is_right_eye:
|
if self.was_right_eye != viewport.is_right_eye:
|
||||||
self.was_right_eye = viewport.is_right_eye
|
self.was_right_eye = viewport.is_right_eye
|
||||||
|
@ -523,7 +525,7 @@ proc draw_viewport*(self: RenderManager, viewport: Viewport, rect: (int32,int32,
|
||||||
idx = idx shr 1
|
idx = idx shr 1
|
||||||
idx = num_meshes - idx - 1
|
idx = num_meshes - idx - 1
|
||||||
let ob = scene.mesh_passes[1][idx]
|
let ob = scene.mesh_passes[1][idx]
|
||||||
# (ob.last_lod[cam_name].?mesh ? ob).sort_faces(cam_pos)
|
# TODO: LoDs
|
||||||
ob.sort_faces(cam_pos)
|
ob.sort_faces(cam_pos)
|
||||||
for ob in scene.mesh_passes[1]:
|
for ob in scene.mesh_passes[1]:
|
||||||
if ob.visible:
|
if ob.visible:
|
||||||
|
|
|
@ -110,8 +110,6 @@ method get_armature*(self: GameObject): Armature {.base.} =
|
||||||
# End forward declarations and ob type methods
|
# End forward declarations and ob type methods
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import elvis
|
|
||||||
|
|
||||||
import std/math
|
import std/math
|
||||||
import std/tables
|
import std/tables
|
||||||
import ../incomplete
|
import ../incomplete
|
||||||
|
@ -120,22 +118,6 @@ import ../graphics/ubo
|
||||||
import ../scene
|
import ../scene
|
||||||
import ./mesh
|
import ./mesh
|
||||||
|
|
||||||
# Alternative to ob type methods using templates instead
|
|
||||||
# TODO: use or delete
|
|
||||||
|
|
||||||
# template is_camera*(self: GameObject): bool = ?self and self.otype == TCamera
|
|
||||||
# template is_light*(self: GameObject): bool = ?self and self.otype == TLight
|
|
||||||
# template is_mesh*(self: GameObject): bool = ?self and self.otype == TMesh
|
|
||||||
# template is_armature*(self: GameObject): bool = ?self and self.otype == TArmature
|
|
||||||
# template get_camera*(self: GameObject): Camera =
|
|
||||||
# if ?self and self.otype == TCamera: cast[Camera](self) else: nil
|
|
||||||
# template get_light*(self: GameObject): Light =
|
|
||||||
# if ?self and self.otype == TLight: cast[Light](self) else: nil
|
|
||||||
# template get_mesh*(self: GameObject): Mesh =
|
|
||||||
# if ?self and self.otype == TMesh: cast[Mesh](self) else: nil
|
|
||||||
# template get_armature*(self: GameObject): Armature =
|
|
||||||
# if ?self and self.otype == TArmature: cast[Armature](self) else: nil
|
|
||||||
|
|
||||||
proc initGameObject*(self: GameObject, engine: MyouEngine, name: string="", scene: Scene=nil): GameObject =
|
proc initGameObject*(self: GameObject, engine: MyouEngine, name: string="", scene: Scene=nil): GameObject =
|
||||||
# Remember to add any new mutable reference to clone()
|
# Remember to add any new mutable reference to clone()
|
||||||
self.engine = engine
|
self.engine = engine
|
||||||
|
@ -500,7 +482,7 @@ iterator children_recursive*(self: GameObject, include_self: static[bool] = fals
|
||||||
break
|
break
|
||||||
|
|
||||||
proc remove*(self: GameObject, recursive: bool = true) =
|
proc remove*(self: GameObject, recursive: bool = true) =
|
||||||
if ?self.scene:
|
if self.scene.nonNil:
|
||||||
self.scene.remove_object(self, recursive)
|
self.scene.remove_object(self, recursive)
|
||||||
|
|
||||||
proc destroy*(self: GameObject, recursive: bool = true) =
|
proc destroy*(self: GameObject, recursive: bool = true) =
|
||||||
|
|
|
@ -52,8 +52,6 @@ proc ensure_capacity*(self: Mesh, extra_elements: int)
|
||||||
proc write_vaos*(self: MeshData)
|
proc write_vaos*(self: MeshData)
|
||||||
# End forward declarations and ob type methods
|
# End forward declarations and ob type methods
|
||||||
|
|
||||||
import elvis
|
|
||||||
import ../quat
|
|
||||||
|
|
||||||
import std/algorithm
|
import std/algorithm
|
||||||
# import std/sequtils
|
# import std/sequtils
|
||||||
|
@ -65,6 +63,7 @@ import ./gameobject
|
||||||
import ../scene
|
import ../scene
|
||||||
import ../util
|
import ../util
|
||||||
import ../attributes
|
import ../attributes
|
||||||
|
import ../quat
|
||||||
|
|
||||||
export arr_ref
|
export arr_ref
|
||||||
export tables
|
export tables
|
||||||
|
@ -167,7 +166,7 @@ proc gpu_buffers_upload*(self: MeshData) =
|
||||||
if not had_indices:
|
if not had_indices:
|
||||||
self.num_indices.add(num_indices.int32)
|
self.num_indices.add(num_indices.int32)
|
||||||
elif not had_indices:
|
elif not had_indices:
|
||||||
self.num_indices.add((buffer_size div (self.stride ?: 0)).int32)
|
self.num_indices.add((buffer_size div self.stride).int32)
|
||||||
self.index_buffers.add(ib)
|
self.index_buffers.add(ib)
|
||||||
if self.use_tf:
|
if self.use_tf:
|
||||||
self.tf_vbos.setLen 2
|
self.tf_vbos.setLen 2
|
||||||
|
@ -405,10 +404,7 @@ proc load_from_va_ia*(self: Mesh,
|
||||||
|
|
||||||
if self.data != nil:
|
if self.data != nil:
|
||||||
self.data.remove(self)
|
self.data.remove(self)
|
||||||
# if @hash and (@data = @engine.mesh_datas[@hash])?
|
# TODO: hash meshes to reuse existing copies automatically
|
||||||
# @data.users.push @
|
|
||||||
# @engine.main_loop?.reset_timeout()
|
|
||||||
# return
|
|
||||||
var data = newMeshData(self.engine)
|
var data = newMeshData(self.engine)
|
||||||
when defined(myouUseRenderdoc):
|
when defined(myouUseRenderdoc):
|
||||||
data.name = self.name
|
data.name = self.name
|
||||||
|
@ -460,14 +456,14 @@ proc load_from_va_ia*(self: Mesh,
|
||||||
|
|
||||||
proc add_modifier*(self: Mesh, modifier: VertexModifier) =
|
proc add_modifier*(self: Mesh, modifier: VertexModifier) =
|
||||||
self.vertex_modifiers.add(modifier)
|
self.vertex_modifiers.add(modifier)
|
||||||
if ?modifier.prepare_mesh and ?self.data:
|
if modifier.prepare_mesh.nonNil and self.data.nonNil:
|
||||||
echo &"applying modifiers of {self.name} after it was already loaded"
|
echo &"applying modifiers of {self.name} after it was already loaded"
|
||||||
modifier.prepare_mesh(self)
|
modifier.prepare_mesh(self)
|
||||||
# self.update_signature()
|
# self.update_signature()
|
||||||
|
|
||||||
proc insert_modifier*(self: Mesh, index: int, modifier: VertexModifier) =
|
proc insert_modifier*(self: Mesh, index: int, modifier: VertexModifier) =
|
||||||
self.vertex_modifiers.insert(modifier, index)
|
self.vertex_modifiers.insert(modifier, index)
|
||||||
if ?modifier.prepare_mesh and ?self.data:
|
if modifier.prepare_mesh.nonNil and self.data.nonNil:
|
||||||
echo &"applying modifiers of {self.name} after it was already loaded"
|
echo &"applying modifiers of {self.name} after it was already loaded"
|
||||||
modifier.prepare_mesh(self)
|
modifier.prepare_mesh(self)
|
||||||
# self.update_signature()
|
# self.update_signature()
|
||||||
|
@ -483,7 +479,7 @@ proc remove_modifier*(self: Mesh, modifier: VertexModifier) =
|
||||||
|
|
||||||
proc clone_impl*(self: Mesh, clone: Mesh): Mesh =
|
proc clone_impl*(self: Mesh, clone: Mesh): Mesh =
|
||||||
clone.last_lod.clear()
|
clone.last_lod.clear()
|
||||||
if ?clone.data:
|
if clone.data.nonNil:
|
||||||
clone.data.users.add(clone)
|
clone.data.users.add(clone)
|
||||||
return clone
|
return clone
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
import ../types
|
import ../types
|
||||||
import vmath except Quat
|
import vmath except Quat
|
||||||
|
|
||||||
import staticglfw as glfw
|
import nglfw as glfw
|
||||||
type Window* = glfw.Window
|
type Window* = glfw.Window
|
||||||
|
|
||||||
# proc make_window*(width, height: int32, title: string): Window
|
# proc make_window*(width, height: int32, title: string): Window
|
||||||
|
@ -154,7 +154,7 @@ proc init_graphics*(engine: MyouEngine, width, height: int32, title: string,
|
||||||
# TODO!! Option to delay this to simulate the situation in mobile platforms
|
# TODO!! Option to delay this to simulate the situation in mobile platforms
|
||||||
|
|
||||||
# Init GLFW
|
# Init GLFW
|
||||||
if glfw.init() == 0:
|
if not glfw.init():
|
||||||
raise newException(Exception, "Failed to Initialize GLFW")
|
raise newException(Exception, "Failed to Initialize GLFW")
|
||||||
|
|
||||||
let major = opengl_version div 100
|
let major = opengl_version div 100
|
||||||
|
@ -209,12 +209,12 @@ var current_screen: Screen
|
||||||
|
|
||||||
proc platform_switch_screen*(screen: Screen): bool {.inline.} =
|
proc platform_switch_screen*(screen: Screen): bool {.inline.} =
|
||||||
if current_screen != screen:
|
if current_screen != screen:
|
||||||
screen.window.makeContextCurrent()
|
cast[Window](screen.window).makeContextCurrent()
|
||||||
current_screen = screen
|
current_screen = screen
|
||||||
return true
|
return true
|
||||||
|
|
||||||
# proc platform_swap_buffers*(screen: Screen) {.inline.} =
|
# proc platform_swap_buffers*(screen: Screen) {.inline.} =
|
||||||
# screen.window.swapBuffers()
|
# cast[Window](screen.window).swapBuffers()
|
||||||
|
|
||||||
proc start_platform_main_loop*(engine: MyouEngine, main_loop: proc(self: MyouEngine)) =
|
proc start_platform_main_loop*(engine: MyouEngine, main_loop: proc(self: MyouEngine)) =
|
||||||
while windows.len != 0:
|
while windows.len != 0:
|
||||||
|
@ -231,4 +231,4 @@ proc start_platform_main_loop*(engine: MyouEngine, main_loop: proc(self: MyouEng
|
||||||
glfw.terminate()
|
glfw.terminate()
|
||||||
|
|
||||||
proc myouAndroidGetActivity*(): pointer =
|
proc myouAndroidGetActivity*(): pointer =
|
||||||
assert false, "Not using Android"
|
assert false, "Not using Android"
|
||||||
|
|
|
@ -64,7 +64,6 @@ proc render_all_cubemaps*(self: Scene, use_roughness_prefiltering: bool, mipmap_
|
||||||
|
|
||||||
import vmath except Quat
|
import vmath except Quat
|
||||||
import ./quat
|
import ./quat
|
||||||
import elvis
|
|
||||||
import std/algorithm
|
import std/algorithm
|
||||||
import std/math
|
import std/math
|
||||||
import std/options
|
import std/options
|
||||||
|
@ -163,13 +162,13 @@ proc add_object*(self: Scene, ob: GameObject,
|
||||||
ob.parent = p
|
ob.parent = p
|
||||||
p.children.add(ob)
|
p.children.add(ob)
|
||||||
var armature = p.get_armature
|
var armature = p.get_armature
|
||||||
if ?armature and ?parent_bone:
|
if armature.nonNil and parent_bone != "":
|
||||||
var bone = armature.bones[parent_bone]
|
var bone = armature.bones[parent_bone]
|
||||||
if ?bone:
|
if bone.nonNil:
|
||||||
ob.parent_bone_index = armature.bone_list.find(bone)
|
ob.parent_bone_index = armature.bone_list.find(bone)
|
||||||
bone.object_children.add(ob)
|
bone.object_children.add(ob)
|
||||||
var mesh = ob.get_mesh
|
var mesh = ob.get_mesh
|
||||||
if ?mesh:
|
if mesh.nonNil:
|
||||||
# TODO: not having number of passes hardcoded
|
# TODO: not having number of passes hardcoded
|
||||||
for p in 0'i32 .. 2:
|
for p in 0'i32 .. 2:
|
||||||
if p in mesh.passes:
|
if p in mesh.passes:
|
||||||
|
@ -196,12 +195,12 @@ proc remove_object*(self: Scene, ob: GameObject, recursive: bool = true) =
|
||||||
self.objects.del(ob.name)
|
self.objects.del(ob.name)
|
||||||
self.parents.del(ob.original_name)
|
self.parents.del(ob.original_name)
|
||||||
var mesh = ob.get_mesh
|
var mesh = ob.get_mesh
|
||||||
if ?mesh:
|
if mesh.nonNil:
|
||||||
self.mesh_passes[0].remove mesh
|
self.mesh_passes[0].remove mesh
|
||||||
self.mesh_passes[1].remove mesh
|
self.mesh_passes[1].remove mesh
|
||||||
self.fg_pass.remove mesh
|
self.fg_pass.remove mesh
|
||||||
self.bg_pass.remove mesh
|
self.bg_pass.remove mesh
|
||||||
if ?mesh.data:
|
if mesh.data.nonNil:
|
||||||
mesh.data.remove(mesh)
|
mesh.data.remove(mesh)
|
||||||
elif ob.is_camera:
|
elif ob.is_camera:
|
||||||
for screen in self.engine.screens:
|
for screen in self.engine.screens:
|
||||||
|
@ -217,9 +216,9 @@ proc remove_object*(self: Scene, ob: GameObject, recursive: bool = true) =
|
||||||
self.lights.remove light
|
self.lights.remove light
|
||||||
elif ob.is_armature:
|
elif ob.is_armature:
|
||||||
self.armatures.remove ob.get_armature
|
self.armatures.remove ob.get_armature
|
||||||
if ob.parent_bone_index != -1 and ?ob.parent:
|
if ob.parent_bone_index != -1 and ob.parent.nonNil:
|
||||||
var ar = ob.parent.get_armature
|
var ar = ob.parent.get_armature
|
||||||
if ?ar and ar.bone_list.len > ob.parent_bone_index:
|
if ar.nonNil and ar.bone_list.len > ob.parent_bone_index:
|
||||||
ar.bone_list[ob.parent_bone_index].object_children.remove ob
|
ar.bone_list[ob.parent_bone_index].object_children.remove ob
|
||||||
ob.body.destroy()
|
ob.body.destroy()
|
||||||
# TODO: Remove probes if they have no users
|
# TODO: Remove probes if they have no users
|
||||||
|
@ -235,7 +234,7 @@ proc remove_object*(self: Scene, ob: GameObject, recursive: bool = true) =
|
||||||
proc make_parent*(self: Scene, parent: GameObject, child: GameObject,
|
proc make_parent*(self: Scene, parent: GameObject, child: GameObject,
|
||||||
keep_transform: bool = true) =
|
keep_transform: bool = true) =
|
||||||
assert parent != nil and child != nil, "Arguments 'parent' and 'child' can't be nil."
|
assert parent != nil and child != nil, "Arguments 'parent' and 'child' can't be nil."
|
||||||
if ?child.parent:
|
if child.parent.nonNil:
|
||||||
self.clear_parent(child, keep_transform)
|
self.clear_parent(child, keep_transform)
|
||||||
# TODO: should we store the index in the objects
|
# TODO: should we store the index in the objects
|
||||||
# to make this check faster?
|
# to make this check faster?
|
||||||
|
@ -313,7 +312,7 @@ proc reorder_children*(self: Scene) =
|
||||||
reorder(c)
|
reorder(c)
|
||||||
|
|
||||||
for ob in self.children:
|
for ob in self.children:
|
||||||
if ?ob.parent:
|
if ob.parent.nonNil:
|
||||||
continue
|
continue
|
||||||
reorder(ob)
|
reorder(ob)
|
||||||
self.children_are_ordered = true
|
self.children_are_ordered = true
|
||||||
|
@ -382,9 +381,10 @@ proc new_mesh*(self: Scene, name: string,
|
||||||
proc set_active_camera*(self: Scene, camera: Camera) =
|
proc set_active_camera*(self: Scene, camera: Camera) =
|
||||||
self.active_camera = camera
|
self.active_camera = camera
|
||||||
if camera.scene != self:
|
if camera.scene != self:
|
||||||
self.add_object(camera, camera.name ?: "Camera")
|
let name = if camera.name != "": camera.name else: "Camera"
|
||||||
|
self.add_object(camera, name)
|
||||||
if self.add_viewport_automatically:
|
if self.add_viewport_automatically:
|
||||||
if not ?self.engine.screens[0].viewports:
|
if self.engine.screens[0].viewports.len == 0:
|
||||||
self.engine.screens[0].add_viewport(camera)
|
self.engine.screens[0].add_viewport(camera)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -96,9 +96,10 @@ func align*[T: SomeInteger](n, align: T): T =
|
||||||
|
|
||||||
func bytelen*[T](s: seq[T]): int = s.len * sizeof(T)
|
func bytelen*[T](s: seq[T]): int = s.len * sizeof(T)
|
||||||
|
|
||||||
func get_or_default*[T](s: seq[T], i: int): T =
|
func get_or_default*[T](s: seq[T], i: int, default: T = T.default): T =
|
||||||
if i >= s.low and i <= s.high:
|
if i >= s.low and i <= s.high:
|
||||||
return s[i]
|
return s[i]
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
|
@ -229,3 +230,5 @@ template staticOrDebugRead*(path: string): string =
|
||||||
readFile dir & path
|
readFile dir & path
|
||||||
else:
|
else:
|
||||||
staticRead path
|
staticRead path
|
||||||
|
|
||||||
|
template nonNil*(x: untyped): bool = x != nil
|
||||||
|
|
Loading…
Reference in a new issue