Class: BulldogPhysics::Particles::Collisions::ParticleGroundContacts

Inherits:
ParticleContactGenerator show all
Defined in:
lib/Particles/particle_ground_contacts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(particles) ⇒ ParticleGroundContacts

Returns a new instance of ParticleGroundContacts.



9
10
11
# File 'lib/Particles/particle_ground_contacts.rb', line 9

def initialize(particles)
	@particles = particles
end

Instance Attribute Details

#particlesObject (readonly)

Returns the value of attribute particles.



7
8
9
# File 'lib/Particles/particle_ground_contacts.rb', line 7

def particles
  @particles
end

Instance Method Details

#add_contact(contactArray, limit) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/Particles/particle_ground_contacts.rb', line 13

def add_contact(contactArray, limit)
	
	count = 0
	@particles.each do |p|
		
		y = p.position.y
		
		if y < 0.0
			contact = ParticleContact.new(p, nil)
			contact.penetration = (p.position - Vector3.new(p.position.x, 0, p.position.z)).magnitude.abs - p.radius
			contact.restitution = 0.2
			contactArray << contact
			count+=1
		end
		
		
		if( count >= limit)
			return count
		end
		
	end
	
	return count

end