Module: Jolt::SystemConstraints

Included in:
System
Defined in:
lib/jolt/system_constraints.rb

Instance Method Summary collapse

Instance Method Details

#__constraints_snapshotObject



23
24
25
26
# File 'lib/jolt/system_constraints.rb', line 23

def __constraints_snapshot
  __check_alive!
  @constraint_registry.dup
end

#__destroy_all_constraintsObject



32
33
34
# File 'lib/jolt/system_constraints.rb', line 32

def __destroy_all_constraints
  @constraint_registry.dup.each(&:destroy)
end

#__destroy_constraint(constraint) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jolt/system_constraints.rb', line 9

def __destroy_constraint(constraint)
  return if constraint.destroyed?

  __check_alive!
  removed = @constraint_registry.delete(constraint)
  raise InvalidArgumentError, "constraint does not belong to this system" unless removed

  pointer = constraint.__native_pointer
  Native.JPH_PhysicsSystem_RemoveConstraint(@pointer, pointer)
  Native.JPH_Constraint_Destroy(pointer)
  constraint.__mark_destroyed
  nil
end

#__destroy_constraints_for(body) ⇒ Object



28
29
30
# File 'lib/jolt/system_constraints.rb', line 28

def __destroy_constraints_for(body)
  @constraint_registry.select { |constraint| constraint.__involves?(body) }.each(&:destroy)
end

#__register_constraint(constraint) ⇒ Object



5
6
7
# File 'lib/jolt/system_constraints.rb', line 5

def __register_constraint(constraint)
  @constraint_registry << constraint
end