public void ReceiveFixture(PFixture2D fixture) { _fixture = fixture; _shape = Parallel2D.GetShapeOfFixture(fixture); Parallel2D.SetLayer(fixture, gameObject.layer, false); Parallel2D.SetFixtureProperties(fixture, isTrigger, _friction, _bounciness); }
public static void UpdateCapsule(PShape2D shape, PFixture2D fixture, Fix64Vec2 v1, Fix64Vec2 v2, Fix64 radius, Fix64Vec2 center, Fix64 angle) { if (!initialized) { Initialize(); } NativeParallel2D.UpdateCapsule(shape.IntPointer, fixture.IntPointer, v1, v2, radius, center, angle); }
public static void UpdateBox(PShape2D shape, PFixture2D fixture, Fix64 width, Fix64 height, Fix64Vec2 center, Fix64 angle) { if (!initialized) { Initialize(); } NativeParallel2D.UpdateBox(shape.IntPointer, fixture.IntPointer, width, height, center, angle); }
public static void UpdateCircle(PShape2D shape, PFixture2D fixture, Fix64 radius, Fix64Vec2 center) { if (!initialized) { Initialize(); } NativeParallel2D.UpdateCircle(shape.IntPointer, fixture.IntPointer, radius, center); }
public static void SetFixtureProperties(PFixture2D fixture, bool isTrigger, Fix64 friction, Fix64 bounciness) { if (!initialized) { Initialize(); } NativeParallel2D.SetFixtureProperties(fixture.IntPointer, isTrigger, friction, bounciness); }
public static PShape2D GetShapeOfFixture(PFixture2D fixture2D) { if (!initialized) { Initialize(); } IntPtr m_NativeObject = NativeParallel2D.GetShapeOfFixture(fixture2D.IntPointer); return(new PShape2D(m_NativeObject)); }
public static void UpdatePolygon(PShape2D shape, PFixture2D fixture, Fix64Vec2[] verts, int count, Fix64Vec2 center, Fix64 angle) { if (!initialized) { Initialize(); } ParallelVec2List parallelVec2List = new ParallelVec2List(); parallelVec2List.count = count; parallelVec2List.points = verts; NativeParallel2D.UpdatePolygon(shape.IntPointer, fixture.IntPointer, ref parallelVec2List, center, angle); }
public static void SetLayer(PFixture2D fixture, int layer, bool refilter) { if (!initialized) { Initialize(); } int mask = masksByLayer[layer]; //shift layer int shiftedLayer = 1 << layer; NativeParallel2D.SetLayer(fixture.IntPointer, shiftedLayer, mask, refilter); }
//============================== Unity Events ============================== void Awake() { ParallelPhysicsController2D pSettings = FindObjectOfType <ParallelPhysicsController2D>(); if (pSettings == null) { return; } pSettings.InitIfNecessary(); parallelFixedUpdates = GetComponents <IParallelFixedUpdate>(); parallelCollisions = GetComponents <IParallelCollision2D>(); parallelTriggers = GetComponents <IParallelTrigger2D>(); pTransform.ImportFromUnity(); colliders = GetComponentsInChildren <ParallelCollider2D>(); _body2D = Parallel2D.AddBody( (int)bodyType, (Fix64Vec2)pTransform.position, pTransform.rotation.GetZAngle(), linearDampling, angularDamping, fixedRotation, gravityScale, this); _bodyID = _body2D.BodyID; foreach (ParallelCollider2D collider in colliders) { collider.SetRootGameObject(gameObject); PShape2D shape = collider.CreateShape(gameObject); if (shape == null) { Debug.LogError("Failed to create collider shape"); continue; } PFixture2D fixture2D = Parallel2D.AddFixture(_body2D, shape, (Fix64)1); collider.ReceiveFixture(fixture2D); } }