Duct taping a cache bug, added test_object that uses sponza.obj.

This commit is contained in:
2018-06-18 12:17:32 -05:00
parent 8f39c34d54
commit f68c31f87c
4 changed files with 10 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ require_relative "lib/objects/camera"
require_relative "lib/objects/player" require_relative "lib/objects/player"
require_relative "lib/objects/tree" require_relative "lib/objects/tree"
require_relative "lib/objects/skydome" require_relative "lib/objects/skydome"
require_relative "lib/objects/test_object"
require_relative "lib/objects/model_loader" require_relative "lib/objects/model_loader"
require_relative "lib/objects/terrain" require_relative "lib/objects/terrain"

View File

@@ -35,7 +35,7 @@ class IMICFPS
found = false found = false
if CACHE[@type].is_a?(Hash) if CACHE[@type].is_a?(Hash)
if CACHE[@type][@file_path] if CACHE[@type][@file_path]
@model = CACHE[@type][@file_path] @model = CACHE[@type][@file_path].dup # Don't know why, but adding .dup improves performance with Sponza (1 fps -> 20 fps)
puts "Used cached model for: #{@file_path.split('/').last}" puts "Used cached model for: #{@file_path.split('/').last}"
found = true found = true
end end

View File

@@ -0,0 +1,7 @@
class IMICFPS
class TestObject < GameObject
def setup
bind_model(ModelLoader.new(type: :obj, file_path: "objects/sponza.obj", game_object: self))
end
end
end

View File

@@ -24,6 +24,7 @@ class IMICFPS
Tree.new(x: 1, y: 0, z: -5) Tree.new(x: 1, y: 0, z: -5)
Tree.new(x: 5, y: 0, z: 5) Tree.new(x: 5, y: 0, z: 5)
Tree.new(x: -5, y: 0, z: 1) Tree.new(x: -5, y: 0, z: 1)
TestObject.new(scale: 1)
p ObjectManager.objects.map {|o| o.name} p ObjectManager.objects.map {|o| o.name}
# Model.new(type: :obj, file_path: "objects/tree.obj", z: -5) # Model.new(type: :obj, file_path: "objects/tree.obj", z: -5)
# Model.new(type: :obj, file_path: "objects/tree.obj", x: -2, z: -6) # Model.new(type: :obj, file_path: "objects/tree.obj", x: -2, z: -6)