public void _Remove(ChipmunkBody obj) { if (obj._handle == IntPtr.Zero) { Debug.LogError("ChipmunkBody handle is NULL"); return; } if (!CP.cpSpaceContainsBody(_handle, obj._handle)) { Debug.LogError("Space does not contain ChipmunkBody."); return; } PostStepFunc del = delegate(){ // Debug.Log("Removing body."); bodies.Remove(obj); CP.cpSpaceRemoveBody(_handle, obj._handle); }; if (locked) { _AddPostStepCallback(_handle, obj.handle, del); } else { del(); } }
public void _Add(ChipmunkConstraint obj) { PostStepFunc del = delegate(){ // Debug.Log("Adding shape."); CP.cpSpaceAddConstraint(_handle, obj.handle); }; if (locked) { _AddPostStepCallback(_handle, obj.handle, del); } else { del(); } }
public void _Add(ChipmunkBody obj) { PostStepFunc del = delegate(){ // Debug.Log("Adding body."); bodies.Add(obj); CP.cpSpaceAddBody(_handle, obj.handle); }; if (locked) { _AddPostStepCallback(_handle, obj.handle, del); } else { del(); } }
[MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern void _AddPostStepCallback(IntPtr handle, IntPtr key, PostStepFunc callback);
extern static void cpSpaceAddPostStepCallback(IntPtr space, PostStepFunc func, IntPtr key, IntPtr data);