15#define S2_VERSION 2001
18#include <soft2d/soft2d.h>
55#define S2_NULL_HANDLE 0
109 S2_MATERIAL_TYPE_MAX_ENUM = 0xffffffff,
145 S2_MOBILITY_MAX_ENUM = 0xffffffff,
184 S2_SHAPE_TYPE_MAX_ENUM = 0xffffffff,
296 S2_OUT_WORLD_BOUNDARY_POLICY_MAX_ENUM = 0xffffffff,
319 S2_COLLISION_TYPE_MAX_ENUM = 0xffffffff,
445 S2_BUFFER_NAME_MAX_ENUM = 0xffffffff,
494 uint32_t particle_num,
497 void *particles_in_local_space,
513 uint32_t particle_num,
516 void *particles_in_local_space,
690 const TiTexture *texture);
768 const S2Vec2 *linear_velocity);
784 float angular_velocity);
struct S2Trigger_t * S2Trigger
Definition soft2d_core.h:79
S2_API S2Body S2_API_CALL s2_create_custom_body(S2World world, const S2Material *material, const S2Kinematics *kinematics, uint32_t particle_num, void *particles_in_local_space, uint32_t tag)
S2_API void S2_API_CALL s2_export_buffer_to_texture(S2World world, S2BufferName buffer_name, S2Bool y_flipped, float scale, const TiTexture *texture)
S2_API uint32_t S2_API_CALL s2_query_particle_num_in_trigger_by_tag(S2Trigger trigger, uint32_t tag, uint32_t mask)
S2_API void S2_API_CALL s2_set_trigger_rotation(S2Trigger trigger, float rotation)
S2ShapeType
Definition soft2d_core.h:173
@ S2_SHAPE_TYPE_POLYGON
Polygon type.
Definition soft2d_core.h:183
@ S2_SHAPE_TYPE_BOX
Box type.
Definition soft2d_core.h:175
@ S2_SHAPE_TYPE_CIRCLE
Circle type.
Definition soft2d_core.h:177
@ S2_SHAPE_TYPE_ELLIPSE
Ellipse type.
Definition soft2d_core.h:179
@ S2_SHAPE_TYPE_CAPSULE
Capsule type.
Definition soft2d_core.h:181
S2OutWorldBoundaryPolicy
Definition soft2d_core.h:289
@ S2_OUT_WORLD_BOUNDARY_POLICY_REMOVING
Definition soft2d_core.h:295
@ S2_OUT_WORLD_BOUNDARY_POLICY_DEACTIVATION
Definition soft2d_core.h:292
S2_API void S2_API_CALL s2_set_world_query_enabled(S2World world, uint32_t enable)
S2_API void S2_API_CALL s2_manipulate_particles_in_trigger(S2Trigger trigger, S2ParticleManipulationCallback callback)
void(* S2ParticleManipulationCallback)(S2Particle *particles, uint32_t size)
Definition soft2d_core.h:395
S2_API void S2_API_CALL s2_set_substep_timestep(S2World world, float delta_time)
S2_API void S2_API_CALL s2_set_body_tag(S2Body body, uint32_t tag)
S2_API S2Vec2I S2_API_CALL s2_get_world_grid_resolution(S2World world)
S2_API void S2_API_CALL s2_destroy_world(S2World world)
S2_API void S2_API_CALL s2_step(S2World world, float delta_time)
S2_API float S2_API_CALL s2_get_collider_rotation(S2Collider collider)
S2_API float S2_API_CALL s2_get_collider_angular_velocity(S2Collider collider)
S2_API void S2_API_CALL s2_set_trigger_position(S2Trigger trigger, const S2Vec2 *position)
S2_API void S2_API_CALL s2_apply_impulse_in_circular_area(S2World world, const S2Vec2 *impulse, const S2Vec2 *center, float radius)
S2_API void S2_API_CALL s2_set_collider_linear_velocity(S2Collider collider, const S2Vec2 *linear_velocity)
S2_API void S2_API_CALL s2_remove_particles_in_trigger(S2Trigger trigger)
S2_API uint32_t S2_API_CALL s2_query_trigger_overlapped(S2Trigger trigger)
struct S2Body_t * S2Body
Definition soft2d_core.h:68
S2BufferName
Definition soft2d_core.h:421
@ S2_BUFFER_NAME_PARTICLE_ID
Stores IDs of all particles.
Definition soft2d_core.h:432
@ S2_BUFFER_NAME_FINE_GRID_COLLIDER_NUM
Definition soft2d_core.h:436
@ S2_BUFFER_NAME_PARTICLE_POSITION
Stores positions of all particles.
Definition soft2d_core.h:426
@ S2_BUFFER_NAME_PARTICLE_TAG
Stores tags of all particles.
Definition soft2d_core.h:430
@ S2_BUFFER_NAME_FINE_GRID_TRIGGER_ID
Definition soft2d_core.h:441
@ S2_BUFFER_NAME_PARTICLE_VELOCITY
Stores velocities of all particles.
Definition soft2d_core.h:428
@ S2_BUFFER_NAME_PARTICLE_NUM
Definition soft2d_core.h:424
@ S2_BUFFER_NAME_ELEMENT_INDICES
Definition soft2d_core.h:444
S2_API void S2_API_CALL s2_destroy_body(S2Body body)
S2_API S2Vec2 S2_API_CALL s2_get_collider_position(S2Collider collider)
S2_API void S2_API_CALL s2_set_body_material(S2Body body, const S2Material *material)
struct S2Collider_t * S2Collider
Definition soft2d_core.h:73
S2_API void S2_API_CALL s2_remove_particles_in_trigger_by_tag(S2Trigger trigger, uint32_t tag, uint32_t mask)
struct S2World_t * S2World
Definition soft2d_core.h:61
S2MaterialType
Definition soft2d_core.h:100
@ S2_MATERIAL_TYPE_FLUID
Fluid type.
Definition soft2d_core.h:102
@ S2_MATERIAL_TYPE_SNOW
Snow type.
Definition soft2d_core.h:106
@ S2_MATERIAL_TYPE_ELASTIC
Elastic body type.
Definition soft2d_core.h:104
@ S2_MATERIAL_TYPE_SAND
Sand type.
Definition soft2d_core.h:108
S2_API S2Collider S2_API_CALL s2_create_collider(S2World world, const S2Kinematics *kinematics, const S2Shape *shape, const S2CollisionParameter *collision_parameter)
S2_API void S2_API_CALL s2_set_world_extent(S2World world, const S2Vec2 *extent)
S2_API S2Body S2_API_CALL s2_create_mesh_body(S2World world, const S2Material *material, const S2Kinematics *kinematics, uint32_t particle_num, void *particles_in_local_space, uint32_t index_num, void *indices, uint32_t tag)
S2_API void S2_API_CALL s2_set_mesh_body_force_scale(S2World world, float scale)
S2_API float S2_API_CALL s2_get_trigger_rotation(S2Trigger trigger)
S2_API void S2_API_CALL s2_apply_angular_impulse(S2Body body, float impulse)
S2_API S2World S2_API_CALL s2_create_world(TiArch arch, TiRuntime runtime, const S2WorldConfig *config)
S2_API void S2_API_CALL s2_set_collider_rotation(S2Collider collider, float rotation)
S2_API uint32_t S2_API_CALL s2_query_particle_num_in_trigger(S2Trigger trigger)
S2_API S2Vec2 S2_API_CALL s2_get_trigger_position(S2Trigger trigger)
uint32_t S2Flags
Definition soft2d_core.h:49
S2_API void S2_API_CALL s2_apply_linear_impulse(S2Body body, const S2Vec2 *impulse)
S2_API uint32_t S2_API_CALL s2_query_trigger_overlapped_by_tag(S2Trigger trigger, uint32_t tag, uint32_t mask)
S2_API void S2_API_CALL s2_destroy_trigger(S2Trigger trigger)
S2_API void S2_API_CALL s2_set_collider_angular_velocity(S2Collider collider, float angular_velocity)
S2CollisionType
Definition soft2d_core.h:303
@ S2_COLLISION_TYPE_SEPARATE
Definition soft2d_core.h:318
@ S2_COLLISION_TYPE_STICKY
All velocity components of the particle will be set to 0.
Definition soft2d_core.h:305
@ S2_COLLISION_TYPE_SLIP
Definition soft2d_core.h:311
S2_API S2Vec2 S2_API_CALL s2_get_collider_linear_velocity(S2Collider collider)
S2_API S2Body S2_API_CALL s2_create_body(S2World world, const S2Material *material, const S2Kinematics *kinematics, const S2Shape *shape, uint32_t tag)
S2_API void S2_API_CALL s2_set_collider_position(S2Collider collider, const S2Vec2 *position)
S2_API void S2_API_CALL s2_get_buffer(S2World world, S2BufferName buffer_name, TiNdArray *buffer)
S2_API void S2_API_CALL s2_destroy_collider(S2Collider collider)
S2_API S2Trigger S2_API_CALL s2_create_trigger(S2World world, const S2Kinematics *kinematics, const S2Shape *shape)
S2Mobility
Definition soft2d_core.h:135
@ S2_MOBILITY_KINEMATIC
Definition soft2d_core.h:141
@ S2_MOBILITY_STATIC
Definition soft2d_core.h:138
@ S2_MOBILITY_DYNAMIC
Definition soft2d_core.h:144
S2_API void S2_API_CALL s2_set_world_offset(S2World world, const S2Vec2 *offset)
uint32_t S2Bool
Definition soft2d_core.h:29
S2_API void S2_API_CALL s2_set_gravity(S2World world, const S2Vec2 *gravity)
S2_API S2WorldConfig S2_API_CALL s2_get_world_config(S2World world)
Definition soft2d_core.h:84
Definition soft2d_core.h:92
Definition soft2d_core.h:116
float density
Density (kg/m^3).
Definition soft2d_core.h:120
S2MaterialType type
Material's type.
Definition soft2d_core.h:118
float youngs_modulus
Young's modulus (MPa).
Definition soft2d_core.h:122
float poissons_ratio
Poisson's ratio.
Definition soft2d_core.h:124
Definition soft2d_core.h:157
S2Mobility mobility
The mobility of the object.
Definition soft2d_core.h:167
float rotation
The rotation of the object (radians).
Definition soft2d_core.h:161
S2Vec2 center
The center of the object.
Definition soft2d_core.h:159
float angular_velocity
The angular velocity of the object (radians per second).
Definition soft2d_core.h:165
S2Vec2 linear_velocity
The linear velocity of the object (meters per second).
Definition soft2d_core.h:163
Definition soft2d_core.h:190
S2Vec2 half_extent
Half of the width and height of the box.
Definition soft2d_core.h:192
Definition soft2d_core.h:198
float radius
The radius of the circle.
Definition soft2d_core.h:200
Definition soft2d_core.h:206
float radius_y
The radius along the y-axis of the ellipse.
Definition soft2d_core.h:210
float radius_x
The radius along the x-axis of the ellipse.
Definition soft2d_core.h:208
Definition soft2d_core.h:216
float cap_radius
The radius of caps on the two sides.
Definition soft2d_core.h:220
float rect_half_length
The half length of the central rectangle's width.
Definition soft2d_core.h:218
Definition soft2d_core.h:228
uint32_t vertex_num
The number of vertices in the vertex buffer.
Definition soft2d_core.h:230
void * vertices
A user-specified vertex buffer.
Definition soft2d_core.h:232
Definition soft2d_core.h:239
S2CircleShape circle
See S2CircleShape.
Definition soft2d_core.h:243
S2PolygonShape polygon
See S2PolygonShape.
Definition soft2d_core.h:249
S2CapsuleShape capsule
See S2CapsuleShape.
Definition soft2d_core.h:247
S2EllipseShape ellipse
See S2EllipseShape.
Definition soft2d_core.h:245
S2BoxShape box
See S2BoxShape.
Definition soft2d_core.h:241
Definition soft2d_core.h:256
S2ShapeUnion shape_union
Shape's underlying data.
Definition soft2d_core.h:260
S2ShapeType type
Shape's type.
Definition soft2d_core.h:258
Definition soft2d_core.h:268
S2Vec2 velocity
Particle's velocity. This value is read-only.
Definition soft2d_core.h:275
uint32_t id
Definition soft2d_core.h:271
uint32_t tag
Definition soft2d_core.h:278
S2Vec2 position
Particle's position. This value is read-only.
Definition soft2d_core.h:273
S2Bool is_removed
Definition soft2d_core.h:283
Definition soft2d_core.h:326
float friction_coeff
Definition soft2d_core.h:332
S2CollisionType collision_type
Collision's type.
Definition soft2d_core.h:328
float restitution_coeff
Definition soft2d_core.h:336
Structure S2WorldConfig
Definition soft2d_core.h:340
uint32_t max_allowed_element_num
World's capacity of triangle elements.
Definition soft2d_core.h:346
float collision_penalty_force_scale_along_velocity_dir
A parameter to prevent particles from penetrating colliders.
Definition soft2d_core.h:380
uint32_t max_allowed_particle_num
World's capacity of particles.
Definition soft2d_core.h:342
S2Vec2 offset
World's offset. Indicates the location of the world's bottom-left corner.
Definition soft2d_core.h:352
uint32_t grid_resolution
The resolution of the world's background grid.
Definition soft2d_core.h:350
float collision_penalty_force_scale_along_normal_dir
A parameter to prevent particles from penetrating colliders.
Definition soft2d_core.h:378
uint32_t fine_grid_scale
Definition soft2d_core.h:384
S2Vec2 extent
Definition soft2d_core.h:356
float substep_dt
Definition soft2d_core.h:360
S2Vec2 gravity
Definition soft2d_core.h:363
uint32_t max_allowed_body_num
World's capacity of bodies.
Definition soft2d_core.h:344
S2OutWorldBoundaryPolicy out_world_boundary_policy
Definition soft2d_core.h:366
uint32_t enable_world_query
Definition soft2d_core.h:374
uint32_t max_allowed_trigger_num
World's capacity of triggers.
Definition soft2d_core.h:348
uint32_t enable_debugging
Definition soft2d_core.h:370
float mesh_body_force_scale
A scale factor of mesh body's internal force.
Definition soft2d_core.h:376