public static ColliderPrefab CreateColliderPrefab(ColliderData data) { CBaseShape collider = null; if (LMath.Abs(data.deg - 45) < 1) { } //warning data.deg is unity deg //changed unity deg to ccw deg var collisionDeg = -data.deg + 90; if (data.radius > 0) { //circle collider = new CCircle(data.radius); } else { //obb collider = new COBB(data.size, collisionDeg); } collider.high = data.high; var colFab = new ColliderPrefab(); colFab.parts.Add(new ColliderPart() { transform = new CTransform2D(data.pos, data.y, data.deg), collider = collider }); return(colFab); }
public static ColliderPrefab CreateColliderPrefab(GameObject fab, ColliderData data) { Debug.Trace("CreateColliderPrefab " + fab.name); CBaseShape collider = null; if (data == null) { Debug.LogError(fab.name + " Miss ColliderDataMono "); return(null); } if (data.radius > 0) { //circle collider = new CCircle(data.radius); } else { //obb collider = new COBB(data.size, data.deg); } Debug.Trace($"{fab.name} !!!CreateCollider deg: {data.deg} up:{data.size} radius:{data.radius}"); var colFab = new ColliderPrefab(); colFab.parts.Add(new ColliderPart() { transform = new CTransform2D(LVector2.zero), collider = collider }); return(colFab); }
public static ColliderPrefab CreateColliderPrefab(GameObject fab) { Collider unityCollider = null; var colliders = fab.GetComponents <Collider>(); foreach (var col in colliders) { if (col.isTrigger) { unityCollider = col; break; } } if (unityCollider == null) { foreach (var col in colliders) { unityCollider = col; break; } } if (unityCollider == null) { return(null); } CBaseShape collider = null; if (unityCollider is BoxCollider boxCol) { collider = new COBB(boxCol.size.ToLVector2XZ(), LFloat.zero); } if (unityCollider is SphereCollider cirCol) { collider = new CCircle(cirCol.radius.ToLFloat()); } if (unityCollider is CapsuleCollider capCol) { collider = new CCircle(capCol.radius.ToLFloat()); } var colFab = new ColliderPrefab(); colFab.parts.Add(new ColliderPart() { transform = new CTransform2D(LVector2.zero), collider = collider }); return(colFab); }
private static bool CheckCircle_Polygon(CCircle col1, CPolygon col2, Transform2D trans1, Transform2D trans2) { return(false); }
private static bool CheckCircle_OBB(CCircle col1, COBB col2, Transform2D trans1, Transform2D trans2) { return(Utils.TestCircleOBB( trans1.pos, col1.radius, trans2.pos, col2.radius, col2.size, col2.up)); }
private static bool CheckCircle_Circle(CCircle col1, CCircle col2, Transform2D trans1, Transform2D trans2) { return(Utils.TestCircleCircle( trans1.pos, col1.radius, trans2.pos, col2.radius)); }
private static bool CheckRay_Circle(CRay col1, CCircle col2, Transform2D trans1, Transform2D trans2) { return(false); }
private static bool CheckSeg_Circle(CSegment col1, CCircle col2, Transform2D trans1, Transform2D trans2) { return(false); }
public static ColliderPrefab CreateColliderPrefab(GameObject fab) { Debug.Trace("CreateColliderPrefab " + fab.name); #if false Collider unityCollider = null; var colliders = fab.GetComponents <Collider>(); foreach (var col in colliders) { if (col.isTrigger) { unityCollider = col; break; } } if (unityCollider == null) { foreach (var col in colliders) { unityCollider = col; break; } } if (unityCollider == null) { return(null); } CBaseShape collider = null; if (unityCollider is BoxCollider boxCol) { collider = new COBB(boxCol.size.ToLVector2XZ(), LFloat.zero); } if (unityCollider is SphereCollider cirCol) { collider = new CCircle(cirCol.radius.ToLFloat()); } if (unityCollider is CapsuleCollider capCol) { collider = new CCircle(capCol.radius.ToLFloat()); } if (collider is COBB tObb) { Debug.LogTrace($"{fab.name} CreateCollider OBB deg: {tObb.deg} up:{tObb.up} radius:{tObb.radius}"); } if (collider is CCircle tCircle) { Debug.LogTrace($"{fab.name} CreateCollider Circle deg: radius:{tCircle.radius}"); } #else CBaseShape collider = null; var data = fab.GetComponent <ColliderDataMono>()?.colliderData; if (data == null) { Debug.LogError(fab.name + " Miss ColliderDataMono "); return(null); } if (data.radius > 0) { //circle collider = new CCircle(data.radius); } else { //obb collider = new COBB(data.size, data.deg); } Debug.Trace($"{fab.name} !!!CreateCollider deg: {data.deg} up:{data.size} radius:{data.radius}"); #endif var colFab = new ColliderPrefab(); colFab.parts.Add(new ColliderPart() { transform = new CTransform2D(LVector2.zero), collider = collider }); return(colFab); }