Class CoalScene#

Inheritance Relationships#

Base Type#

Class Documentation#

class CoalScene : public Karana::Scene::CollisionScene#

CollisionScene implementation using the COAL library.

See Scene layer for more discussion on the scene layer.

Public Functions

CoalScene(std::string_view name)#

CoalScene constructor.

Parameters:

name – - Name for the CoalScene.

~CoalScene()#
virtual void broadphase(std::function<void(const CollisionScenePart&, const CollisionScenePart&)> callback) override#

Do a coarse sweep over the scene check for potential collisions.

Parameters:

callback – - Function called for each potential collision

virtual void sweep(const std::function<void(const CollisionInfo &collision)> &callback, const std::function<bool(const CollisionScenePart&, const CollisionScenePart&)> &filter = nullptr) override#

Do a sweep over the scene checking for collisions.

Parameters:
  • callback – - Function called for each collision

  • filter – - Filter function called for each potential collision pair

virtual const std::vector<CollisionInfo> &cachedCollisions() const override#

Get a list of collisions from the last sweep.

Returns:

The cached collisions

virtual const Karana::Core::ks_ptr<CollisionScenePart> &lookupPart(Karana::Core::id_t) const override#

Fetch a part by its id.

Returns:

The part

size_t getMaxNumContacts()#

Get the maximum number of contact points that we track between any two scene parts.

Returns:

size_t

void setMaxNumContacts(size_t max_contacts)#

Set the maximum number of contact points that we track between any two scene parts.

Also broadcasts this information to every existing CoalScenePart

Parameters:

max_contacts – New maximum count

double getGJKEPATolerance() const#

Get the tolerance used by the GJK and EPA narrowphase solvers.

Returns:

The shared GJK/EPA tolerance.

void setGJKEPATolerance(double tolerance)#

Set the tolerance used by the GJK and EPA narrowphase solvers.

Also broadcasts this value to every existing CoalScenePart.

Parameters:

tolerance – Positive, finite solver tolerance.

bool getUseContactPatchRefinement() const#

Return whether contact-patch refinement is enabled.

Returns:

True when raw contacts are refined to patch centroids.

void setUseContactPatchRefinement(bool enabled)#

Enable or disable contact-patch refinement.

When enabled, CoalScene expands each raw COAL contact into a contact patch and refines its witness to the patch centroid. This provides more accurate witness points for non-strictly convext collisions in exchange for a slight increase to the cost of performing narrowphase collision detection.

Parameters:

enabled – Whether contact-patch refinement is enabled.

double getContactPatchTolerance() const#

Return the support-set tolerance used to construct contact patches.

Returns:

Positive contact-patch tolerance in metres.

void setContactPatchTolerance(double tolerance)#

Set the support-set tolerance used to construct contact patches.

This tolerance is independent of the GJK/EPA tolerance. COAL’s default value of 1e-3 is intentionally retained because a thinner support plane can turn a nearly parallel face contact into an edge contact.

Parameters:

tolerance – Positive, finite patch tolerance in metres.

Public Static Functions

static Karana::Core::ks_ptr<CoalScene> create(std::string_view name)#

Create a CoalScene.

Parameters:

name – - Name for the CoalScene

Returns:

The created CoalScene

Protected Functions

virtual void _discard(Karana::Core::ks_ptr<Karana::Core::Base> &base) override#

This does the work to discard the CoalScene.

Parameters:

base – - A Base pointer to the CoalScene to discard.