@@ -148,7 +148,7 @@ fn initInterface(comptime T: type, comptime VTableT: type) *const VTableT {
148148 }
149149 } else {
150150 if (field .default_value_ptr ) | default_value_ptr | {
151- @field (vtable , field .name ) = @as (* const field .type , @alignCast ( @ptrCast (default_value_ptr ))).* ;
151+ @field (vtable , field .name ) = @as (* const field .type , @ptrCast ( @alignCast (default_value_ptr ))).* ;
152152 } else @compileError ("non-pointer vtable field " ++ field .name ++ " must have a default value" );
153153 }
154154 }
@@ -184,24 +184,24 @@ pub const StreamOut = extern struct {
184184 }
185185};
186186
187- pub const AnyWriterStreamOut = extern struct {
187+ pub const WriterStreamOut = extern struct {
188188 stream_out : StreamOut = .init (@This ()),
189- writer : * const std.io.AnyWriter ,
189+ writer : * std.Io.Writer ,
190190 failed : bool = false ,
191191
192- pub fn init (writer : * const std.io.AnyWriter ) AnyWriterStreamOut {
192+ pub fn init (writer : * std.Io.Writer ) WriterStreamOut {
193193 return .{ .writer = writer };
194194 }
195195
196196 pub fn writeBytes (stream_out : * StreamOut , data : [* ]const u8 , num_bytes : usize ) callconv (.c ) void {
197- const self : * AnyWriterStreamOut = @alignCast (@fieldParentPtr ("stream_out" , stream_out ));
197+ const self : * WriterStreamOut = @alignCast (@fieldParentPtr ("stream_out" , stream_out ));
198198 self .writer .writeAll (data [0.. num_bytes ]) catch {
199199 self .failed = true ;
200200 };
201201 }
202202
203203 pub fn isFailed (stream_out : * StreamOut ) callconv (.c ) bool {
204- const self : * AnyWriterStreamOut = @alignCast (@fieldParentPtr ("stream_out" , stream_out ));
204+ const self : * WriterStreamOut = @alignCast (@fieldParentPtr ("stream_out" , stream_out ));
205205 return self .failed ;
206206 }
207207};
@@ -225,19 +225,19 @@ pub const StreamIn = extern struct {
225225 }
226226};
227227
228- pub const AnyReaderStreamIn = extern struct {
228+ pub const ReaderStreamIn = extern struct {
229229 stream_in : StreamIn = .init (@This ()),
230- reader : * const std.io.AnyReader ,
230+ reader : * std.Io.Reader ,
231231 failed : bool = false ,
232232 eof : bool = false ,
233233
234- pub fn init (reader : * const std.io.AnyReader ) AnyReaderStreamIn {
234+ pub fn init (reader : * std.Io.Reader ) ReaderStreamIn {
235235 return .{ .reader = reader };
236236 }
237237
238238 pub fn readBytes (stream_in : * StreamIn , data : [* ]u8 , num_bytes : usize ) callconv (.c ) void {
239239 const self : * @This () = @alignCast (@fieldParentPtr ("stream_in" , stream_in ));
240- self .reader .readNoEof (data [0.. num_bytes ]) catch | err | switch (err ) {
240+ self .reader .readSliceAll (data [0.. num_bytes ]) catch | err | switch (err ) {
241241 error .EndOfStream = > self .eof = true ,
242242 else = > self .failed = true ,
243243 };
@@ -1509,8 +1509,12 @@ pub const PhysicsSystem = opaque {
15091509 c .JPC_PhysicsSystem_DrawConstraintReferenceFrame (@ptrCast (physics_system ));
15101510 }
15111511
1512- pub fn getBodyIds (physics_system : * const PhysicsSystem , body_ids : * std .ArrayList (BodyId )) ! void {
1513- try body_ids .ensureTotalCapacityPrecise (physics_system .getMaxBodies ());
1512+ pub fn getBodyIds (
1513+ physics_system : * const PhysicsSystem ,
1514+ allocator : std.mem.Allocator ,
1515+ body_ids : * std .ArrayList (BodyId ),
1516+ ) ! void {
1517+ try body_ids .ensureTotalCapacityPrecise (allocator , physics_system .getMaxBodies ());
15141518 var num_body_ids : u32 = 0 ;
15151519 c .JPC_PhysicsSystem_GetBodyIDs (
15161520 @as (* const c .JPC_PhysicsSystem , @ptrCast (physics_system )),
@@ -1521,8 +1525,12 @@ pub const PhysicsSystem = opaque {
15211525 body_ids .items .len = num_body_ids ;
15221526 }
15231527
1524- pub fn getActiveBodyIds (physics_system : * const PhysicsSystem , body_ids : * std .ArrayList (BodyId )) ! void {
1525- try body_ids .ensureTotalCapacityPrecise (physics_system .getMaxBodies ());
1528+ pub fn getActiveBodyIds (
1529+ physics_system : * const PhysicsSystem ,
1530+ allocator : std.mem.Allocator ,
1531+ body_ids : * std .ArrayList (BodyId ),
1532+ ) ! void {
1533+ try body_ids .ensureTotalCapacityPrecise (allocator , physics_system .getMaxBodies ());
15261534 var num_body_ids : u32 = 0 ;
15271535 c .JPC_PhysicsSystem_GetActiveBodyIDs (
15281536 @as (* const c .JPC_PhysicsSystem , @ptrCast (physics_system )),
@@ -1618,6 +1626,8 @@ pub const BodyLockWrite = extern struct {
16181626//
16191627//--------------------------------------------------------------------------------------------------
16201628pub const BodyInterface = opaque {
1629+ pub const AddState = * opaque {};
1630+
16211631 pub fn createBody (body_iface : * BodyInterface , settings : BodyCreationSettings ) ! * Body {
16221632 const body = c .JPC_BodyInterface_CreateBody (
16231633 @as (* c .JPC_BodyInterface , @ptrCast (body_iface )),
@@ -1646,6 +1656,33 @@ pub const BodyInterface = opaque {
16461656 );
16471657 }
16481658
1659+ pub fn addBodiesAbort (body_iface : * BodyInterface , body_ids : []BodyId , add_state : AddState ) void {
1660+ c .JPC_BodyInterface_AddBodiesAbort (
1661+ @as (* c .JPC_BodyInterface , @ptrCast (body_iface )),
1662+ @ptrCast (body_ids .ptr ),
1663+ @intCast (body_ids .len ),
1664+ @ptrCast (add_state ),
1665+ );
1666+ }
1667+
1668+ pub fn addBodiesFinalize (body_iface : * BodyInterface , body_ids : []BodyId , add_state : AddState , mode : Activation ) void {
1669+ c .JPC_BodyInterface_AddBodiesFinalize (
1670+ @as (* c .JPC_BodyInterface , @ptrCast (body_iface )),
1671+ @ptrCast (body_ids .ptr ),
1672+ @intCast (body_ids .len ),
1673+ @ptrCast (add_state ),
1674+ @intFromEnum (mode ),
1675+ );
1676+ }
1677+
1678+ pub fn addBodiesPrepare (body_iface : * BodyInterface , body_ids : []BodyId ) AddState {
1679+ return @ptrCast (c .JPC_BodyInterface_AddBodiesPrepare (
1680+ @as (* c .JPC_BodyInterface , @ptrCast (body_iface )),
1681+ @ptrCast (body_ids .ptr ),
1682+ @intCast (body_ids .len ),
1683+ ));
1684+ }
1685+
16491686 pub fn addBody (body_iface : * BodyInterface , body_id : BodyId , mode : Activation ) void {
16501687 c .JPC_BodyInterface_AddBody (
16511688 @as (* c .JPC_BodyInterface , @ptrCast (body_iface )),
@@ -3390,7 +3427,7 @@ pub const Shape = opaque {
33903427
33913428 pub fn getLocalBounds (shape : * const Shape ) AABox {
33923429 const aabox = c .JPC_Shape_GetLocalBounds (@ptrCast (shape ));
3393- return @as (* AABox , @constCast ( @ptrCast (& aabox ))).* ;
3430+ return @as (* AABox , @ptrCast ( @constCast (& aabox ))).* ;
33943431 }
33953432
33963433 pub fn getSurfaceNormal (shape : * const Shape , sub_shape_id : SubShapeId , local_pos : [3 ]f32 ) [3 ]f32 {
@@ -4356,18 +4393,18 @@ test "zphysics.body.basic" {
43564393 }
43574394
43584395 {
4359- var body_ids = std .ArrayList (BodyId ). init ( std . testing . allocator ) ;
4360- defer body_ids .deinit ();
4361- try physics_system .getBodyIds (& body_ids );
4396+ var body_ids : std .ArrayList (BodyId ) = .empty ;
4397+ defer body_ids .deinit (std . testing . allocator );
4398+ try physics_system .getBodyIds (std . testing . allocator , & body_ids );
43624399 try expect (body_ids .items .len == 1 );
43634400 try expect (body_ids .capacity >= physics_system .getMaxBodies ());
43644401 try expect (body_ids .items [0 ] == body_id );
43654402 }
43664403
43674404 {
4368- var body_ids = std .ArrayList (BodyId ). init ( std . testing . allocator ) ;
4369- defer body_ids .deinit ();
4370- try physics_system .getActiveBodyIds (& body_ids );
4405+ var body_ids : std .ArrayList (BodyId ) = .empty ;
4406+ defer body_ids .deinit (std . testing . allocator );
4407+ try physics_system .getActiveBodyIds (std . testing . allocator , & body_ids );
43714408 try expect (body_ids .items .len == 0 );
43724409 try expect (body_ids .capacity >= physics_system .getMaxBodies ());
43734410 }
@@ -4599,20 +4636,18 @@ test "zphysics.serialization" {
45994636 const shape = try shape_settings .asShapeSettings ().createShape ();
46004637 defer shape .release ();
46014638
4602- var buf : std .ArrayListUnmanaged ( u8 ) = .{} ;
4603- defer buf .deinit (std . testing . allocator );
4639+ var buf : std.Io.Writer.Allocating = .init ( std . testing . allocator ) ;
4640+ defer buf .deinit ();
46044641
46054642 {
4606- const writer = buf .writer (std .testing .allocator ).any ();
4607- var stream_out = AnyWriterStreamOut .init (& writer );
4643+ var stream_out = WriterStreamOut .init (& buf .writer );
46084644 shape .saveBinaryState (@ptrCast (& stream_out ));
4609- try std .testing .expectEqual (1 + 8 + 4 + 12 + 4 , buf .items .len );
4645+ try std .testing .expectEqual (1 + 8 + 4 + 12 + 4 , buf .written () .len );
46104646 }
46114647
46124648 {
4613- var stream = std .io .fixedBufferStream (buf .items );
4614- const reader = stream .reader ().any ();
4615- var stream_in = AnyReaderStreamIn .init (& reader );
4649+ var reader : std.Io.Reader = .fixed (buf .written ());
4650+ var stream_in = ReaderStreamIn .init (& reader );
46164651 const shape_restored = try Shape .restoreFromBinaryState (@ptrCast (& stream_in ));
46174652 defer shape_restored .release ();
46184653
@@ -4795,7 +4830,7 @@ const test_cb1 = struct {
47954830 batch : * anyopaque ,
47964831 ) callconv (.c ) void {
47974832 _ = self ;
4798- const primitive : * MyRenderPrimitive = @alignCast ( @ptrCast (batch ));
4833+ const primitive : * MyRenderPrimitive = @ptrCast ( @alignCast (batch ));
47994834 primitive .allocated = false ;
48004835 }
48014836 fn drawGeometry (
0 commit comments