DetPhysDocs日本語

detphys_bake.hconcave shape baker (version 1)

Turns an image (its alpha) into a concave shape made of convex polygons (at most 8 vertices each) and writes it as .dnshape bytes (integer vertices, origin at the image centre, y up). Register the bytes as a mesh of a world or a session. It is an editor-time tool: nothing in it runs during a simulation. Every decision is made with integers, so the same image and parameters give the same bytes on every platform. The editors' bakers (3. Concepts) call these functions.

FunctionDescription
detphys_bake_abi_versionVersion of this header (DETPHYS_BAKE_ABI_VERSION)
detphys_bake_params_defaultDefault parameters (1000 units per m = mm, 128 px per m, alpha 128 or more is inside, 8 vertices per piece, Steiner, tolerance 1 px)
detphys_bake_alpha, detphys_bake_rgba, detphys_bake_pngBake an alpha image (1 byte per pixel), an RGBA image (alpha is the 4th byte) or the bytes of a PNG file (rows top-down; up to 16384 x 16384 px). params may be NULL (the defaults). Always return a result (NULL only when memory runs out)
detphys_bake_statusDETPHYS_OK, DETPHYS_BAKE_ERR_IMAGE (−20, the image could not be read), DETPHYS_BAKE_ERR_SHAPE (−21, no shape could be made) or DETPHYS_ERR_ARGUMENT / DETPHYS_ERR_INTERNAL
detphys_bake_errorWhy the bake failed (English, one sentence; empty on success)
detphys_bake_dataThe .dnshape bytes (NULL when the bake failed). Valid until the result is destroyed
detphys_bake_get_statsNumbers about the bake (detphys_bake_stats)
detphys_bake_read_outlineThe simplified outline, for previews (loops and vertices in vertex units)
detphys_bake_png_alphaReads the alpha of a PNG without baking it (call with alpha = NULL to get the size first)
detphys_bake_result_destroyFrees a result
StructDescription
detphys_bake_paramsUnits per m, pixels per m, alpha threshold, most vertices per piece (3–8), decomposition (DETPHYS_BAKE_STEINER = default, DETPHYS_BAKE_HM = Hertel-Mehlhorn), simplification tolerance (px), smallest bulge of a vertex (mm), smallest island (px), Steiner snap distance (mm)
detphys_bake_statsImage size, pieces and their vertices, outline loops and vertices, holes filled, specks dropped, vertices removed, Steiner points, bounds, the tolerance used and the largest distance from the traced outline (mm)
detphys_bake_resultA finished bake (opaque)

↑↓ to choose, Enter to open, Esc to close