本文整理汇总了C#中Vec3.Length方法的典型用法代码示例。如果您正苦于以下问题:C# Vec3.Length方法的具体用法?C# Vec3.Length怎么用?C# Vec3.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec3
的用法示例。
在下文中一共展示了Vec3.Length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VolumeCheckGetFirstNotFreePlace
bool VolumeCheckGetFirstNotFreePlace( Capsule[] sourceVolumeCapsules, Vec3 destVector, bool firstIteration, float step,
out List<Body> collisionBodies, out float collisionDistance, out bool collisionOnFirstCheck )
{
collisionBodies = new List<Body>();
collisionDistance = 0;
collisionOnFirstCheck = false;
bool firstCheck = true;
Vec3 direction = destVector.GetNormalize();
float totalDistance = destVector.Length();
int stepCount = (int)( (float)totalDistance / step ) + 2;
Vec3 previousOffset = Vec3.Zero;
for( int nStep = 0; nStep < stepCount; nStep++ )
{
float distance = (float)nStep * step;
if( distance > totalDistance )
distance = totalDistance;
Vec3 offset = direction * distance;
foreach( Capsule sourceVolumeCapsule in sourceVolumeCapsules )
{
Capsule checkCapsule = CapsuleAddOffset( sourceVolumeCapsule, offset );
Body[] bodies = PhysicsWorld.Instance.VolumeCast( checkCapsule, (int)ContactGroup.CastOnlyContact );
foreach( Body body in bodies )
{
if( body == mainBody || body == fixRotationJointBody )
continue;
collisionBodies.Add( body );
}
}
if( collisionBodies.Count != 0 )
{
//second iteration
if( nStep != 0 && firstIteration )
{
float step2 = step / 10;
Capsule[] sourceVolumeCapsules2 = new Capsule[ sourceVolumeCapsules.Length ];
for( int n = 0; n < sourceVolumeCapsules2.Length; n++ )
sourceVolumeCapsules2[ n ] = CapsuleAddOffset( sourceVolumeCapsules[ n ], previousOffset );
Vec3 destVector2 = offset - previousOffset;
List<Body> collisionBodies2;
float collisionDistance2;
bool collisionOnFirstCheck2;
if( VolumeCheckGetFirstNotFreePlace( sourceVolumeCapsules2, destVector2, false, step2, out collisionBodies2,
out collisionDistance2, out collisionOnFirstCheck2 ) )
{
collisionBodies = collisionBodies2;
collisionDistance = ( previousOffset != Vec3.Zero ? previousOffset.Length() : 0 ) + collisionDistance2;
collisionOnFirstCheck = false;
return true;
}
}
collisionDistance = distance;
collisionOnFirstCheck = firstCheck;
return true;
}
firstCheck = false;
previousOffset = offset;
}
return false;
}