Class: ODE::Space

Inherits:
Object
  • Object
show all
Includes:
ObjectID
Defined in:
lib/ode.rb

Direct Known Subclasses

HashSpace, QuadTreeSpace, SimpleSpace

Instance Attribute Summary

Attributes included from ObjectID

#id

Instance Method Summary collapse

Methods included from ObjectID

by_id, #initialize, #method_missing, set_by_id

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ODE::ObjectID

Instance Method Details

#collide(*args, &block) ⇒ Object



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/ode.rb', line 368

def collide(*args, &block)
  if (block_given?)
	raise "Wrong number of arguments to Space#collide (#{args.length} for 0)" unless (args.length == 0)
  else
	raise "Wrong number of arguments to Space#collide (#{args.length} for 1)" unless (args.length == 1)
	raise "Space#collide needs a block or a proc!" unless (args[0].kind_of?(Proc))
	block = args[0]
  end
  ODE.dSpaceCollide(@id,
    Proc.new { |o1id, o2id|
#	  puts "o1id = #{o1id} o2id = #{o2id}" 
	  o1, o2 = ObjectID.by_id(o1id), ObjectID.by_id(o2id)
      block.call(o1,o2)
	} )
end

#collide2(other_geom, *args, &block) ⇒ Object



384
385
386
387
388
389
390
391
392
393
# File 'lib/ode.rb', line 384

def collide2(other_geom, *args, &block)
  if (block_given?)
	raise "Wrong number of arguments to Space#collide (#{args.length + 1} for 1)" unless (args.length == 0)
  else
	raise "Wrong number of arguments to Space#collide (#{args.length + 1} for 2)" unless (args.length == 1)
	raise "Space#collide needs a block or a proc!" unless (args[0].kind_of?(Proc))
	block = args[0]
  end
  ODE.dSpaceCollide2(@id, other_geom.id, Proc.new { |o1, o2| block.call(ObjectID.by_id(o1), ObjectID.by_id(o2)) } )
end