@@ -20,9 +20,17 @@ const (
2020 ShapeTypeBox
2121 // ShapeTypeConvexPolygon uses Vertices as a convex polygon in the shape's local frame.
2222 ShapeTypeConvexPolygon
23- // ShapeTypeStaticChain uses ChainPoints for open chain segments (static/terrain-style
24- // geometry only; not for moving dynamic shapes ).
23+ // ShapeTypeStaticChain uses ChainPoints for open chain segments (static or kinematic
24+ // bodies only; not for dynamic bodies which require mass ).
2525 ShapeTypeStaticChain
26+ // ShapeTypeStaticChainLoop uses ChainPoints for closed chain loops (static or kinematic
27+ // bodies only; not for dynamic bodies). Unlike ShapeTypeStaticChain, the last vertex
28+ // automatically connects back to the first, creating a sealed boundary.
29+ ShapeTypeStaticChainLoop
30+ // ShapeTypeEdge uses EdgeVertices (exactly 2 points) for a single line segment
31+ // (static or kinematic bodies only). Lighter than a 2-point chain for isolated barriers
32+ // or triggers.
33+ ShapeTypeEdge
2634)
2735
2836// ColliderShape is one child shape inside a compound Collider2D.
@@ -33,17 +41,20 @@ const (
3341// - ShapeTypeBox → HalfExtents (half-width on X, half-height on Y, axis-aligned before LocalOffset/LocalRotation)
3442// - ShapeTypeConvexPolygon → Vertices (convex polygon, respect backend limits)
3543// - ShapeTypeStaticChain → ChainPoints (open polyline in local space)
44+ // - ShapeTypeStaticChainLoop → ChainPoints (closed loop in local space)
45+ // - ShapeTypeEdge → EdgeVertices (exactly 2 points in local space)
3646type ColliderShape struct {
3747 ShapeType ShapeType `json:"shape_type"`
3848 LocalOffset Vec2 `json:"local_offset"`
3949 LocalRotation float64 `json:"local_rotation"`
4050 IsSensor bool `json:"is_sensor"`
4151
4252 // Geometry (use fields matching ShapeType).
43- Radius float64 `json:"radius,omitempty"`
44- HalfExtents Vec2 `json:"half_extents,omitempty"`
45- Vertices []Vec2 `json:"vertices,omitempty"`
46- ChainPoints []Vec2 `json:"chain_points,omitempty"`
53+ Radius float64 `json:"radius,omitempty"`
54+ HalfExtents Vec2 `json:"half_extents,omitempty"`
55+ Vertices []Vec2 `json:"vertices,omitempty"`
56+ ChainPoints []Vec2 `json:"chain_points,omitempty"`
57+ EdgeVertices [2 ]Vec2 `json:"edge_vertices,omitempty"`
4758
4859 // Material and per-shape collision filtering (fixture-level in Box2D).
4960 Friction float64 `json:"friction"`
@@ -117,9 +128,15 @@ func (s ColliderShape) Validate() error {
117128 return err
118129 }
119130 }
131+ for i , v := range s .EdgeVertices {
132+ if err := validateVec2 (fmt .Sprintf ("edge_vertices[%d]" , i ), v ); err != nil {
133+ return err
134+ }
135+ }
120136
121137 switch s .ShapeType {
122- case ShapeTypeCircle , ShapeTypeBox , ShapeTypeConvexPolygon , ShapeTypeStaticChain :
138+ case ShapeTypeCircle , ShapeTypeBox , ShapeTypeConvexPolygon , ShapeTypeStaticChain ,
139+ ShapeTypeStaticChainLoop , ShapeTypeEdge :
123140 default :
124141 return fmt .Errorf ("shape_type: unknown value %d" , s .ShapeType )
125142 }
0 commit comments