Sha256: ab52d672ae6ed11f6e75d4ff6500ccd6964ae6e1a41f9eb0ec2b27a46ab9488f

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module Joybox
  module Debug
    module Physics

      class << self
        attr_accessor :modes
        attr_accessor :world
        attr_accessor :draw
      end
      
      def draw
        super
        initialize_physics_drawing if @world_symbol.nil?
        draw_physics unless @world_symbol.nil?
      end

      def initialize_physics_drawing
        @world_symbol = self.instance_variables.find do |symbol|
          instance_variable_get(symbol).class == Joybox::Physics::World
        end

        unless @world_symbol.nil?
          @physics_draw = PhysicsDraw.new(Joybox::Debug::Physics.modes)
          instance_variable_get(@world_symbol).setDebugDraw(@physics_draw.draw)
          Joybox::Debug::Physics.world = instance_variable_get(@world_symbol)
          Joybox::Debug::Physics.draw = @physics_draw
        end
      end

      def draw_physics
        ccGLEnableVertexAttribs(KCCVertexAttribFlag_Position)
        kmGLPushMatrix
        instance_variable_get(@world_symbol).drawDebugData
        kmGLPopMatrix
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
joybox-1.1.1 motion/joybox/debug/physics.rb
joybox-1.1.0 motion/joybox/debug/physics.rb