本文整理汇总了C++中idPlane::Normal方法的典型用法代码示例。如果您正苦于以下问题:C++ idPlane::Normal方法的具体用法?C++ idPlane::Normal怎么用?C++ idPlane::Normal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idPlane
的用法示例。
在下文中一共展示了idPlane::Normal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_LocalPlaneToGlobal
void R_LocalPlaneToGlobal( const float modelMatrix[16], const idPlane &in, idPlane &out ) {
float offset;
R_LocalVectorToGlobal( modelMatrix, in.Normal(), out.Normal() );
offset = modelMatrix[12] * out[0] + modelMatrix[13] * out[1] + modelMatrix[14] * out[2];
out[3] = in[3] - offset;
}
示例2: FromWinding
/*
============
idBrush::FromWinding
============
*/
bool idBrush::FromWinding( const idWinding& w, const idPlane& windingPlane )
{
int i, j, bestAxis;
idPlane plane;
idVec3 normal, axialNormal;
sides.Append( new idBrushSide( windingPlane, -1 ) );
sides.Append( new idBrushSide( -windingPlane, -1 ) );
bestAxis = 0;
for( i = 1; i < 3; i++ )
{
if( idMath::Fabs( windingPlane.Normal()[i] ) > idMath::Fabs( windingPlane.Normal()[bestAxis] ) )
{
bestAxis = i;
}
}
axialNormal = vec3_origin;
if( windingPlane.Normal()[bestAxis] > 0.0f )
{
axialNormal[bestAxis] = 1.0f;
}
else
{
axialNormal[bestAxis] = -1.0f;
}
for( i = 0; i < w.GetNumPoints(); i++ )
{
j = ( i + 1 ) % w.GetNumPoints();
normal = ( w[j].ToVec3() - w[i].ToVec3() ).Cross( axialNormal );
if( normal.Normalize() < 0.5f )
{
continue;
}
plane.SetNormal( normal );
plane.FitThroughPoint( w[j].ToVec3() );
sides.Append( new idBrushSide( plane, -1 ) );
}
if( sides.Num() < 4 )
{
for( i = 0; i < sides.Num(); i++ )
{
delete sides[i];
}
sides.Clear();
return false;
}
sides[0]->winding = w.Copy();
windingsValid = true;
BoundBrush();
return true;
}
示例3: PlaneSide
/*
================
idBox::PlaneSide
================
*/
int idBox::PlaneSide( const idPlane &plane, const float epsilon ) const {
float d1, d2;
d1 = plane.Distance( center );
d2 = idMath::Fabs( extents[0] * plane.Normal()[0] ) +
idMath::Fabs( extents[1] * plane.Normal()[1] ) +
idMath::Fabs( extents[2] * plane.Normal()[2] );
if ( d1 - d2 > epsilon ) {
return PLANESIDE_FRONT;
}
if ( d1 + d2 < -epsilon ) {
return PLANESIDE_BACK;
}
return PLANESIDE_CROSS;
}
示例4: PlaneDistance
/*
================
idBox::PlaneDistance
================
*/
float idBox::PlaneDistance( const idPlane &plane ) const {
float d1, d2;
d1 = plane.Distance( center );
d2 = idMath::Fabs( extents[0] * plane.Normal()[0] ) +
idMath::Fabs( extents[1] * plane.Normal()[1] ) +
idMath::Fabs( extents[2] * plane.Normal()[2] );
if ( d1 - d2 > 0.0f ) {
return d1 - d2;
}
if ( d1 + d2 < 0.0f ) {
return d1 + d2;
}
return 0.0f;
}
示例5: PlaneSide
/*
================
idBounds::PlaneSide
================
*/
int idBounds::PlaneSide( const idPlane &plane, const float epsilon ) const {
idVec3 center;
float d1, d2;
center = ( b[0] + b[1] ) * 0.5f;
d1 = plane.Distance( center );
d2 = idMath::Fabs( ( b[1][0] - center[0] ) * plane.Normal()[0] ) +
idMath::Fabs( ( b[1][1] - center[1] ) * plane.Normal()[1] ) +
idMath::Fabs( ( b[1][2] - center[2] ) * plane.Normal()[2] );
if ( d1 - d2 > epsilon ) {
return PLANESIDE_FRONT;
}
if ( d1 + d2 < -epsilon ) {
return PLANESIDE_BACK;
}
return PLANESIDE_CROSS;
}
示例6: PlaneDistance
/*
================
idBounds::PlaneDistance
================
*/
float idBounds::PlaneDistance( const idPlane &plane ) const {
idVec3 center;
float d1, d2;
center = ( b[0] + b[1] ) * 0.5f;
d1 = plane.Distance( center );
d2 = idMath::Fabs( ( b[1][0] - center[0] ) * plane.Normal()[0] ) +
idMath::Fabs( ( b[1][1] - center[1] ) * plane.Normal()[1] ) +
idMath::Fabs( ( b[1][2] - center[2] ) * plane.Normal()[2] );
if ( d1 - d2 > 0.0f ) {
return d1 - d2;
}
if ( d1 + d2 < 0.0f ) {
return d1 + d2;
}
return 0.0f;
}
示例7: PlaneIntersection
/*
================
idPlane::PlaneIntersection
================
*/
bool idPlane::PlaneIntersection( const idPlane &plane, idVec3 &start, idVec3 &dir ) const {
double n00, n01, n11, det, invDet, f0, f1;
n00 = Normal().LengthSqr();
n01 = Normal() * plane.Normal();
n11 = plane.Normal().LengthSqr();
det = n00 * n11 - n01 * n01;
if ( idMath::Fabs(det) < 1e-6f ) {
return false;
}
invDet = 1.0f / det;
f0 = ( n01 * plane.d - n11 * d ) * invDet;
f1 = ( n01 * d - n00 * plane.d ) * invDet;
dir = Normal().Cross( plane.Normal() );
start = f0 * Normal() + f1 * plane.Normal();
return true;
}
示例8: EdgeSplitPoint
/*
============
idAASLocal::EdgeSplitPoint
calculates split point of the edge with the plane
returns true if the split point is between the edge vertices
============
*/
bool idAASLocal::EdgeSplitPoint( idVec3 &split, int edgeNum, const idPlane &plane ) const {
const aasEdge_t *edge;
idVec3 v1, v2;
float d1, d2;
edge = &file->GetEdge( edgeNum );
v1 = file->GetVertex( edge->vertexNum[0] );
v2 = file->GetVertex( edge->vertexNum[1] );
d1 = v1 * plane.Normal() - plane.Dist();
d2 = v2 * plane.Normal() - plane.Dist();
//if ( (d1 < CM_CLIP_EPSILON && d2 < CM_CLIP_EPSILON) || (d1 > -CM_CLIP_EPSILON && d2 > -CM_CLIP_EPSILON) ) {
if( FLOATSIGNBITSET( d1 ) == FLOATSIGNBITSET( d2 ) ) {
return false;
}
split = v1 + ( d1 / ( d1 - d2 ) ) * ( v2 - v1 );
return true;
}
示例9: Split
/*
=================
idSurface::Split
=================
*/
int idSurface::Split( const idPlane &plane, const float epsilon, idSurface **front, idSurface **back, int *frontOnPlaneEdges, int *backOnPlaneEdges ) const {
float * dists;
float f;
byte * sides;
int counts[3];
int * edgeSplitVertex;
int numEdgeSplitVertexes;
int * vertexRemap[2];
int vertexIndexNum[2][2];
int * vertexCopyIndex[2];
int * indexPtr[2];
int indexNum[2];
int * index;
int * onPlaneEdges[2];
int numOnPlaneEdges[2];
int maxOnPlaneEdges;
int i;
idSurface * surface[2];
idDrawVert v;
dists = (float *) _alloca( verts.Num() * sizeof( float ) );
sides = (byte *) _alloca( verts.Num() * sizeof( byte ) );
counts[0] = counts[1] = counts[2] = 0;
// determine side for each vertex
for ( i = 0; i < verts.Num(); i++ ) {
dists[i] = f = plane.Distance( verts[i].xyz );
if ( f > epsilon ) {
sides[i] = SIDE_FRONT;
} else if ( f < -epsilon ) {
sides[i] = SIDE_BACK;
} else {
sides[i] = SIDE_ON;
}
counts[sides[i]]++;
}
*front = *back = NULL;
// if coplanar, put on the front side if the normals match
if ( !counts[SIDE_FRONT] && !counts[SIDE_BACK] ) {
f = ( verts[indexes[1]].xyz - verts[indexes[0]].xyz ).Cross( verts[indexes[0]].xyz - verts[indexes[2]].xyz ) * plane.Normal();
if ( FLOATSIGNBITSET( f ) ) {
*back = new idSurface( *this );
return SIDE_BACK;
} else {
*front = new idSurface( *this );
return SIDE_FRONT;
}
}
// if nothing at the front of the clipping plane
if ( !counts[SIDE_FRONT] ) {
*back = new idSurface( *this );
return SIDE_BACK;
}
// if nothing at the back of the clipping plane
if ( !counts[SIDE_BACK] ) {
*front = new idSurface( *this );
return SIDE_FRONT;
}
// allocate front and back surface
*front = surface[0] = new idSurface();
*back = surface[1] = new idSurface();
edgeSplitVertex = (int *) _alloca( edges.Num() * sizeof( int ) );
numEdgeSplitVertexes = 0;
maxOnPlaneEdges = 4 * counts[SIDE_ON];
counts[SIDE_FRONT] = counts[SIDE_BACK] = counts[SIDE_ON] = 0;
// split edges
for ( i = 0; i < edges.Num(); i++ ) {
int v0 = edges[i].verts[0];
int v1 = edges[i].verts[1];
int sidesOr = ( sides[v0] | sides[v1] );
// if both vertexes are on the same side or one is on the clipping plane
if ( !( sides[v0] ^ sides[v1] ) || ( sidesOr & SIDE_ON ) ) {
edgeSplitVertex[i] = -1;
counts[sidesOr & SIDE_BACK]++;
counts[SIDE_ON] += ( sidesOr & SIDE_ON ) >> 1;
} else {
示例10: R_ChopWinding
/*
=============
R_ChopWinding
Clips a triangle from one buffer to another, setting edge flags
The returned buffer may be the same as inNum if no clipping is done
If entirely clipped away, clipTris[returned].numVerts == 0
I have some worries about edge flag cases when polygons are clipped
multiple times near the epsilon.
=============
*/
static int R_ChopWinding( clipTri_t clipTris[2], int inNum, const idPlane plane ) {
clipTri_t *in, *out;
float dists[MAX_CLIPPED_POINTS];
int sides[MAX_CLIPPED_POINTS];
int counts[3];
float dot;
int i, j;
idVec3 mid;
bool front;
in = &clipTris[inNum];
out = &clipTris[inNum^1];
counts[0] = counts[1] = counts[2] = 0;
// determine sides for each point
front = false;
for ( i = 0; i < in->numVerts; i++ ) {
dot = in->verts[i] * plane.Normal() + plane[3];
dists[i] = dot;
if ( dot < LIGHT_CLIP_EPSILON ) { // slop onto the back
sides[i] = SIDE_BACK;
} else {
sides[i] = SIDE_FRONT;
if ( dot > LIGHT_CLIP_EPSILON ) {
front = true;
}
}
counts[sides[i]]++;
}
// if none in front, it is completely clipped away
if ( !front ) {
in->numVerts = 0;
return inNum;
}
if ( !counts[SIDE_BACK] ) {
return inNum; // inout stays the same
}
// avoid wrapping checks by duplicating first value to end
sides[i] = sides[0];
dists[i] = dists[0];
in->verts[in->numVerts] = in->verts[0];
out->numVerts = 0;
for ( i = 0 ; i < in->numVerts ; i++ ) {
idVec3 &p1 = in->verts[i];
if ( sides[i] == SIDE_FRONT ) {
out->verts[out->numVerts] = p1;
out->numVerts++;
}
if ( sides[i+1] == sides[i] ) {
continue;
}
// generate a split point
idVec3 &p2 = in->verts[i+1];
dot = dists[i] / ( dists[i] - dists[i+1] );
for ( j = 0; j < 3; j++ ) {
mid[j] = p1[j] + dot * ( p2[j] - p1[j] );
}
out->verts[out->numVerts] = mid;
out->numVerts++;
}
return inNum ^ 1;
}
示例11: Split
//.........这里部分代码省略.........
{
maxBackWinding[i] = dist;
}
}
if( maxFrontWinding[i] > maxFront )
{
maxFront = maxFrontWinding[i];
}
if( maxBackWinding[i] < maxBack )
{
maxBack = maxBackWinding[i];
}
}
if( maxFront < BRUSH_EPSILON )
{
if( back )
{
*back = Copy();
}
return PLANESIDE_BACK;
}
if( maxBack > -BRUSH_EPSILON )
{
if( front )
{
*front = Copy();
}
return PLANESIDE_FRONT;
}
mid = new idWinding( plane.Normal(), plane.Dist() );
for( i = 0; i < sides.Num() && mid; i++ )
{
mid = mid->Clip( -sides[i]->plane, BRUSH_EPSILON, false );
}
if( mid )
{
if( mid->IsTiny() )
{
delete mid;
mid = NULL;
}
else if( mid->IsHuge() )
{
// if the winding is huge then the brush is unbounded
common->Warning( "brush %d on entity %d is unbounded"
"( %1.2f %1.2f %1.2f )-( %1.2f %1.2f %1.2f )-( %1.2f %1.2f %1.2f )", primitiveNum, entityNum,
bounds[0][0], bounds[0][1], bounds[0][2], bounds[1][0], bounds[1][1], bounds[1][2],
bounds[1][0] - bounds[0][0], bounds[1][1] - bounds[0][1], bounds[1][2] - bounds[0][2] );
delete mid;
mid = NULL;
}
}
if( !mid )
{
if( maxFront > - maxBack )
{
if( front )
{
*front = Copy();
示例12: Split
/*
============
idBrushBSPNode::Split
============
*/
bool idBrushBSPNode::Split( const idPlane &splitPlane, int splitPlaneNum ) {
int s, i;
idWinding *mid;
idBrushBSPPortal *p, *midPortal, *newPortals[2];
idBrushBSPNode *newNodes[2];
mid = new idWinding( splitPlane.Normal(), splitPlane.Dist() );
for ( p = portals; p && mid; p = p->next[s] ) {
s = (p->nodes[1] == this);
if ( s ) {
mid = mid->Clip( -p->plane, 0.1f, false );
}
else {
mid = mid->Clip( p->plane, 0.1f, false );
}
}
if ( !mid ) {
return false;
}
// allocate two new nodes
for ( i = 0; i < 2; i++ ) {
newNodes[i] = new idBrushBSPNode();
newNodes[i]->flags = flags;
newNodes[i]->contents = contents;
newNodes[i]->parent = this;
}
// split all portals of the node
for ( p = portals; p; p = portals ) {
s = (p->nodes[1] == this);
p->Split( splitPlane, &newPortals[0], &newPortals[1] );
for ( i = 0; i < 2; i++ ) {
if ( newPortals[i] ) {
if ( s ) {
newPortals[i]->AddToNodes( p->nodes[0], newNodes[i] );
}
else {
newPortals[i]->AddToNodes( newNodes[i], p->nodes[1] );
}
}
}
p->RemoveFromNode( p->nodes[0] );
p->RemoveFromNode( p->nodes[1] );
delete p;
}
// add seperating portal
midPortal = new idBrushBSPPortal();
midPortal->plane = splitPlane;
midPortal->planeNum = splitPlaneNum;
midPortal->winding = mid;
midPortal->AddToNodes( newNodes[0], newNodes[1] );
// set new child nodes
children[0] = newNodes[0];
children[1] = newNodes[1];
plane = splitPlane;
return true;
}
示例13: CreateDecal
/*
=================
idRenderModelDecal::CreateDecal
=================
*/
void idRenderModelDecal::CreateDecal( const idRenderModel *model, const decalProjectionParms_t &localParms ) {
int maxVerts = 0;
for ( int surfNum = 0; surfNum < model->NumSurfaces(); surfNum++ ) {
const modelSurface_t *surf = model->Surface( surfNum );
if ( surf->geometry != NULL && surf->shader != NULL ) {
maxVerts = Max( maxVerts, surf->geometry->numVerts );
}
}
idTempArray< byte > cullBits( ALIGN( maxVerts, 4 ) );
// check all model surfaces
for ( int surfNum = 0; surfNum < model->NumSurfaces(); surfNum++ ) {
const modelSurface_t *surf = model->Surface( surfNum );
// if no geometry or no shader
if ( surf->geometry == NULL || surf->shader == NULL ) {
continue;
}
// decals and overlays use the same rules
if ( !localParms.force && !surf->shader->AllowOverlays() ) {
continue;
}
srfTriangles_t *tri = surf->geometry;
// if the triangle bounds do not overlap with the projection bounds
if ( !localParms.projectionBounds.IntersectsBounds( tri->bounds ) ) {
continue;
}
// decals don't work on animated models
assert( tri->staticModelWithJoints == NULL );
// catagorize all points by the planes
R_DecalPointCullStatic( cullBits.Ptr(), localParms.boundingPlanes, tri->verts, tri->numVerts );
// start streaming the indexes
idODSStreamedArray< triIndex_t, 256, SBT_QUAD, 3 > indexesODS( tri->indexes, tri->numIndexes );
// find triangles inside the projection volume
for ( int i = 0; i < tri->numIndexes; ) {
const int nextNumIndexes = indexesODS.FetchNextBatch() - 3;
for ( ; i <= nextNumIndexes; i += 3 ) {
const int i0 = indexesODS[i + 0];
const int i1 = indexesODS[i + 1];
const int i2 = indexesODS[i + 2];
// skip triangles completely off one side
if ( cullBits[i0] & cullBits[i1] & cullBits[i2] ) {
continue;
}
const idDrawVert * verts[3] = {
&tri->verts[i0],
&tri->verts[i1],
&tri->verts[i2]
};
// skip back facing triangles
const idPlane plane( verts[0]->xyz, verts[1]->xyz, verts[2]->xyz );
if ( plane.Normal() * localParms.boundingPlanes[NUM_DECAL_BOUNDING_PLANES - 2].Normal() < -0.1f ) {
continue;
}
// create a winding with texture coordinates for the triangle
idFixedWinding fw;
fw.SetNumPoints( 3 );
if ( localParms.parallel ) {
for ( int j = 0; j < 3; j++ ) {
fw[j] = verts[j]->xyz;
fw[j].s = localParms.textureAxis[0].Distance( verts[j]->xyz );
fw[j].t = localParms.textureAxis[1].Distance( verts[j]->xyz );
}
} else {
for ( int j = 0; j < 3; j++ ) {
const idVec3 dir = verts[j]->xyz - localParms.projectionOrigin;
float scale;
localParms.boundingPlanes[NUM_DECAL_BOUNDING_PLANES - 1].RayIntersection( verts[j]->xyz, dir, scale );
const idVec3 intersection = verts[j]->xyz + scale * dir;
fw[j] = verts[j]->xyz;
fw[j].s = localParms.textureAxis[0].Distance( intersection );
fw[j].t = localParms.textureAxis[1].Distance( intersection );
}
}
const int orBits = cullBits[i0] | cullBits[i1] | cullBits[i2];
// clip the exact surface triangle to the projection volume
for ( int j = 0; j < NUM_DECAL_BOUNDING_PLANES; j++ ) {
if ( ( orBits & ( 1 << j ) ) != 0 ) {
//.........这里部分代码省略.........
示例14: PointFurthestFromPlane
/*
================
idCollisionModelManagerLocal::PointFurthestFromPlane
calculates the direction of motion at the initial position, where dir < 0 means the point moves towards the plane
if the point moves away from the plane the tangent of half the rotation angle at which
the point is furthest away from the plane is also calculated
================
*/
int idCollisionModelManagerLocal::PointFurthestFromPlane( const cm_traceWork_t *tw, const idVec3 &point, const idPlane &plane,
const float angle, float &tanHalfAngle, float &dir ) {
double v1, v2, a, b, c, d, sqrtd, q, frac1, frac2;
idVec3 p, normal;
/*
v2 * cos(t) + v1 * sin(t) + v0 = 0;
// rotation about the z-axis
v0 = normal[2] * p[2] + dist
v1 = normal[0] * p[1] - normal[1] * p[0]
v2 = normal[0] * p[0] + normal[1] * p[1]
derivative:
v1 * cos(t) - v2 * sin(t) = 0;
r = tan(t / 2);
sin(t) = 2*r/(1+r*r);
cos(t) = (1-r*r)/(1+r*r);
-v2 * 2 * r / (1 + r*r) + v1 * (1 - r*r)/(1+r*r);
-v2 * 2 * r + v1 * (1 - r*r) / (1 + r*r) = 0;
-v2 * 2 * r + v1 * (1 - r*r) = 0;
(-v1) * r * r + (-2 * v2) * r + (v1) = 0;
*/
tanHalfAngle = 0.0f;
// transform rotation axis to z-axis
p = (point - tw->origin) * tw->matrix;
normal = plane.Normal() * tw->matrix;
v1 = normal[0] * p[1] - normal[1] * p[0];
v2 = normal[0] * p[0] + normal[1] * p[1];
// the point will always start at the front of the plane, therefore v0 + v2 > 0 is always true
if ( angle < 0.0f ) {
dir = -v1;
}
else {
dir = v1;
}
// negative direction means the point moves towards the plane at the initial position
if ( dir <= 0.0f ) {
return true;
}
a = -v1;
b = -v2;
c = v1;
if ( a == 0.0f ) {
if ( b == 0.0f ) {
return false;
}
frac1 = -c / ( 2.0f * b );
frac2 = 1e10; // = tan( idMath::HALF_PI )
}
else {
d = b * b - c * a;
if ( d <= 0.0f ) {
return false;
}
sqrtd = sqrt( d );
if ( b > 0.0f ) {
q = - b + sqrtd;
}
else {
q = - b - sqrtd;
}
frac1 = q / a;
frac2 = c / q;
}
if ( angle < 0.0f ) {
frac1 = -frac1;
frac2 = -frac2;
}
if ( frac1 < 0.0f && frac2 < 0.0f ) {
return false;
}
if ( frac1 > frac2 ) {
tanHalfAngle = frac1;
}
else {
tanHalfAngle = frac2;
}
//.........这里部分代码省略.........
示例15: RotatePointThroughPlane
/*
================
idCollisionModelManagerLocal::RotatePointThroughPlane
calculates the tangent of half the rotation angle at which the point collides with the plane
================
*/
int idCollisionModelManagerLocal::RotatePointThroughPlane( const cm_traceWork_t *tw, const idVec3 &point, const idPlane &plane,
const float angle, const float minTan, float &tanHalfAngle ) {
double v0, v1, v2, a, b, c, d, sqrtd, q, frac1, frac2;
idVec3 p, normal;
/*
p[0] = point[0] * cos(t) + point[1] * sin(t)
p[1] = point[0] * -sin(t) + point[1] * cos(t)
p[2] = point[2];
normal[0] * (p[0] * cos(t) + p[1] * sin(t)) +
normal[1] * (p[0] * -sin(t) + p[1] * cos(t)) +
normal[2] * p[2] + dist = 0
normal[0] * p[0] * cos(t) + normal[0] * p[1] * sin(t) +
-normal[1] * p[0] * sin(t) + normal[1] * p[1] * cos(t) +
normal[2] * p[2] + dist = 0
v2 * cos(t) + v1 * sin(t) + v0
// rotation about the z-axis
v0 = normal[2] * p[2] + dist
v1 = normal[0] * p[1] - normal[1] * p[0]
v2 = normal[0] * p[0] + normal[1] * p[1]
r = tan(t / 2);
sin(t) = 2*r/(1+r*r);
cos(t) = (1-r*r)/(1+r*r);
v1 * 2 * r / (1 + r*r) + v2 * (1 - r*r) / (1 + r*r) + v0 = 0
(v1 * 2 * r + v2 * (1 - r*r)) / (1 + r*r) = -v0
(v1 * 2 * r + v2 - v2 * r*r) / (1 + r*r) = -v0
v1 * 2 * r + v2 - v2 * r*r = -v0 * (1 + r*r)
v1 * 2 * r + v2 - v2 * r*r = -v0 + -v0 * r*r
(v0 - v2) * r * r + (2 * v1) * r + (v0 + v2) = 0;
*/
tanHalfAngle = tw->maxTan;
// transform rotation axis to z-axis
p = (point - tw->origin) * tw->matrix;
d = plane[3] + plane.Normal() * tw->origin;
normal = plane.Normal() * tw->matrix;
v0 = normal[2] * p[2] + d;
v1 = normal[0] * p[1] - normal[1] * p[0];
v2 = normal[0] * p[0] + normal[1] * p[1];
a = v0 - v2;
b = v1;
c = v0 + v2;
if ( a == 0.0f ) {
if ( b == 0.0f ) {
return false;
}
frac1 = -c / ( 2.0f * b );
frac2 = 1e10; // = tan( idMath::HALF_PI )
}
else {
d = b * b - c * a;
if ( d <= 0.0f ) {
return false;
}
sqrtd = sqrt( d );
if ( b > 0.0f ) {
q = - b + sqrtd;
}
else {
q = - b - sqrtd;
}
frac1 = q / a;
frac2 = c / q;
}
if ( angle < 0.0f ) {
frac1 = -frac1;
frac2 = -frac2;
}
// get smallest tangent for which a collision occurs
if ( frac1 >= minTan && frac1 < tanHalfAngle ) {
tanHalfAngle = frac1;
}
if ( frac2 >= minTan && frac2 < tanHalfAngle ) {
tanHalfAngle = frac2;
}
if ( angle < 0.0f ) {
tanHalfAngle = -tanHalfAngle;
}
//.........这里部分代码省略.........