Пример #1
0
		public override void SayGoodbye(Joint joint) {
			if (test.m_mouseJoint == joint) {
				test.m_mouseJoint = null;
			} else {
				test.JointDestroyed(joint);
			}
		}
Пример #2
0
		protected Joint(JointDef def){
			Utilities.Assert(def.bodyA != def.bodyB);

			m_type = def.type;
			m_prev = null;
			m_next = null;
			m_bodyA = def.bodyA;
			m_bodyB = def.bodyB;
			m_index = 0;
			m_collideConnected = def.collideConnected;
			m_islandFlag = false;
			m_userData = def.userData;

			m_edgeA = new List<JointEdge>();
			m_edgeB = new List<JointEdge>();
		}
Пример #3
0
		public Joint joint; //pointer			///< the joint

		public JointEdge(Joint j, Body body) {
			this.joint = j;
			this.other = body;
		}
Пример #4
0
		protected static void Destroy(Joint joint){
			throw new NotImplementedException();
			//joint.~Joint();
			//switch (joint.m_type)
			//{
			//case JointType.e_distanceJoint:
			//    allocator.Free(joint, sizeof(DistanceJoint));
			//    break;

			//case JointType.e_mouseJoint:
			//    allocator.Free(joint, sizeof(MouseJoint));
			//    break;

			//case JointType.e_prismaticJoint:
			//    allocator.Free(joint, sizeof(PrismaticJoint));
			//    break;

			//case JointType.e_revoluteJoint:
			//    allocator.Free(joint, sizeof(RevoluteJoint));
			//    break;

			//case JointType.e_pulleyJoint:
			//    allocator.Free(joint, sizeof(PulleyJoint));
			//    break;

			//case JointType.e_gearJoint:
			//    allocator.Free(joint, sizeof(GearJoint));
			//    break;

			//case JointType.e_wheelJoint:
			//    allocator.Free(joint, sizeof(WheelJoint));
			//    break;
    
			//case JointType.e_weldJoint:
			//    allocator.Free(joint, sizeof(WeldJoint));
			//    break;

			//case JointType.e_frictionJoint:
			//    allocator.Free(joint, sizeof(FrictionJoint));
			//    break;

			//case JointType.e_ropeJoint:
			//    allocator.Free(joint, sizeof(RopeJoint));
			//    break;

			//case JointType.e_motorJoint:
			//    allocator.Free(joint, sizeof(MotorJoint));
			//    break;

			//default:
			//    Utilities.Assert(false);
			//    break;
			//}
		}
Пример #5
0
		// Let derived tests know that a joint was destroyed.
		public virtual void JointDestroyed(Joint joint) {  }
Пример #6
0
		/// Called when any joint is about to be destroyed due
		/// to the destruction of one of its attached bodies.
		public abstract void SayGoodbye(Joint joint);
Пример #7
0
		public override void JointDestroyed(Joint joint)
		{
			for (int i = 0; i < 8; ++i)
			{
				if (m_joints[i] == joint)
				{
					m_joints[i] = null;
					break;
				}
			}
		}
Пример #8
0
		/// Destroy a joint. This may cause the connected bodies to begin colliding.
		/// @warning This function is locked during callbacks.
		public void DestroyJoint(Joint joint){
			throw new NotImplementedException();
			//Utilities.Assert(IsLocked() == false);
			//if (IsLocked())
			//{
			//    return;
			//}

			//bool collideConnected = j.m_collideConnected;

			//// Remove from the doubly linked list.
			//if (j.m_prev)
			//{
			//    j.m_prev.m_next = j.m_next;
			//}

			//if (j.m_next)
			//{
			//    j.m_next.m_prev = j.m_prev;
			//}

			//if (j == m_jointList)
			//{
			//    m_jointList = j.m_next;
			//}

			//// Disconnect from island graph.
			//Body* bodyA = j.m_bodyA;
			//Body* bodyB = j.m_bodyB;

			//// Wake up connected bodies.
			//bodyA.SetAwake(true);
			//bodyB.SetAwake(true);

			//// Remove from body 1.
			//if (j.m_edgeA.prev)
			//{
			//    j.m_edgeA.prev.next = j.m_edgeA.next;
			//}

			//if (j.m_edgeA.next)
			//{
			//    j.m_edgeA.next.prev = j.m_edgeA.prev;
			//}

			//if (&j.m_edgeA == bodyA.m_jointList)
			//{
			//    bodyA.m_jointList = j.m_edgeA.next;
			//}

			//j.m_edgeA.prev = null;
			//j.m_edgeA.next = null;

			//// Remove from body 2
			//if (j.m_edgeB.prev)
			//{
			//    j.m_edgeB.prev.next = j.m_edgeB.next;
			//}

			//if (j.m_edgeB.next)
			//{
			//    j.m_edgeB.next.prev = j.m_edgeB.prev;
			//}

			//if (&j.m_edgeB == bodyB.m_jointList)
			//{
			//    bodyB.m_jointList = j.m_edgeB.next;
			//}

			//j.m_edgeB.prev = null;
			//j.m_edgeB.next = null;

			//Joint::Destroy(j, &m_blockAllocator);

			//Utilities.Assert(m_jointCount > 0);
			//--m_jointCount;

			//// If the joint prevents collisions, then flag any contacts for filtering.
			//if (collideConnected == false)
			//{
			//    ContactEdge* edge = bodyB.GetContactList();
			//    while (edge)
			//    {
			//        if (edge.other == bodyA)
			//        {
			//            // Flag the contact for filtering at the next time step (where either
			//            // body is awake).
			//            edge.contact.FlagForFiltering();
			//        }

			//        edge = edge.next;
			//    }
			//}
		}
Пример #9
0
		private void DrawJoint(Joint joint)
		{
			Body bodyA = joint.GetBodyA();
			Body bodyB = joint.GetBodyB();
			Transform xf1 = bodyA.GetTransform();
			Transform xf2 = bodyB.GetTransform();
			Vec2 x1 = xf1.p;
			Vec2 x2 = xf2.p;
			Vec2 p1 = joint.GetAnchorA();
			Vec2 p2 = joint.GetAnchorB();

			Color color = Color.FromArgb(128, 200, 200);

			switch (joint.GetJointType())
			{
			case JointType.e_distanceJoint:
			    m_debugDraw.DrawSegment(p1, p2, color);
			    break;

			case JointType.e_pulleyJoint:
			    {
					throw new NotImplementedException();
					//PulleyJoint pulley = (PulleyJoint)joint;
					//Vec2 s1 = pulley.GetGroundAnchorA();
					//Vec2 s2 = pulley.GetGroundAnchorB();
					//m_debugDraw.DrawSegment(s1, p1, color);
					//m_debugDraw.DrawSegment(s2, p2, color);
					//m_debugDraw.DrawSegment(s1, s2, color);
			    }
			    break;

			case JointType.e_mouseJoint:
			    // don't draw this
			    break;

			default:
			    m_debugDraw.DrawSegment(x1, p1, color);
			    m_debugDraw.DrawSegment(p1, p2, color);
			    m_debugDraw.DrawSegment(x2, p2, color);
				break;
			}
		}
Пример #10
0
        public Joint joint;        //pointer			///< the joint

        public JointEdge(Joint j, Body body)
        {
            this.joint = j;
            this.other = body;
        }
Пример #11
0
		public void Add(Joint joint)
		{
			m_joints.Add(joint);
		}