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 ordinary contacts use COAL contact-patch centers.

void setUseContactPatchRefinement(bool enabled)#

Enable or disable contact-patch refinement.

When enabled, ordinary contacts place the force at the center of the contact area reported by COAL. When disabled, ordinary contacts use COAL’s contact points directly. Local plane approximation ignores this setting for height fields.

Parameters:

enabled – Whether contact-patch refinement is enabled.

double getContactPatchTolerance() const#

Get the distance tolerance used to choose contact force locations.

Returns:

Positive contact-patch tolerance in meters.

void setContactPatchTolerance(double tolerance)#

Set the distance tolerance used to choose contact force locations.

This setting controls which nearby surface points are included when choosing where the contact force acts. It is separate from the collision solver’s accuracy setting. Smaller values can turn a nearly flat contact area into an edge or point contact. This does not affect local plane approximation. The default patch tolerance is 1e-3 meters.

Parameters:

tolerance – Positive, finite patch tolerance in meters.

bool getUseLocalPlaneApproximation() const#

Return whether terrain contacts use local plane approximation.

Returns:

True when approximation is enabled; false by default.

void setUseLocalPlaneApproximation(bool enabled)#

Enable or disable local plane approximation for terrain contacts.

Approximation smooths terrain (height field) peaks and valleys beneath supported convex objects. Non-convex meshes fall back to ordinary collision detection. This flag affects all current and future height field scene parts for this scene.

Parameters:

enabled – Whether to enable approximation.

double getLocalPlaneApproximationSupport() const#

Get the scaling factor for the ellipsoid used to fit the local terrain plane.

Returns:

Positive, finite scaling factor; defaults to 1.

void setLocalPlaneApproximationSupport(double support)#

Set the ellipsoidal footprint used to fit the local terrain plane.

A value of 1 wraps an ellipsoid around the collider’s local bounding box. The ellipsoid turns with the collider and projects straight down onto the terrain. Larger values average ground over a wider area. At terrain edges, the fit uses the available ground within that footprint. Numerically degenerate projections use ordinary collision detection rather than an artificial width. This changes the fitted surface, not the collision geometry’s dimensions. Changes apply to existing and future parts without enabling approximation.

Parameters:

support – Positive, finite scaling factor with no upper bound.

Throws:

std::invalid_argument – If support is nonpositive or nonfinite.

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.