Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AABBOverlapHit ¶
type AABBOverlapHit struct {
Entity cardinal.EntityID `json:"entity"`
ShapeIndex int `json:"shape_index"`
}
AABBOverlapHit is one ECS shape that overlaps the query AABB after narrow-phase test.
type AABBOverlapRequest ¶
type AABBOverlapRequest struct {
Min component.Vec2 `json:"min"`
Max component.Vec2 `json:"max"`
Filter *Filter `json:"filter,omitempty"`
}
AABBOverlapRequest finds fixtures whose shapes overlap the axis-aligned box [Min, Max] in world space (inclusive bounds on the query box). Min.X may be greater than Max.X; components are swapped per axis.
type AABBOverlapResult ¶
type AABBOverlapResult struct {
Hits []AABBOverlapHit `json:"hits"`
}
AABBOverlapResult lists distinct (Entity, ShapeIndex) pairs that overlap the query box.
func OverlapAABB ¶
func OverlapAABB(req AABBOverlapRequest) AABBOverlapResult
OverlapAABB returns distinct (Entity, ShapeIndex) pairs overlapping the query AABB. A zero-area AABB (Min == Max on any axis) always returns no hits.
type CircleSweepRequest ¶
type CircleSweepRequest struct {
Start component.Vec2 `json:"start"`
End component.Vec2 `json:"end"`
Radius float64 `json:"radius"`
Filter *Filter `json:"filter,omitempty"`
MaxFraction float64 `json:"max_fraction"`
}
CircleSweepRequest sweeps a circle with center moving along the segment from Start to End in world space. Radius must be positive. MaxFraction is the TOI search bound in [0,1] along that segment; 0 means 1.0. A nil Filter uses the same defaults as RaycastRequest (all layers, solids only).
type CircleSweepResult ¶
type CircleSweepResult struct {
Hit bool `json:"hit"`
Entity cardinal.EntityID `json:"entity"`
ShapeIndex int `json:"shape_index"`
Point component.Vec2 `json:"point"`
Normal component.Vec2 `json:"normal"`
Fraction float64 `json:"fraction"`
}
CircleSweepResult is the closest first contact along the sweep, if any.
func CircleSweep ¶
func CircleSweep(req CircleSweepRequest) CircleSweepResult
CircleSweep sweeps a circle along Start->End and returns the earliest TOI hit. A zero-radius or zero-length sweep always returns no hit.
type Filter ¶
type Filter struct {
CategoryBits uint64 `json:"category_bits"`
MaskBits uint64 `json:"mask_bits"`
IncludeSensors bool `json:"include_sensors"`
}
Filter restricts which fixtures a query considers. A fixture passes when all of the following hold:
- (Filter.MaskBits & fixture.CategoryBits) != 0
- (Filter.CategoryBits & fixture.MaskBits) != 0
- if IncludeSensors is false, the fixture is not a sensor
Fixture group index is not part of v1 query filtering; category/mask only.
A nil *Filter uses CategoryBits and MaskBits ^uint64(0) and IncludeSensors false (solids only, all layers) for RaycastRequest, AABBOverlapRequest, and CircleSweepRequest.
type RaycastRequest ¶
type RaycastRequest struct {
Origin component.Vec2 `json:"origin"`
End component.Vec2 `json:"end"`
Filter *Filter `json:"filter,omitempty"`
}
RaycastRequest is a world-space segment cast from Origin toward End (inclusive segment; hit fraction is in [0,1] along Origin->End). The ray must have non-zero length.
type RaycastResult ¶
type RaycastResult struct {
Hit bool `json:"hit"`
Entity cardinal.EntityID `json:"entity"`
ShapeIndex int `json:"shape_index"`
Point component.Vec2 `json:"point"`
Normal component.Vec2 `json:"normal"`
Fraction float64 `json:"fraction"`
}
RaycastResult is the closest hit along the segment, if any. When Hit is false, other fields are zero.
func Raycast ¶
func Raycast(req RaycastRequest) RaycastResult
Raycast returns the closest fixture hit along [req.Origin, req.End], or Hit=false. A zero-length segment (Origin == End) always returns no hit.