LDK_GRASS_PROFILE_POINT_COUNT
#define LDK_GRASS_PROFILE_POINT_COUNT 4u
Persistent procedural grass patches.
#define LDK_GRASS_PROFILE_POINT_COUNT 4u
#define LDK_GRASS_MIN_SIDE_COUNT 3u
#define LDK_GRASS_MAX_SIDE_COUNT 8u
#define LDK_GRASS_TYPE_COUNT 16u
#define LDK_GRASS_TYPE_ID_INVALID UINT32_MAX
typedef u32 LDKGrassTypeId;
Deprecated source-compatible name for the original thorny prototype.
typedef enum LDKGrassBladeTopology{
LDK_GRASS_BLADE_TOPOLOGY_RIBBON=0,
LDK_GRASS_BLADE_TOPOLOGY_CROSSED_RIBBONS,
LDK_GRASS_BLADE_TOPOLOGY_RADIAL,
LDK_GRASS_BLADE_TOPOLOGY_TRIPLE_RIBBONS,
LDK_GRASS_BLADE_TOPOLOGY_THORNY_STEM,
/** Deprecated source-compatible name for the original thorny prototype. */LDK_GRASS_BLADE_TOPOLOGY_THORNY_RIBBON=LDK_GRASS_BLADE_TOPOLOGY_THORNY_STEM
}LDKGrassBladeTopology;
typedef enum LDKGrassBladePreset{
LDK_GRASS_BLADE_PRESET_THIN=0,
LDK_GRASS_BLADE_PRESET_CROSSED,
LDK_GRASS_BLADE_PRESET_TUFT,
LDK_GRASS_BLADE_PRESET_FLAT_TOP,
LDK_GRASS_BLADE_PRESET_THORNY
}LDKGrassBladePreset;
One sample of the normalized blade profile. Height is in [0, 1]. Width is the full ribbon width, or the radial diameter, at that height.
typedef struct LDKGrassProfilePoint{
float height;
float width;
}LDKGrassProfilePoint;
Used by the radial and thorny stem topologies.
typedef struct LDKGrassBladeShape{
LDKGrassProfilePoint profile[LDK_GRASS_PROFILE_POINT_COUNT];
LDKGrassBladeTopology topology;
/** Used by the radial and thorny stem topologies. */u32 side_count;
}LDKGrassBladeShape;
Flat target geometry. The complete parallelogram, including its edges, is a valid generation area. origin + axis_u + axis_v is the opposite corner.
typedef struct LDKGrassPlane{
Vec3 origin;
Vec3 axis_u;
Vec3 axis_v;
}LDKGrassPlane;
Seconds until interaction deformation fully returns to rest. Zero uses the default.
typedef struct LDKGrassTypeDesc{
XSmallstr name;
LDKGrassBladePreset blade_preset;
float density;
float min_height;
float max_height;
float blade_width;
float curvature;
/** Per-type maximum wind displacement before the system wind force. */float wind_strength;
/** Seconds until interaction deformation fully returns to rest. Zero uses the default. */float interaction_recovery_time;
rgba32 bottom_color;
rgba32 top_color;
}LDKGrassTypeDesc;
Per-region state. Visual configuration comes from LDKGrassSystem.
typedef struct LDKGrassPatchDesc{
LDKGrassPlane plane;
float density_scale;
u32 seed;
}LDKGrassPatchDesc;
Opaque identity of one patch. Individual blades are intentionally hidden.
typedef struct LDKGrassPatch{
u32 index;
u32 version;
}LDKGrassPatch;
Initialize the grass system.
int ldk_grass_system_initialize(void *data);
void *dataSystem initialization status code.
Update the grass system.
void ldk_grass_system_update(
void *data,
const LDKEntityGroup *group,
float dt
);
void *dataconst LDKEntityGroup *groupfloat dtShut down the grass system.
void ldk_grass_system_terminate(void *data);
void *dataAnimation cycles per second.
typedef struct LDKGrassSystem{
float min_tilt_degrees;
float max_tilt_degrees;
/** Shared lean azimuth: 0 degrees is +X, 90 degrees is +Z. */float tilt_direction_degrees;
/** Wind azimuth: 0 degrees is +X, 90 degrees is +Z. */float wind_direction_degrees;
float wind_force;
/** Animation cycles per second. */float wind_speed;
float specular;
float shininess;
float emission;
bool casts_shadows;
XSmallstr type_0_name;
LDKGrassBladePreset type_0_blade_preset;
float type_0_density;
float type_0_min_height;
float type_0_max_height;
float type_0_blade_width;
float type_0_curvature;
float type_0_wind_strength;
float type_0_interaction_recovery_time;
u32 type_0_bottom_color;
u32 type_0_top_color;
XSmallstr type_1_name;
LDKGrassBladePreset type_1_blade_preset;
float type_1_density;
float type_1_min_height;
float type_1_max_height;
float type_1_blade_width;
float type_1_curvature;
float type_1_wind_strength;
float type_1_interaction_recovery_time;
u32 type_1_bottom_color;
u32 type_1_top_color;
XSmallstr type_2_name;
LDKGrassBladePreset type_2_blade_preset;
float type_2_density;
float type_2_min_height;
float type_2_max_height;
float type_2_blade_width;
float type_2_curvature;
float type_2_wind_strength;
float type_2_interaction_recovery_time;
u32 type_2_bottom_color;
u32 type_2_top_color;
XSmallstr type_3_name;
LDKGrassBladePreset type_3_blade_preset;
float type_3_density;
float type_3_min_height;
float type_3_max_height;
float type_3_blade_width;
float type_3_curvature;
float type_3_wind_strength;
float type_3_interaction_recovery_time;
u32 type_3_bottom_color;
u32 type_3_top_color;
XSmallstr type_4_name;
LDKGrassBladePreset type_4_blade_preset;
float type_4_density;
float type_4_min_height;
float type_4_max_height;
float type_4_blade_width;
float type_4_curvature;
float type_4_wind_strength;
float type_4_interaction_recovery_time;
u32 type_4_bottom_color;
u32 type_4_top_color;
XSmallstr type_5_name;
LDKGrassBladePreset type_5_blade_preset;
float type_5_density;
float type_5_min_height;
float type_5_max_height;
float type_5_blade_width;
float type_5_curvature;
float type_5_wind_strength;
float type_5_interaction_recovery_time;
u32 type_5_bottom_color;
u32 type_5_top_color;
XSmallstr type_6_name;
LDKGrassBladePreset type_6_blade_preset;
float type_6_density;
float type_6_min_height;
float type_6_max_height;
float type_6_blade_width;
float type_6_curvature;
float type_6_wind_strength;
float type_6_interaction_recovery_time;
u32 type_6_bottom_color;
u32 type_6_top_color;
XSmallstr type_7_name;
LDKGrassBladePreset type_7_blade_preset;
float type_7_density;
float type_7_min_height;
float type_7_max_height;
float type_7_blade_width;
float type_7_curvature;
float type_7_wind_strength;
float type_7_interaction_recovery_time;
u32 type_7_bottom_color;
u32 type_7_top_color;
XSmallstr type_8_name;
LDKGrassBladePreset type_8_blade_preset;
float type_8_density;
float type_8_min_height;
float type_8_max_height;
float type_8_blade_width;
float type_8_curvature;
float type_8_wind_strength;
float type_8_interaction_recovery_time;
u32 type_8_bottom_color;
u32 type_8_top_color;
XSmallstr type_9_name;
LDKGrassBladePreset type_9_blade_preset;
float type_9_density;
float type_9_min_height;
float type_9_max_height;
float type_9_blade_width;
float type_9_curvature;
float type_9_wind_strength;
float type_9_interaction_recovery_time;
u32 type_9_bottom_color;
u32 type_9_top_color;
XSmallstr type_10_name;
LDKGrassBladePreset type_10_blade_preset;
float type_10_density;
float type_10_min_height;
float type_10_max_height;
float type_10_blade_width;
float type_10_curvature;
float type_10_wind_strength;
float type_10_interaction_recovery_time;
u32 type_10_bottom_color;
u32 type_10_top_color;
XSmallstr type_11_name;
LDKGrassBladePreset type_11_blade_preset;
float type_11_density;
float type_11_min_height;
float type_11_max_height;
float type_11_blade_width;
float type_11_curvature;
float type_11_wind_strength;
float type_11_interaction_recovery_time;
u32 type_11_bottom_color;
u32 type_11_top_color;
XSmallstr type_12_name;
LDKGrassBladePreset type_12_blade_preset;
float type_12_density;
float type_12_min_height;
float type_12_max_height;
float type_12_blade_width;
float type_12_curvature;
float type_12_wind_strength;
float type_12_interaction_recovery_time;
u32 type_12_bottom_color;
u32 type_12_top_color;
XSmallstr type_13_name;
LDKGrassBladePreset type_13_blade_preset;
float type_13_density;
float type_13_min_height;
float type_13_max_height;
float type_13_blade_width;
float type_13_curvature;
float type_13_wind_strength;
float type_13_interaction_recovery_time;
u32 type_13_bottom_color;
u32 type_13_top_color;
XSmallstr type_14_name;
LDKGrassBladePreset type_14_blade_preset;
float type_14_density;
float type_14_min_height;
float type_14_max_height;
float type_14_blade_width;
float type_14_curvature;
float type_14_wind_strength;
float type_14_interaction_recovery_time;
u32 type_14_bottom_color;
u32 type_14_top_color;
XSmallstr type_15_name;
LDKGrassBladePreset type_15_blade_preset;
float type_15_density;
float type_15_min_height;
float type_15_max_height;
float type_15_blade_width;
float type_15_curvature;
float type_15_wind_strength;
float type_15_interaction_recovery_time;
u32 type_15_bottom_color;
u32 type_15_top_color;
}LDKGrassSystem;
Initialize a useful default grass type description.
LDK_API void ldk_grass_type_desc_defaults(LDKGrassTypeDesc *out_desc);
LDKGrassTypeDesc *out_descReturn the active configuration index for name, or INVALID when absent.
LDK_API LDKGrassTypeId ldk_grass_get_id_by_name(const char *name);
const char *nameThe requested value.
True when type_id names a configured slot in the active GrassSystem.
LDK_API bool ldk_grass_type_is_valid(LDKGrassTypeId type_id);
LDKGrassTypeId type_idTrue when the queried condition holds; false otherwise.
Copy one configured type from the active GrassSystem.
LDK_API bool ldk_grass_type_get(
LDKGrassTypeId type_id,
LDKGrassTypeDesc *out_desc
);
LDKGrassTypeId type_idLDKGrassTypeDesc *out_descTrue if the operation succeeds; false otherwise.
Register an additional type in the first free runtime slot. Names must be unique. Returns INVALID when the system is inactive, the description is invalid, the name already exists, or all 16 slots are occupied.
LDK_API LDKGrassTypeId ldk_grass_type_register(const LDKGrassTypeDesc *desc);
const LDKGrassTypeDesc *descThe requested value.
Initialize an empty one-square-unit patch with density scale 1.
LDK_API void ldk_grass_patch_desc_defaults(LDKGrassPatchDesc *out_desc);
LDKGrassPatchDesc *out_descReturn an invalid grass patch handle.
LDK_API LDKGrassPatch ldk_grass_patch_null(void);
An invalid or empty handle.
True while patch identifies a live entry in the active GrassSystem.
LDK_API bool ldk_grass_patch_is_valid(LDKGrassPatch patch);
LDKGrassPatch patchTrue when the queried condition holds; false otherwise.
Generate and retain one patch using a configured grass type.
LDK_API LDKGrassPatch ldk_grass_add(
LDKGrassTypeId type_id,
const LDKGrassPatchDesc *desc
);
LDKGrassTypeId type_idconst LDKGrassPatchDesc *descThe requested value.
Replace a patch recipe and regenerate its persistent blade transforms.
LDK_API bool ldk_grass_update(
LDKGrassPatch patch,
LDKGrassTypeId type_id,
const LDKGrassPatchDesc *desc
);
LDKGrassPatch patchLDKGrassTypeId type_idconst LDKGrassPatchDesc *descTrue if the operation succeeds; false otherwise.
Remove a patch and every opaque blade belonging to it.
LDK_API bool ldk_grass_remove(LDKGrassPatch patch);
LDKGrassPatch patchTrue if the operation succeeds; false otherwise.
Remove every live patch. Renderer-side style resources remain cached.
LDK_API void ldk_grass_clear(void);
Queue one world-space grass interaction capsule for the active GrassSystem. Passing the same point for from and to produces a circular interaction. The queued interaction is consumed by the GrassSystem render update.
LDK_API bool ldk_grass_interact(
Vec3 from,
Vec3 to,
float radius,
float strength
);
Vec3 fromVec3 tofloat radiusfloat strengthTrue if the operation succeeds; false otherwise.