当前位置: 首页>>代码示例>>C#>>正文


C# Vector2f.Negate方法代码示例

本文整理汇总了C#中Loon.Core.Geom.Vector2f.Negate方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2f.Negate方法的具体用法?C# Vector2f.Negate怎么用?C# Vector2f.Negate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Loon.Core.Geom.Vector2f的用法示例。


在下文中一共展示了Vector2f.Negate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Collide

		public virtual int Collide(PShape s1, PShape s2, PContact[] cs) {
			if (s1._type != PShapeType.CONVEX_SHAPE
					&& s1._type != PShapeType.BOX_SHAPE
					|| s2._type != PShapeType.CONVEX_SHAPE
					&& s2._type != PShapeType.BOX_SHAPE) {
				return 0;
			}
			PConvexPolygonShape p1 = (PConvexPolygonShape) s1;
			PConvexPolygonShape p2 = (PConvexPolygonShape) s2;
			PPolygonPolygonCollider.PWDistanceData  dis1 = GetDistance(p1, p2);
			if (dis1.dist > 0.0F)
				return 0;
			PPolygonPolygonCollider.PWDistanceData  dis2 = GetDistance(p2, p1);
			if (dis2.dist > 0.0F)
				return 0;
			float error = 0.008F;
			int edgeA;
			PConvexPolygonShape pa;
			PConvexPolygonShape pb;
			bool flip;
			if (dis1.dist > dis2.dist + error) {
				pa = p1;
				pb = p2;
				edgeA = dis1.edge;
				flip = false;
			} else {
				pa = p2;
				pb = p1;
				edgeA = dis2.edge;
				flip = true;
			}
			Vector2f normal = pa.nors[edgeA];
			Vector2f tangent = new Vector2f(-normal.y, normal.x);
			Vector2f[] paVers = pa.vers;
			PPolygonPolygonCollider.PWContactedVertex [] cv = GetEdgeOfPotentialCollision(pa, pb, edgeA,
					flip);
			cv = ClipEdge(cv, tangent.Negate(), -tangent.Dot(paVers[edgeA]));
			if (cv == null)
				return 0;
			cv = ClipEdge(cv, tangent,
					tangent.Dot(paVers[(edgeA + 1) % pa.numVertices]));
			if (cv == null)
				return 0;
			Vector2f contactNormal = (flip) ? normal : normal.Negate();
			int numContacts = 0;
			for (int i = 0; i < 2; i++) {
				float dist = normal.Dot(cv[i].v) - normal.Dot(paVers[edgeA]);
				if (dist < 0.0F) {
					PContact c = new PContact();
					c.normal.Set(contactNormal.x, contactNormal.y);
					c.pos.Set(cv[i].v.x, cv[i].v.y);
					c.overlap = dist;
					c.data = cv[i].data;
					c.data.flip = flip;
					cs[numContacts] = c;
					numContacts++;
				}
			}
	
			return numContacts;
		}
开发者ID:207h2Flogintvg,项目名称:LGame,代码行数:61,代码来源:PPolygonPolygonCollider.cs


注:本文中的Loon.Core.Geom.Vector2f.Negate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。