Sha256: b13ea1497eb4b8ebb8ac8ec54e891efc2ce5283b57105aeea8691e462cf4cf9f

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

module GameMachine
  module Navigation
    class DetourNavmesh

      def self.meshes
        if @meshes
          @meshes
        else
          @meshes = java.util.concurrent.ConcurrentHashMap.new
        end
      end

      def self.create(id,meshfile)
        if meshes.has_key?(id)
          return false
        end
        meshes[id] = new(id,meshfile)
      end

      def self.find(id)
        meshes.fetch(id,nil)
      end

      attr_reader :id, :meshfile, :loaded
      def initialize(id,meshfile)
        @id = id
        @meshfile = meshfile
        unless File.exists?(meshfile)
          raise "Navigation mesh file does not exist (#{meshfile})"
        end
        @loaded = false
      end

      def loaded?
        loaded
      end

      def load_mesh!
        if loaded?
          raise "DetourNavmesh #{id} already loaded"
        end

        load_res = Detour.loadNavMesh(id,meshfile)
        unless load_res == 1
          raise "DetourNavmesh #{id} failed to load (#{load_res})"
        end
        @loaded = true
        load_res
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
game_machine-1.0.4 lib/game_machine/navigation/detour_navmesh.rb
game_machine-1.0.2 lib/game_machine/navigation/detour_navmesh.rb
game_machine-0.0.11 lib/game_machine/navigation/detour_navmesh.rb
game_machine-0.0.10 lib/game_machine/navigation/detour_navmesh.rb
game_machine-0.0.9 lib/game_machine/navigation/detour_navmesh.rb
game_machine-0.0.8 lib/game_machine/navigation/detour_navmesh.rb