#if !defined(MLR_MLRCLIPTRICK_HPP) #include #endif extern DWORD gEnableTextureSort, gShowClippedPolys, gEnableSimpleLight; extern WORD *indexOffset; // [MidLevelRenderer::Max_Number_Vertices_Per_Mesh] extern DWORD Trivial_Accepts; #define HUNT_CLIP_ERROR 0 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void CLASSNAME::TransformNoClip(Matrix4D *mat, GOSVertexPool *vt, FogData *fogData, DWORD paintMeColor, bool db) { Check_Object(this); Check_Object(vt); #ifdef I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_LIGHTING if(actualColors==NULL || actualColors->GetLength() == 0 || gEnableSimpleLight>0) { CLASSNAMENOCOLOR::TransformNoClip(mat, vt, fogData, paintMeColor, db); return; } #else if(colors.GetLength()==0) { CLASSNAMENOCOLOR::TransformNoClip(mat, vt, fogData, paintMeColor, db); return; } #endif #endif MLR_RENDER("Transform::NoClip::MLRPrimitiveClipping"); Start_Timer(Transform_Time); Verify(index.GetLength() > 0); WORD stride; bool textureAnimation = false; Scalar deltaU=0.0f, deltaV=0.0f; if(state.GetTextureHandle()) { MLRTexture *texture = (*MLRTexturePool::Instance)[state.GetTextureHandle()]; if(texture!=NULL) { MLRState::SetCurrentTextureSize(texture->GetImage()->GetWidth()); textureAnimation = texture->GetAnimateTexture(); if(textureAnimation) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU = (*textureMatrix)(3, 0); deltaV = (*textureMatrix)(3, 1); } } } int i, j, k, len = lengths.GetLength(); #ifdef I_SAY_YES_TO_DUAL_TEXTURES int tex2count = 0; #endif int numVertices = GetNumVertices(); if (numVertices>Limits::Max_Number_Vertices_Per_Mesh) { numVertices = Limits::Max_Number_Vertices_Per_Mesh; } gos_vertices = vt->GetActualVertexPool(db); numGOSVertices = 0; Verify(index.GetLength() > 0); if(visibleIndexedVerticesKey == false) { FindVisibleVertices(); } for(j=0,stride=0;jGetLast() + numGOSVertices < Limits::Max_Size_Of_Vertex_Buffer); } else { Verify (numGOSVertices < Limits::Max_Size_Of_Vertex_Buffer); } indexOffset[j] = (WORD)(j - stride); gos_vertices[numGOSVertices].GOSTransformNoClip( coords[j], *mat, &texCoords[j][0] #if FOG_HACK , (state.GetFogMode() != 0) #endif ); // gos_vertices[numGOSVertices].u = texCoords[j][0]; // gos_vertices[numGOSVertices].v = texCoords[j][1]; #ifdef I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_LIGHTING #if COLOR_AS_DWORD gos_vertices[numGOSVertices].argb = (*actualColors)[j]; #else gos_vertices[numGOSVertices].argb = GOSCopyColor(&(*actualColors)[j]); #endif #else #if COLOR_AS_DWORD gos_vertices[numGOSVertices].argb = colors[j]; #else gos_vertices[numGOSVertices].argb = GOSCopyColor(&colors[j]); #endif #endif #else gos_vertices[numGOSVertices].argb = paintMeColor; #endif #if 1 if(fogData!=NULL) { *((BYTE *)&gos_vertices[numGOSVertices].frgb + 3) = fogData->FogVertex(&coords[j]); } #else if(channelUse & 1<GetLast() + 2*numGOSVertices < vt->GetLength()); } else { Verify (numGOSVertices < Limits::Max_Size_Of_Vertex_Buffer); } if(state2.GetTextureHandle()) { MLRTexture *texture = (*MLRTexturePool::Instance)[state.GetTextureHandle()]; textureAnimation = texture->GetAnimateTexture(); if(textureAnimation) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU = (*textureMatrix)(3, 0); deltaV = (*textureMatrix)(3, 1); } } memcpy(gos_vertices + numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex)); if(textureAnimation) { for(i=0,j=numGOSVertices;iIncrease(2*numGOSVertices); } #else #ifdef I_SAY_YES_TO_DETAIL_TEXTURES if(db==false) { Verify (vt->GetLast() + 2*numGOSVertices < vt->GetLength()); } else { Verify (numGOSVertices < Limits::Max_Size_Of_Vertex_Buffer); } memcpy(gos_vertices + numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex)); for(i=0,j=numGOSVertices;iIncrease(2*numGOSVertices); } #else if(db==false) { vt->Increase(numGOSVertices); } #endif #endif gos_indices = vt->GetActualIndexPool(db); numGOSIndices = 0; int ngi = 0; for(i=0,j=0;i= 3); if((*testList)[i] == 0) { continue; } for(k=1;kGetLastIndex() + 3 + numGOSIndices) < vt->GetLength()); } else { Verify(3 + numGOSIndices < Limits::Max_Size_Of_Index_Buffer); } gos_indices[ngi++] = indexOffset[index[j]]; gos_indices[ngi++] = indexOffset[index[j+1+k]]; gos_indices[ngi++] = indexOffset[index[j+k]]; } } numGOSIndices = (WORD)ngi; Check_Object(vt); if(db==false) { vt->IncreaseIndex(numGOSIndices); } Stop_Timer(Transform_Time); visible = numGOSVertices ? (BYTE)1 : (BYTE)0; } static MLRClippingState theAnd, theOr, theTest; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Now it gets serious int CLASSNAME::TransformAndClip(Matrix4D *mat, MLRClippingState clippingFlags, GOSVertexPool *vt, FogData *fogData, DWORD paintMeColor, bool db) { #ifdef I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_LIGHTING if(actualColors==NULL || actualColors->GetLength() == 0 || gEnableSimpleLight>0) { return CLASSNAMENOCOLOR::TransformAndClip(mat, clippingFlags, vt, fogData, paintMeColor, db); } #else if(colors.GetLength()==0) { return CLASSNAMENOCOLOR::TransformAndClip(mat, clippingFlags, vt, fogData, paintMeColor, db); } #endif #endif WORD l; int i, j, k, ret = 0; int len; { MLR_RENDER("Transform::Clip::MLRPrimitiveClipping"); Start_Timer(Transform_Time); Verify(clippingFlags.GetClippingState() != 0); // //-------------------------------------- // See if we don't have to draw anything //-------------------------------------- // if(lengths.GetLength() <= 0) { visible = 0; Stop_Timer(Transform_Time); return visible; } Verify(index.GetLength() > 0); #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY Vector2DScalar terrainUV; #endif // CALCULATEuvONtheFLY #endif // I_SAY_YES_TO_TERRAIN2 len = coords.GetLength(); if(visibleIndexedVerticesKey == false) { FindVisibleVertices(); } Stuff::Vector4D *v4d = transformedCoords->GetData(); const Stuff::Point3D *p3d = coords.GetData(); int *cs = (int *)clipPerVertex->GetData(); BYTE *viv = visibleIndexedVertices->GetData(); if(fogData!=NULL) { for(i=0;iMultiplySetClip(*p3d, *mat, cs); (*extraChannels[2*FogChannel])[i] = fogData->FogVertex(p3d); #ifdef LAB_ONLY Set_Statistic(TransformedVertices, TransformedVertices+1); #endif // LAB_ONLY // //-------------------------------------------------------- // I claims all vertices are in. lets check it. who knows //-------------------------------------------------------- // #ifdef LAB_ONLY if( (*cs)==0) { #if defined(_ARMOR) if(ArmorLevel > 3) { // //-------------------------------------------------------- // I claims all vertices are in. lets check it. who knows //-------------------------------------------------------- // Verify(v4d->x >= 0.0f && v4d->x <= v4d->w ); Verify(v4d->y >= 0.0f && v4d->y <= v4d->w ); Verify(v4d->z >= 0.0f && v4d->z <= v4d->w ); } #endif // _ARMOR Set_Statistic(NonClippedVertices, NonClippedVertices+1); } else { Set_Statistic(ClippedVertices, ClippedVertices+1); } #endif // LAB_ONLY } } else { for(i=0;iMultiplySetClip(*p3d, *mat, cs); #ifdef LAB_ONLY Set_Statistic(TransformedVertices, TransformedVertices+1); #endif // LAB_ONLY // //-------------------------------------------------------- // I claims all vertices are in. lets check it. who knows //-------------------------------------------------------- // #ifdef LAB_ONLY if( (*cs)==0) { #if defined(_ARMOR) if(ArmorLevel > 3) { // //-------------------------------------------------------- // I claims all vertices are in. lets check it. who knows //-------------------------------------------------------- // Verify(v4d->x >= 0.0f && v4d->x <= v4d->w ); Verify(v4d->y >= 0.0f && v4d->y <= v4d->w ); Verify(v4d->z >= 0.0f && v4d->z <= v4d->w ); } #endif // _ARMOR Set_Statistic(NonClippedVertices, NonClippedVertices+1); } else { Set_Statistic(ClippedVertices, ClippedVertices+1); } #endif // LAB_ONLY } } Stop_Timer(Transform_Time); } MLR_RENDER("Clipping::MLRPrimitiveClipping"); Start_Timer(Clipping_Time); int mask, end, k0, k1, ct=0; Scalar a=0.0f; WORD stride; len = lengths.GetLength(); // Scalar bc0=0.0f, bc1=0.0f; bool textureAnimation = false; Scalar deltaU=0.0f, deltaV=0.0f; if(state.GetTextureHandle()) { MLRTexture *texture = (*MLRTexturePool::Instance)[state.GetTextureHandle()]; if(texture!=NULL) { MLRState::SetCurrentTextureSize(texture->GetImage()->GetWidth()); textureAnimation = texture->GetAnimateTexture(); if(textureAnimation) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU = (*textureMatrix)(3, 0); deltaV = (*textureMatrix)(3, 1); } } } #ifdef I_SAY_YES_TO_DUAL_TEXTURES bool textureAnimation2 = false; Scalar deltaU2=0.0f, deltaV2=0.0f; if(state2.GetTextureHandle()) { MLRTexture *texture = (*MLRTexturePool::Instance)[state.GetTextureHandle()]; textureAnimation2 = texture->GetAnimateTexture(); if(textureAnimation2) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU2 = (*textureMatrix)(3, 0); deltaV2 = (*textureMatrix)(3, 1); } } #endif #ifdef I_SAY_YES_TO_DUAL_TEXTURES int tex2count = 0; int numVertices = GetNumVertices(); if (numVertices>Limits::Max_Number_Vertices_Per_Mesh) { numVertices = Limits::Max_Number_Vertices_Per_Mesh; } #endif int myNumberUsedClipVertex, myNumberUsedClipIndex, myNumberUsedClipLength; myNumberUsedClipVertex = 0; myNumberUsedClipIndex = 0; myNumberUsedClipLength = 0; Verify(index.GetLength() > 0); if(visibleIndexedVerticesKey == false) { FindVisibleVertices(); } // //------------------------ // Handle the indexed case //------------------------ // // initialize visibleIndexedVertices memset(visibleIndexedVertices->GetData(), 0, visibleIndexedVertices->GetSize()); // //----------------------------------------------------------------- // Step through each polygon, making sure that we don't try to clip // backfaced polygons //----------------------------------------------------------------- // for(i=0,j=0;i 0); (*clipExtraColors)[clipped_index] = (*actualColors)[k0]; #else Verify(colors.GetLength() > 0); (*clipExtraColors)[clipped_index] = colors[k0]; #endif #endif Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index] = texCoords[k0]; #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*clipExtraTexCoords2)[clipped_index] = texCoords[k0+numVertices]; #endif if(channelUse > 0) { mask = 1; for(int n=0;n= 0.0f && a <= 1.0f); ct = l; break; } mask <<= 1; } // //------------------------------ // Lerp the homogeneous position //------------------------------ // if(firstIsIn==true) { (*clipExtraCoords)[clipped_index].Lerp( (*transformedCoords)[k0], (*transformedCoords)[k1], a ); DoClipTrick((*clipExtraCoords)[clipped_index], ct); // //---------------------------------------------------------- // If there are colors, lerp them in screen space for now as // most cards do that anyway //---------------------------------------------------------- // #ifdef I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_LIGHTING Verify((*actualColors).GetLength() > 0); #if COLOR_AS_DWORD (*clipExtraColors)[clipped_index] = Color_DWORD_Lerp ( (*actualColors)[k0], (*actualColors)[k1], a ); #else (*clipExtraColors)[clipped_index].Lerp( (*actualColors)[k0], (*actualColors)[k1], a ); #endif #else Verify(colors.GetLength() > 0); #if COLOR_AS_DWORD (*clipExtraColors)[clipped_index] = Color_DWORD_Lerp ( colors[k0], colors[k1], a ); #else (*clipExtraColors)[clipped_index].Lerp( colors[k0], colors[k1], a ); #endif #endif #endif // //----------------------------------------------------- // If there are texture uv's, we need to lerp them in a // perspective correct manner //----------------------------------------------------- // Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index].Lerp ( texCoords[k0], texCoords[k1], a ); #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*clipExtraTexCoords2)[clipped_index].Lerp ( texCoords[k0+numVertices], texCoords[k1+numVertices], a ); #endif if(channelUse > 0) { mask = 1; for(int n=0;n 0); #if COLOR_AS_DWORD (*clipExtraColors)[clipped_index] = Color_DWORD_Lerp ( (*actualColors)[k1], (*actualColors)[k0], a ); #else (*clipExtraColors)[clipped_index].Lerp( (*actualColors)[k1], (*actualColors)[k0], a ); #endif #else Verify(colors.GetLength() > 0); #if COLOR_AS_DWORD (*clipExtraColors)[clipped_index] = Color_DWORD_Lerp ( colors[k1], colors[k0], a ); #else (*clipExtraColors)[clipped_index].Lerp( colors[k1], colors[k0], a ); #endif #endif #endif // //----------------------------------------------------- // If there are texture uv's, we need to lerp them in a // perspective correct manner //----------------------------------------------------- // Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index].Lerp ( texCoords[k1], texCoords[k0], a ); #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*clipExtraTexCoords2)[clipped_index].Lerp ( texCoords[k1+numVertices], texCoords[k0+numVertices], a ); #endif if(channelUse > 0) { mask = 1; for(int n=0;n 0); srcPolygon.coords = clipBuffer[dstBuffer].coords.GetData(); #ifdef I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_LIGHTING Verify((*actualColors).GetLength() > 0); #else Verify(colors.GetLength() > 0); #endif srcPolygon.colors = clipBuffer[dstBuffer].colors.GetData(); #endif srcPolygon.texCoords = clipBuffer[dstBuffer].texCoords.GetData(); srcPolygon.clipPerVertex = clipBuffer[dstBuffer].clipPerVertex.GetData(); if(channelUse > 0) { mask = 1; for(int n=0;n0 DWORD2Color(srcPolygon.colors[l], (*actualColors)[indexK]); #else srcPolygon.colors[l] = (*actualColors)[indexK]; #endif #else #if COLOR_AS_DWORD>0 DWORD2Color(srcPolygon.colors[l], colors[indexK]); #else srcPolygon.colors[l] = colors[indexK]; #endif #endif #endif #ifdef I_SAY_YES_TO_DUAL_TEXTURES srcPolygon.texCoords[2*l] = texCoords[indexK]; srcPolygon.texCoords[2*l+1] = texCoords[indexK + numVertices]; #else srcPolygon.texCoords[l] = texCoords[indexK]; #endif srcPolygon.clipPerVertex[l] = (*clipPerVertex)[indexK]; if(channelUse > 0) { mask = 1; for(int n=0;n 0) { mask = 1; for(int n=0;n 0) { mask = 1; for(int n=0;n= 0.0f && a <= 1.0f); // //------------------------------ // Lerp the homogeneous position //------------------------------ // dstPolygon.coords[dstPolygon.length].Lerp( srcPolygon.coords[k], srcPolygon.coords[k1], a ); #if HUNT_CLIP_ERROR DEBUG_STREAM << "True " << a << " " << k << " " << k1 << " we get " << dstPolygon.length << '\n'; DEBUG_STREAM << setiosflags( ios::scientific) << setprecision(20) << dstPolygon.coords[dstPolygon.length].x << " " << dstPolygon.coords[dstPolygon.length].y << " " << dstPolygon.coords[dstPolygon.length].z << " " << dstPolygon.coords[dstPolygon.length].w << '\n'; #endif DoClipTrick(dstPolygon.coords[dstPolygon.length], l); // //---------------------------------------------------------- // If there are colors, lerp them in screen space for now as // most cards do that anyway //---------------------------------------------------------- // #ifdef I_SAY_YES_TO_COLOR dstPolygon.colors[dstPolygon.length].Lerp( srcPolygon.colors[k], srcPolygon.colors[k1], a ); #endif // //----------------------------------------------------- // If there are texture uv's, we need to lerp them in a // perspective correct manner //----------------------------------------------------- // #ifdef I_SAY_YES_TO_DUAL_TEXTURES dstPolygon.texCoords[2*dstPolygon.length].Lerp ( srcPolygon.texCoords[2*k], srcPolygon.texCoords[2*k1], a ); dstPolygon.texCoords[2*dstPolygon.length+1].Lerp ( srcPolygon.texCoords[2*k+1], srcPolygon.texCoords[2*k1+1], a ); #else dstPolygon.texCoords[dstPolygon.length].Lerp ( srcPolygon.texCoords[k], srcPolygon.texCoords[k1], a ); #endif if(channelUse > 0) { mask = 1; for(int n=0;n= 0.0f && a <= 1.0f); // //------------------------------ // Lerp the homogeneous position //------------------------------ // dstPolygon.coords[dstPolygon.length].Lerp( srcPolygon.coords[k1], srcPolygon.coords[k], a ); #if HUNT_CLIP_ERROR DEBUG_STREAM << "False " << a << " " << k << " " << k1 << " we get " << dstPolygon.length << '\n'; DEBUG_STREAM << setiosflags( ios::scientific) << setprecision(20) << dstPolygon.coords[dstPolygon.length].x << " " << dstPolygon.coords[dstPolygon.length].y << " " << dstPolygon.coords[dstPolygon.length].z << " " << dstPolygon.coords[dstPolygon.length].w << '\n'; #endif DoClipTrick(dstPolygon.coords[dstPolygon.length], l); // //---------------------------------------------------------- // If there are colors, lerp them in screen space for now as // most cards do that anyway //---------------------------------------------------------- // #ifdef I_SAY_YES_TO_COLOR dstPolygon.colors[dstPolygon.length].Lerp( srcPolygon.colors[k1], srcPolygon.colors[k], a ); #endif // //----------------------------------------------------- // If there are texture uv's, we need to lerp them in a // perspective correct manner //----------------------------------------------------- // #ifdef I_SAY_YES_TO_DUAL_TEXTURES dstPolygon.texCoords[2*dstPolygon.length].Lerp ( srcPolygon.texCoords[2*k1], srcPolygon.texCoords[2*k], a ); dstPolygon.texCoords[2*dstPolygon.length+1].Lerp ( srcPolygon.texCoords[2*k1+1], srcPolygon.texCoords[2*k+1], a ); #else dstPolygon.texCoords[dstPolygon.length].Lerp ( srcPolygon.texCoords[k1], srcPolygon.texCoords[k], a ); #endif if(channelUse > 0) { mask = 1; for(int n=0;n 0) { mask = 1; for(int n=0;n 0) { mask = 1; for(int n=0;n0 (*clipExtraColors)[clipped_index] = GOSCopyColor(&srcPolygon.colors[k]); #else (*clipExtraColors)[clipped_index] = srcPolygon.colors[k]; #endif #endif #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*clipExtraTexCoords)[clipped_index] = srcPolygon.texCoords[2*k]; (*clipExtraTexCoords2)[clipped_index] = srcPolygon.texCoords[2*k+1]; #else (*clipExtraTexCoords)[clipped_index] = srcPolygon.texCoords[k]; #endif if(channelUse > 0) { mask = 1; for(int n=0;nGetActualVertexPool(db); numGOSVertices = 0; gos_indices = vt->GetActualIndexPool(db); numGOSIndices = 0; k = visibleIndexedVertices->GetLength(); for(j=0,stride=0;jGetData(), #ifdef I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_LIGHTING actualColors->GetData(), #else colors.GetData(), #endif #endif texCoords.GetData(), j ); if(textureAnimation) { gos_vertices[numGOSVertices].u += deltaU; gos_vertices[numGOSVertices].v += deltaV; } #ifdef LAB_ONLY if(gShowClippedPolys) { gos_vertices[numGOSVertices].argb = 0xff0000ff; gos_vertices[numGOSVertices].u = 0.0f; gos_vertices[numGOSVertices].v = 0.0f; } #endif #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*texCoords2)[tex2count++] = texCoords[numVertices + j]; #endif numGOSVertices++; } } for(i=0,j=0;i= 3); if((*testList)[i] == 0) { j += stride; continue; } for(k=1;kGetLastIndex() + 3 + numGOSIndices) < vt->GetLength()); } else { Verify(3 + numGOSIndices < Limits::Max_Size_Of_Index_Buffer); } gos_indices[numGOSIndices] = (WORD)(index[j] - indexOffset[index[j]]); gos_indices[numGOSIndices+1] = (WORD)(index[j+k+1] - indexOffset[index[j+k+1]]); gos_indices[numGOSIndices+2] = (WORD)(index[j+k] - indexOffset[index[j+k]]); numGOSIndices += 3; } j += stride; } if(myNumberUsedClipLength > 0) { for(i=0,j=0;i((*clipExtraLength)[i] & 0x7fff); #else stride = (*clipExtraLength)[i]; #endif #if 0 for(k=j;k -SMALL) { clipExtraCoords[k].x = 0.0f; } if(clipExtraCoords[k].y < 0.0f && clipExtraCoords[k].y > -SMALL) { clipExtraCoords[k].y = 0.0f; } if(clipExtraCoords[k].z < 0.0f && clipExtraCoords[k].z > -SMALL) { clipExtraCoords[k].z = 0.0f; } if(clipExtraCoords[k].x > clipExtraCoords[k].w && clipExtraCoords[k].x < clipExtraCoords[k].w + SMALL) { clipExtraCoords[k].x = clipExtraCoords[k].w; } if(clipExtraCoords[k].y > clipExtraCoords[k].w && clipExtraCoords[k].y < clipExtraCoords[k].w + SMALL) { clipExtraCoords[k].y = clipExtraCoords[k].w; } if(clipExtraCoords[k].z >= clipExtraCoords[k].w && clipExtraCoords[k].z < clipExtraCoords[k].w + SMALL) { clipExtraCoords[k].z = clipExtraCoords[k].w - SMALL; } } #endif for(k=1;kGetLast() + 3 + numGOSVertices) < vt->GetLength()); Verify((vt->GetLastIndex() + 3 + numGOSIndices) < vt->GetLength()); } else { Verify(3 + numGOSVertices < Limits::Max_Size_Of_Vertex_Buffer); Verify(3 + numGOSIndices < Limits::Max_Size_Of_Index_Buffer); } if(channelUse & 1<GetData(), #ifdef I_SAY_YES_TO_COLOR clipExtraColors->GetData(), #endif clipExtraTexCoords->GetData(), j, j+k+1, j+k ); if(textureAnimation) { gos_vertices[numGOSVertices].u += deltaU; gos_vertices[numGOSVertices].v += deltaV; gos_vertices[numGOSVertices+1].u += deltaU; gos_vertices[numGOSVertices+1].v += deltaV; gos_vertices[numGOSVertices+2].u += deltaU; gos_vertices[numGOSVertices+2].v += deltaV; } #ifdef LAB_ONLY if(gShowClippedPolys) { if((*clipExtraLength)[i] & 0x8000) { gos_vertices[numGOSVertices].argb = 0xffff0000; gos_vertices[numGOSVertices].u = 0.0f; gos_vertices[numGOSVertices].v = 0.0f; gos_vertices[numGOSVertices+1].argb = 0xffff0000; gos_vertices[numGOSVertices+1].u = 0.0f; gos_vertices[numGOSVertices+1].v = 0.0f; gos_vertices[numGOSVertices+2].argb = 0xffff0000; gos_vertices[numGOSVertices+2].u = 0.0f; gos_vertices[numGOSVertices+2].v = 0.0f; } else { gos_vertices[numGOSVertices].argb = 0xffff9999; gos_vertices[numGOSVertices].u = 0.0f; gos_vertices[numGOSVertices].v = 0.0f; gos_vertices[numGOSVertices+1].argb = 0xffff9999; gos_vertices[numGOSVertices+1].u = 0.0f; gos_vertices[numGOSVertices+1].v = 0.0f; gos_vertices[numGOSVertices+2].argb = 0xffff9999; gos_vertices[numGOSVertices+2].u = 0.0f; gos_vertices[numGOSVertices+2].v = 0.0f; } } #endif #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j]; (*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j+k+1]; (*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j+k]; #endif if(db==false) { Verify((vt->GetLastIndex() + 3 + numGOSIndices) < vt->GetLength()); } else { Verify(3 + numGOSIndices < Limits::Max_Size_Of_Index_Buffer); } Verify(numGOSIndices%3 == 0); gos_indices[numGOSIndices] = numGOSVertices; gos_indices[numGOSIndices+1] = (WORD)(numGOSVertices + 1); gos_indices[numGOSIndices+2] = (WORD)(numGOSVertices + 2); numGOSVertices += 3; numGOSIndices += 3; } j += stride; } #if HUNT_CLIP_ERROR DEBUG_STREAM << "***" << endl << endl; #endif } #ifdef LAB_ONLY else { Trivial_Accepts++; } #endif #ifdef I_SAY_YES_TO_DUAL_TEXTURES Verify (tex2count == numGOSVertices); if(db==false) { Verify (vt->GetLast() + 2*numGOSVertices < vt->GetLength()); } else { Verify (2*numGOSVertices < 2*Limits::Max_Number_Vertices_Per_Mesh); } memcpy(gos_vertices + numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex)); if(textureAnimation2) { for(i=0,j=numGOSVertices;iIncrease(2*numGOSVertices); } #else #ifdef I_SAY_YES_TO_DETAIL_TEXTURES if(db==false) { Verify (vt->GetLast() + 2*numGOSVertices < vt->GetLength()); } else { Verify (numGOSVertices < Limits::Max_Size_Of_Vertex_Buffer); } memcpy(gos_vertices + numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex)); for(i=0,j=numGOSVertices;iIncrease(2*numGOSVertices); } #else if(db==false) { vt->Increase(numGOSVertices); } #endif #endif if(db==false) { vt->IncreaseIndex(numGOSIndices); } visible = numGOSVertices ? (BYTE)1 : (BYTE)0; if(visible) { } else { } Stop_Timer(Clipping_Time); return ret; }