NewtonCreateConvexHullFromMesh

From Newton Wiki
Jump to: navigation, search

NewtonCreateConvexHullFromMesh

 NewtonCollision* NewtonCreateConvexHullFromMesh (const NewtonWorld* newtonWorld, const NewtonMesh* mesh, dFloat tolerance, int shapeID);

Usage

Creates a convex hull collision primitive from a mesh primitive.

Parameters

  • const NewtonWorld* newtonWorld - pointer to the Newton world.
  • const NewtonMesh* mesh - pointer to the mesh used as input.
  • dFloat tolerance - tolerance value used for post-processing of the hull
  • int shapeID - the ID of the collision shape

Return

  • The generated convex hull collision primitive.

Description

Creates a convex hull collision primitive from a mesh primitive.

Based on the tolerance factor Newton optimizes the hull.

The algorithm behind the function first creates the convex hull then it takes each point and calculates the average plane equation of the face formed by all the points that are directly connected to the examined point. After this it calculates the distance from the examined point to the plane equation and if it is less than the tolerance factor, it means that the point can be removed from the hull.

Remarks

  • Added in Newton 2.0
  • Using a high tolerance factor can introduce artifacts due to the oversimplified convex hull generated by the function
  • The tolerance factor should be set accordingly to improve optimization of the convex hull generated, as shown through the following two images (first image: 0.0, or 0% tolerance; second image: 0.01, or 1% tolerance):

ConvexHull0.jpg ConvexHull1.jpg

See also

NewtonCreateCompoundCollisionFromMesh NewtonCreateConvexHull