#if !defined(MLR_MLRCLIPTRICK_HPP) #include #endif extern DWORD gEnableTextureSort, gShowClippedPolys, gEnableDetailTexture, gShowBucketColors, gEnableSimpleLight; extern WORD *indexOffset; // [MidLevelRenderer::Max_Number_Vertices_Per_Mesh] extern DWORD Trivial_Accepts; #define HUNT_CLIP_ERROR 0 //#define HUNT_CLIP_ERROR2 "micgaert" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void CLASSNAME::TransformNoClip(Matrix4D *mat, GOSVertexPool *vt, FogData *fogData, DWORD paintMeColor, bool db) { Check_Object(this); Check_Object(vt); Verify(index.GetLength() > 0); #ifdef I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_LIGHTING if(actualColors==NULL || actualColors->GetLength() == 0 || gEnableSimpleLight>0 #ifdef LAB_ONLY || gShowBucketColors>0 #endif ) { CLASSNAMENOCOLOR::TransformNoClip(mat, vt, fogData, paintMeColor, db); return; } #else if(colors.GetLength()==0 #ifdef LAB_ONLY || gShowBucketColors>0 #endif ) { CLASSNAMENOCOLOR::TransformNoClip(mat, vt, fogData, paintMeColor, db); return; } #endif #endif MLR_RENDER("Transform::NoClip::MLRTriangleClipping"); Start_Timer(Transform_Time); // WORD stride; int stride; #ifndef I_SAY_YES_TO_TERRAIN2 bool textureAnimation = false; Scalar deltaU=0.0f, deltaV=0.0f; #endif // I_SAY_YES_TO_TERRAIN2 if(state.GetTextureHandle()) { MLRTexture *texture = (*MLRTexturePool::Instance)[state.GetTextureHandle()]; if(texture!=NULL) { MLRState::SetCurrentTextureSize(texture->GetImage()->GetWidth()); #ifndef I_SAY_YES_TO_TERRAIN2 if(true==(textureAnimation = texture->GetAnimateTexture())) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU = (*textureMatrix)(3, 0); deltaV = (*textureMatrix)(3, 1); } #endif // I_SAY_YES_TO_TERRAIN2 } } #if defined(I_SAY_YES_TO_DUAL_TEXTURES) || defined(I_SAY_YES_TO_DETAIL_TEXTURES) gos_vertices2uv = vt->GetActualVertexPool2UV(db); #ifndef I_SAY_YES_TO_TERRAIN2 bool textureAnimation2 = false; Scalar deltaU2=0.0f, deltaV2=0.0f; if(state2.GetTextureHandle()) { MLRTexture *texture = (*MLRTexturePool::Instance)[state2.GetTextureHandle()]; if(texture!=NULL && true==(textureAnimation2 = texture->GetAnimateTexture())) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU2 = (*textureMatrix)(3, 0); deltaV2 = (*textureMatrix)(3, 1); } } #endif // I_SAY_YES_TO_TERRAIN2 #endif // I_SAY_YES_TO_DUAL_TEXTURES || I_SAY_YES_TO_DETAIL_TEXTURES int i, j; #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY Scalar terrainUV[2]; #endif // CALCULATEuvONtheFLY #endif // I_SAY_YES_TO_TERRAIN2 int numVertices = GetNumVertices(); if (numVertices>Limits::Max_Number_Vertices_Per_Mesh) { numVertices = Limits::Max_Number_Vertices_Per_Mesh; } #ifdef I_SAY_YES_TO_BUMP_TEXTURE bool textureAnimation2 = false; Scalar deltaU2=0.0f, deltaV2=0.0f; if(textureNorm) { MLRTexture *texture = (*MLRTexturePool::Instance)[textureNorm]; Verify(texture); if(texture!=NULL && true==(textureAnimation2 = texture->GetAnimateTexture())) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU2 = (*textureMatrix)(3, 0); deltaV2 = (*textureMatrix)(3, 1); } } gos_vertices3uv = vt->GetActualVertexPool3UV(db); #else gos_vertices = vt->GetActualVertexPool(db); #endif #ifdef I_SAY_YES_TO_DUAL_TEXTURES int tex2count = 0; #endif // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_DETAIL_TEXTURES Scalar detailTexCoords[2]; #endif // I_SAY_YES_TO_DETAIL_TEXTURES #if defined(I_SAY_YES_TO_DUAL_TEXTURES) || defined(I_SAY_YES_TO_DETAIL_TEXTURES) gos_vertices2uv = vt->GetActualVertexPool2UV(db); #endif numGOSVertices = 0; Verify(index.GetLength() > 0); if(visibleIndexedVerticesKey == false) { FindVisibleVertices(); } #ifdef _ARMOR memset(indexOffset, 0xff, Limits::Max_Size_Of_Index_Buffer*sizeof(WORD)); #endif // _ARMOR for(j=0,stride=0;jGetLast() + numGOSVertices < Limits::Max_Number_Vertices_Per_Frame); } else { Verify (numGOSVertices < Limits::Max_Size_Of_Index_Buffer); } #endif // LAB_ONLY *(int *)(&indexOffset[j]) = (j - stride); #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY CalculateUV(j, terrainUV[0], terrainUV[1]); #endif // CALCULATEuvONtheFLY #endif // I_SAY_YES_TO_TERRAIN2 #ifdef I_SAY_YES_TO_DUAL_TEXTURES if(MLRState::GetMultitextureLightMap() == true && state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode) { gos_vertices2uv[numGOSVertices].GOSTransformNoClip( coords[j], *mat, &texCoords[j][0], &texCoords[numVertices + j][0] #if FOG_HACK ,state.GetFogMode() #endif // FOG_HACK ); #ifdef I_SAY_YES_TO_COLOR #if COLOR_AS_DWORD gos_vertices2uv[numGOSVertices].argb = (*actualColors)[j]; #else // COLOR_AS_DWORD gos_vertices2uv[numGOSVertices].argb = GOSCopyColor(&(*actualColors)[j]); #endif // COLOR_AS_DWORD #else // I_SAY_YES_TO_COLOR gos_vertices2uv[numGOSVertices].argb = paintMeColor; #endif // I_SAY_YES_TO_COLOR #if 1 if(fogData!=NULL) { *((BYTE *)&gos_vertices2uv[numGOSVertices].frgb + 3) = fogData->FogVertex(&coords[j]); } #else if(channelUse & 1<FogVertex(&coords[j]); } #else if(channelUse & 1<=-MLRState::GetMaxUV() && detailTexCoords[0]<=MLRState::GetMaxUV()) : 1); Verify( MLRState::GetHasMaxUVs() ? (detailTexCoords[1]>=-MLRState::GetMaxUV() && detailTexCoords[1]<=MLRState::GetMaxUV()) : 1); #endif // UV_CHECK #ifdef CALCULATEuvONtheFLY gos_vertices2uv[numGOSVertices].GOSTransformNoClip( coords[j], *mat, #ifdef I_SAY_YES_TO_TERRAIN2 terrainUV, #else &texCoords[j][0], #endif &detailTexCoords[0] #if FOG_HACK ,state.GetFogMode() #endif // FOG_HACK ); #else // CALCULATEuvONtheFLY gos_vertices2uv[numGOSVertices].GOSTransformNoClip( coords[j], *mat, &texCoords[j][0], &detailTexCoords[0] #if FOG_HACK ,state.GetFogMode() #endif // FOG_HACK ); #endif // CALCULATEuvONtheFLY #ifdef I_SAY_YES_TO_COLOR #if COLOR_AS_DWORD gos_vertices2uv[numGOSVertices].argb = (*actualColors)[j]; #else // COLOR_AS_DWORD gos_vertices2uv[numGOSVertices].argb = GOSCopyColor(&(*actualColors)[j]); #endif // COLOR_AS_DWORD #else // I_SAY_YES_TO_COLOR gos_vertices2uv[numGOSVertices].argb = paintMeColor; #endif // I_SAY_YES_TO_COLOR } else #endif // I_SAY_YES_TO_DETAIL_TEXTURES { #ifdef CALCULATEuvONtheFLY gos_vertices[numGOSVertices].GOSTransformNoClip( coords[j], *mat, #ifdef I_SAY_YES_TO_TERRAIN2 terrainUV #else // I_SAY_YES_TO_TERRAIN2 &texCoords[j][0] #endif // I_SAY_YES_TO_TERRAIN2 #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #else // CALCULATEuvONtheFLY #ifdef I_SAY_YES_TO_BUMP_TEXTURE gos_vertices3uv[numGOSVertices].GOSTransformNoClip( #else // I_SAY_YES_TO_BUMP_TEXTURE gos_vertices[numGOSVertices].GOSTransformNoClip( #endif // I_SAY_YES_TO_BUMP_TEXTURE coords[j], *mat, &texCoords[j][0] #ifdef I_SAY_YES_TO_BUMP_TEXTURE , &(*texCoords2)[j][0] , &(*texCoords3)[j][0] #endif // I_SAY_YES_TO_BUMP_TEXTURE #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #endif // CALCULATEuvONtheFLY #ifdef I_SAY_YES_TO_COLOR #if COLOR_AS_DWORD #ifdef I_SAY_YES_TO_BUMP_TEXTURE gos_vertices3uv[numGOSVertices].argb = (*actualColors)[j]; #else // I_SAY_YES_TO_BUMP_TEXTURE gos_vertices[numGOSVertices].argb = (*actualColors)[j]; #endif // I_SAY_YES_TO_BUMP_TEXTURE #else // COLOR_AS_DWORD #ifdef I_SAY_YES_TO_BUMP_TEXTURE gos_vertices3uv[numGOSVertices].argb = GOSCopyColor(&(*actualColors)[j]); #else // I_SAY_YES_TO_BUMP_TEXTURE gos_vertices[numGOSVertices].argb = GOSCopyColor(&(*actualColors)[j]); #endif // I_SAY_YES_TO_BUMP_TEXTURE #endif // COLOR_AS_DWORD #else // I_SAY_YES_TO_COLOR gos_vertices[numGOSVertices].argb = paintMeColor; #endif // I_SAY_YES_TO_COLOR } #endif // I_SAY_YES_TO_DUAL_TEXTURES #ifndef I_SAY_YES_TO_TERRAIN2 #ifdef I_SAY_YES_TO_BUMP_TEXTURE if(textureAnimation) { gos_vertices3uv[numGOSVertices].u1 += deltaU; gos_vertices3uv[numGOSVertices].v1 += deltaV; } if(textureAnimation2) { gos_vertices3uv[numGOSVertices].u2 += deltaU2; gos_vertices3uv[numGOSVertices].v2 += deltaV2; } #else // I_SAY_YES_TO_BUMP_TEXTURE if(textureAnimation) { gos_vertices[numGOSVertices].u += deltaU; gos_vertices[numGOSVertices].v += deltaV; } #endif // I_SAY_YES_TO_BUMP_TEXTURE #endif #if 1 if(fogData!=NULL) { #ifdef I_SAY_YES_TO_BUMP_TEXTURE *((BYTE *)&gos_vertices3uv[numGOSVertices].frgb + 3) = fogData->FogVertex(&coords[j]); #else // I_SAY_YES_TO_BUMP_TEXTURE *((BYTE *)&gos_vertices[numGOSVertices].frgb + 3) = fogData->FogVertex(&coords[j]); #endif // I_SAY_YES_TO_BUMP_TEXTURE } #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)[state2.GetTextureHandle()]; if(texture!=NULL && true==(textureAnimation = texture->GetAnimateTexture())) { 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 { if(db==false) { vt->Increase2UV(numGOSVertices); } } #else // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_DETAIL_TEXTURES if( gEnableDetailTexture==1) { if(MLRState::GetMultitextureLightMap() == false || state.GetMultiTextureMode()==MLRState::MultiTextureOffMode ) { 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)); stride = 0; for(i=0,j=numGOSVertices;i=-MLRState::GetMaxUV() && gos_vertices[j].u<=MLRState::GetMaxUV()) : 1); Verify( MLRState::GetHasMaxUVs() ? (gos_vertices[j].v>=-MLRState::GetMaxUV() && gos_vertices[j].v<=MLRState::GetMaxUV()) : 1); #endif // UV_CHECK if(gos_vertices[j].rhw < fadeDetailEnd) { gos_vertices[j].argb &= 0x00ffffff; } else { stride++; if(gos_vertices[j].rhwIncrease(2*numGOSVertices); } } else { if(db==false) { vt->Increase2UV(numGOSVertices); } } } else { if(db==false) { vt->Increase(numGOSVertices); } } #else // I_SAY_YES_TO_DETAIL_TEXTURES if(db==false) { vt->Increase(numGOSVertices); } #endif // I_SAY_YES_TO_DETAIL_TEXTURES #endif // I_SAY_YES_TO_DUAL_TEXTURES gos_indices = vt->GetActualIndexPool(db); numGOSIndices = 0; int ngi = 0; for(i=0,j=0;iGetLastIndex() + 3 + numGOSIndices) < vt->GetLength()); } else { Verify(3 + numGOSIndices < Limits::Max_Size_Of_Index_Buffer); } Verify(indexOffset[index[j]] < numGOSVertices); gos_indices[ngi++] = indexOffset[index[j]]; Verify(indexOffset[index[j+2]] < numGOSVertices); gos_indices[ngi++] = indexOffset[index[j+2]]; Verify(indexOffset[index[j+1]] < numGOSVertices); gos_indices[ngi++] = indexOffset[index[j+1]]; } numGOSIndices = (WORD)ngi; Check_Object(vt); if(db==false) { vt->IncreaseIndex(numGOSIndices); } visible = numGOSVertices ? (BYTE)1 : (BYTE)0; Stop_Timer(Transform_Time); } static MLRClippingState theAnd, theOr, theTest; // extern void _stdcall CheckVertices( gos_VERTEX* pVertexArray, DWORD NumberVertices, bool PointsLines ); // extern void _stdcall CheckVertices1( gos_VERTEX_2UV* pVertexArray, DWORD NumberVertices ); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Now it gets serious int CLASSNAME::TransformAndClip(Matrix4D *mat, MLRClippingState clippingFlags, GOSVertexPool *vt, FogData *fogData, DWORD paintMeColor, bool db) { Check_Object(this); #ifdef I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_LIGHTING if(actualColors==NULL || actualColors->GetLength() == 0 || gEnableSimpleLight>0 #ifdef LAB_ONLY || gShowBucketColors>0 #endif ) { return CLASSNAMENOCOLOR::TransformAndClip(mat, clippingFlags, vt, fogData, paintMeColor, db); } #else if(colors.GetLength()==0 #ifdef LAB_ONLY || gShowBucketColors>0 #endif ) { return CLASSNAMENOCOLOR::TransformAndClip(mat, clippingFlags, vt, fogData, paintMeColor, db); } #endif #endif int i, j, k, ret = 0; WORD l; int len; int *cs; #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY Vector2DScalar terrainUV; #endif // CALCULATEuvONtheFLY #endif // I_SAY_YES_TO_TERRAIN2 { MLR_RENDER("Transform::Clip::MLRTriangleClipping"); Start_Timer(Transform_Time); Verify(clippingFlags.GetClippingState() != 0); // //-------------------------------------- // See if we don't have to draw anything //-------------------------------------- // if(numOfTriangles <= 0) { visible = 0; Stop_Timer(Transform_Time); return visible; } Verify(index.GetLength() > 0); len = coords.GetLength(); if(visibleIndexedVerticesKey == false) { FindVisibleVertices(); } Stuff::Vector4D *v4d = transformedCoords->GetData(); const Stuff::Point3D *p3d = coords.GetData(); 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::MLRTriangleClipping"); Start_Timer(Clipping_Time); int mask, k0, k1, ct=0; Scalar a=0.0f; #ifndef I_SAY_YES_TO_TERRAIN2 bool textureAnimation = false; Scalar deltaU=0.0f, deltaV=0.0f; #endif // I_SAY_YES_TO_TERRAIN2 if(state.GetTextureHandle()) { MLRTexture *texture = (*MLRTexturePool::Instance)[state.GetTextureHandle()]; if(texture!=NULL) { MLRState::SetCurrentTextureSize(texture->GetImage()->GetWidth()); #ifndef I_SAY_YES_TO_TERRAIN2 if(true==(textureAnimation = texture->GetAnimateTexture())) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU = (*textureMatrix)(3, 0); deltaV = (*textureMatrix)(3, 1); } #endif // I_SAY_YES_TO_TERRAIN2 } } #if defined(I_SAY_YES_TO_DUAL_TEXTURES) || defined(I_SAY_YES_TO_DETAIL_TEXTURES) gos_vertices2uv = vt->GetActualVertexPool2UV(db); #ifndef I_SAY_YES_TO_TERRAIN2 bool textureAnimation2 = false; Scalar deltaU2=0.0f, deltaV2=0.0f; if(state2.GetTextureHandle()) { MLRTexture *texture = (*MLRTexturePool::Instance)[state2.GetTextureHandle()]; if(texture!=NULL && true==(textureAnimation2 = texture->GetAnimateTexture())) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU2 = (*textureMatrix)(3, 0); deltaV2 = (*textureMatrix)(3, 1); } } #endif // I_SAY_YES_TO_TERRAIN2 #endif // I_SAY_YES_TO_DUAL_TEXTURES || I_SAY_YES_TO_DETAIL_TEXTURES #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 // I_SAY_YES_TO_DUAL_TEXTURES int myNumberUsedClipVertex, myNumberUsedClipIndex, myNumberUsedClipLength; myNumberUsedClipVertex = 0; myNumberUsedClipIndex = 0; myNumberUsedClipLength = 0; Verify(index.GetLength() > 0); // //------------------------ // Handle the indexed case //------------------------ // // //----------------------------------------------------------------- // Step through each polygon, making sure that we don't try to clip // backfaced polygons //----------------------------------------------------------------- // cs = (int *)clipPerVertex->GetData(); int index0, index1, index2; #if defined (LAB_ONLY) && defined (HUNT_CLIP_ERROR2) bool whats_up_with_that = false; #endif for(i=0,j=0;i 0); (*clipExtraColors)[clipped_index] = (*actualColors)[k0]; #endif // I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY CalculateUV(k0, (*clipExtraTexCoords)[clipped_index][0], (*clipExtraTexCoords)[clipped_index][1]); #else // CALCULATEuvONtheFLY Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index] = texCoords[k0]; #endif // CALCULATEuvONtheFLY #else // I_SAY_YES_TO_TERRAIN2 Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index] = texCoords[k0]; #endif // I_SAY_YES_TO_TERRAIN2 #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*clipExtraTexCoords2)[clipped_index] = texCoords[k0+numVertices]; #endif #ifdef I_SAY_YES_TO_BUMP_TEXTURE (*clipExtraTexCoords2)[clipped_index] = (*texCoords2)[k0]; (*clipExtraTexCoords3)[clipped_index] = (*texCoords3)[k0]; #endif if(channelUse > 0) { int maskC = 1; for(int n=0;n<(MaxNumberOfExtraChannel<<1);n+=2,maskC<<=1) { if(channelUse & maskC) { (*extraChannels[n+1])[clipped_index] = (*extraChannels[n])[k0]; } } } #if defined (LAB_ONLY) && defined (HUNT_CLIP_ERROR2) if(whats_up_with_that == true) { SPEWALWAYS((HUNT_CLIP_ERROR2, "CT: %f %f %f %f", (*clipExtraCoords)[clipped_index].x, (*clipExtraCoords)[clipped_index].y, (*clipExtraCoords)[clipped_index].z, (*clipExtraCoords)[clipped_index].w )); } #endif numberVerticesPerPolygon++; clipped_index++; // //------------------------------------------------------- // We don't need to clip this edge if the next vertex is // also in the viewing space, so just move on to the next // vertex //------------------------------------------------------- // if(cs[k1] == 0) { continue; } } // //--------------------------------------------------------- // This vertex is outside the viewing space, so if the next // vertex is also outside the viewing space, no clipping is // needed and we throw this vertex away. Since only one // clipping plane is involved, it must be in the same space // as the first vertex //--------------------------------------------------------- // else { firstIsIn = false; if(cs[k1] != 0) { Verify(cs[k1] == cs[k0]); continue; } } // //-------------------------------------------------- // We now find the distance along the edge where the // clipping plane will intersect //-------------------------------------------------- // mask = 1; theTest |= cs[k1]; // //----------------------------------------------------- // Find the boundary conditions that match our clipping // plane //----------------------------------------------------- // for (l=0; l= 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 Verify((*actualColors).GetLength() > 0); #if COLOR_AS_DWORD (*clipExtraColors)[clipped_index] = Color_DWORD_Lerp ( (*actualColors)[k0], (*actualColors)[k1], a ); #else // COLOR_AS_DWORD (*clipExtraColors)[clipped_index].Lerp( (*actualColors)[k0], (*actualColors)[k1], a ); #endif // COLOR_AS_DWORD #endif // I_SAY_YES_TO_COLOR // //----------------------------------------------------- // If there are texture uv's, we need to lerp them in a // perspective correct manner //----------------------------------------------------- // #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY Vector2DScalar ctc[2]; CalculateUV(k0, ctc[0][0], ctc[0][1]); CalculateUV(k1, ctc[1][0], ctc[1][1]); (*clipExtraTexCoords)[clipped_index].Lerp ( ctc[0], ctc[1], a ); #else // CALCULATEuvONtheFLY Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index].Lerp ( texCoords[k0], texCoords[k1], a ); #endif // CALCULATEuvONtheFLY #else // I_SAY_YES_TO_TERRAIN2 Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index].Lerp ( texCoords[k0], texCoords[k1], a ); #endif // I_SAY_YES_TO_TERRAIN2 #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*clipExtraTexCoords2)[clipped_index].Lerp ( texCoords[k0+numVertices], texCoords[k1+numVertices], a ); #endif // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_BUMP_TEXTURE (*clipExtraTexCoords2)[clipped_index].Lerp ( (*texCoords2)[k0], (*texCoords2)[k1], a ); (*clipExtraTexCoords3)[clipped_index].Lerp ( (*texCoords3)[k0], (*texCoords3)[k1], a ); #endif // I_SAY_YES_TO_BUMP_TEXTURE if(channelUse > 0) { int maskC = 1; for(int n=0;n<(MaxNumberOfExtraChannel<<1);n+=2,maskC<<=1) { if(channelUse & maskC) { (*extraChannels[n+1])[clipped_index] = BYTE_Lerp ( (*extraChannels[n])[k0], (*extraChannels[n])[k1], a ); } } } } else { (*clipExtraCoords)[clipped_index].Lerp( (*transformedCoords)[k1], (*transformedCoords)[k0], 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 Verify((*actualColors).GetLength() > 0); #if COLOR_AS_DWORD (*clipExtraColors)[clipped_index] = Color_DWORD_Lerp ( (*actualColors)[k1], (*actualColors)[k0], a ); #else // COLOR_AS_DWORD (*clipExtraColors)[clipped_index].Lerp( (*actualColors)[k1], (*actualColors)[k0], a ); #endif // COLOR_AS_DWORD #endif // I_SAY_YES_TO_COLOR // //----------------------------------------------------- // If there are texture uv's, we need to lerp them in a // perspective correct manner //----------------------------------------------------- // #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY Vector2DScalar ctc[2]; CalculateUV(k1, ctc[0][0], ctc[0][1]); CalculateUV(k0, ctc[1][0], ctc[1][1]); (*clipExtraTexCoords)[clipped_index].Lerp ( ctc[0], ctc[1], a ); #else // CALCULATEuvONtheFLY Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index].Lerp ( texCoords[k1], texCoords[k0], a ); #endif // CALCULATEuvONtheFLY #else // I_SAY_YES_TO_TERRAIN2 Verify(texCoords.GetLength() > 0); (*clipExtraTexCoords)[clipped_index].Lerp ( texCoords[k1], texCoords[k0], a ); #endif // I_SAY_YES_TO_TERRAIN2 #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*clipExtraTexCoords2)[clipped_index].Lerp ( texCoords[k1+numVertices], texCoords[k0+numVertices], a ); #endif // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_BUMP_TEXTURE (*clipExtraTexCoords2)[clipped_index].Lerp ( (*texCoords2)[k1], (*texCoords2)[k0], a ); (*clipExtraTexCoords3)[clipped_index].Lerp ( (*texCoords3)[k1], (*texCoords3)[k0], a ); #endif // I_SAY_YES_TO_BUMP_TEXTURE if(channelUse > 0) { int maskC = 1; for(int n=0;n<(MaxNumberOfExtraChannel<<1);n+=2,maskC<<=1) { if(channelUse & maskC) { (*extraChannels[n+1])[clipped_index] = BYTE_Lerp ( (*extraChannels[n])[k1], (*extraChannels[n])[k0], a ); } } } } #if defined (LAB_ONLY) && defined (HUNT_CLIP_ERROR2) if(whats_up_with_that == true) { SPEWALWAYS((HUNT_CLIP_ERROR2, "CT: %f %f %f %f", (*clipExtraCoords)[clipped_index].x, (*clipExtraCoords)[clipped_index].y, (*clipExtraCoords)[clipped_index].z, (*clipExtraCoords)[clipped_index].w )); } #endif // //-------------------------------- // Bump the polygon's vertex count //-------------------------------- // numberVerticesPerPolygon++; } (*clipExtraLength)[myNumberUsedClipLength] = numberVerticesPerPolygon; #ifdef _ARMOR (*clipExtraLength)[myNumberUsedClipLength] &= ~0x8000; #endif // _ARMOR } // //--------------------------------------------------------------- // We have to handle multiple planes. We do this by creating two // buffers and we switch between them as we clip plane by plane //--------------------------------------------------------------- // else { #ifdef LAB_ONLY Set_Statistic(PolysClippedButGOnePlane, PolysClippedButGOnePlane+1); #endif // LAB_ONLY ClipData2 srcPolygon, dstPolygon; int dstBuffer = 1; srcPolygon.coords = clipBuffer[dstBuffer].coords.GetData(); #ifdef I_SAY_YES_TO_COLOR Verify((*actualColors).GetLength() > 0); srcPolygon.colors = clipBuffer[dstBuffer].colors.GetData(); #endif // I_SAY_YES_TO_COLOR srcPolygon.texCoords = clipBuffer[dstBuffer].texCoords.GetData(); srcPolygon.clipPerVertex = clipBuffer[dstBuffer].clipPerVertex.GetData(); if(channelUse > 0) { int maskC = 1; for(int n=0;n0 DWORD2Color(srcPolygon.colors[l], (*actualColors)[indexK]); #else srcPolygon.colors[l] = (*actualColors)[indexK]; #endif #endif // I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_DUAL_TEXTURES srcPolygon.texCoords[2*l] = texCoords[indexK]; srcPolygon.texCoords[2*l+1] = texCoords[indexK + numVertices]; #else // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY CalculateUV(indexK, terrainUV[0], terrainUV[1]); srcPolygon.texCoords[l] = terrainUV; #else // CALCULATEuvONtheFLY srcPolygon.texCoords[l] = texCoords[indexK]; #endif // CALCULATEuvONtheFLY #else // I_SAY_YES_TO_TERRAIN2 #ifdef I_SAY_YES_TO_BUMP_TEXTURE srcPolygon.texCoords[3*l] = texCoords[indexK]; srcPolygon.texCoords[3*l+1] = (*texCoords2)[indexK]; srcPolygon.texCoords[3*l+2] = (*texCoords3)[indexK]; #else // I_SAY_YES_TO_BUMP_TEXTURE srcPolygon.texCoords[l] = texCoords[indexK]; #endif // I_SAY_YES_TO_BUMP_TEXTURE #endif // I_SAY_YES_TO_TERRAIN2 #endif // I_SAY_YES_TO_DUAL_TEXTURES srcPolygon.clipPerVertex[l] = (*clipPerVertex)[indexK]; if(channelUse > 0) { int maskC = 1; for(int n=0;nmaxF) { maxF = srcPolygon.extraChannel[n][l]; } } } } } srcPolygon.length = l; // //-------------------------------- // Point to the destination buffer //-------------------------------- // dstBuffer = 0; dstPolygon.coords = clipBuffer[dstBuffer].coords.GetData(); #ifdef I_SAY_YES_TO_COLOR dstPolygon.colors = clipBuffer[dstBuffer].colors.GetData(); #endif // I_SAY_YES_TO_COLOR dstPolygon.texCoords = clipBuffer[dstBuffer].texCoords.GetData(); dstPolygon.clipPerVertex = clipBuffer[dstBuffer].clipPerVertex.GetData(); if(channelUse > 0) { int maskC = 1; for(int n=0;n 0) { int maskC = 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 // HUNT_CLIP_ERROR 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 // I_SAY_YES_TO_COLOR // //----------------------------------------------------- // 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 // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_BUMP_TEXTURE dstPolygon.texCoords[3*dstPolygon.length].Lerp ( srcPolygon.texCoords[3*k], srcPolygon.texCoords[3*k1], a ); dstPolygon.texCoords[3*dstPolygon.length+1].Lerp ( srcPolygon.texCoords[3*k+1], srcPolygon.texCoords[3*k1+1], a ); dstPolygon.texCoords[3*dstPolygon.length+2].Lerp ( srcPolygon.texCoords[3*k+2], srcPolygon.texCoords[3*k1+2], a ); #else // I_SAY_YES_TO_BUMP_TEXTURE dstPolygon.texCoords[dstPolygon.length].Lerp ( srcPolygon.texCoords[k], srcPolygon.texCoords[k1], a ); #endif // I_SAY_YES_TO_BUMP_TEXTURE #endif // I_SAY_YES_TO_DUAL_TEXTURES if(channelUse > 0) { int maskC = 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 // HUNT_CLIP_ERROR 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 // I_SAY_YES_TO_COLOR // //----------------------------------------------------- // 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 // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_BUMP_TEXTURE dstPolygon.texCoords[3*dstPolygon.length].Lerp ( srcPolygon.texCoords[3*k1], srcPolygon.texCoords[3*k], a ); dstPolygon.texCoords[3*dstPolygon.length+1].Lerp ( srcPolygon.texCoords[3*k1+1], srcPolygon.texCoords[3*k+1], a ); dstPolygon.texCoords[3*dstPolygon.length+2].Lerp ( srcPolygon.texCoords[3*k1+2], srcPolygon.texCoords[3*k+2], a ); #else // I_SAY_YES_TO_BUMP_TEXTURE dstPolygon.texCoords[dstPolygon.length].Lerp ( srcPolygon.texCoords[k1], srcPolygon.texCoords[k], a ); #endif // I_SAY_YES_TO_BUMP_TEXTURE #endif // I_SAY_YES_TO_DUAL_TEXTURES if(channelUse > 0) { int maskC = 1; for(int n=0;n 0) { int maskC = 1; for(int n=0;n 0) { int maskC = 1; for(int n=0;n0 (*clipExtraColors)[clipped_index] = GOSCopyColor(&srcPolygon.colors[k]); #else (*clipExtraColors)[clipped_index] = srcPolygon.colors[k]; #endif #endif // I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_DUAL_TEXTURES (*clipExtraTexCoords)[clipped_index] = srcPolygon.texCoords[2*k]; (*clipExtraTexCoords2)[clipped_index] = srcPolygon.texCoords[2*k+1]; #else // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_BUMP_TEXTURE (*clipExtraTexCoords)[clipped_index] = srcPolygon.texCoords[3*k]; (*clipExtraTexCoords2)[clipped_index] = srcPolygon.texCoords[3*k+1]; (*clipExtraTexCoords3)[clipped_index] = srcPolygon.texCoords[3*k+2]; #else // I_SAY_YES_TO_BUMP_TEXTURE (*clipExtraTexCoords)[clipped_index] = srcPolygon.texCoords[k]; #endif // I_SAY_YES_TO_BUMP_TEXTURE #endif // I_SAY_YES_TO_DUAL_TEXTURES if(channelUse > 0) { int maskC = 1; for(int n=0;n=minF); } } } #if defined (LAB_ONLY) && defined (HUNT_CLIP_ERROR2) if(whats_up_with_that == true) { SPEWALWAYS((HUNT_CLIP_ERROR2, "CT: %f %f %f %f", (*clipExtraCoords)[clipped_index].x, (*clipExtraCoords)[clipped_index].y, (*clipExtraCoords)[clipped_index].z, (*clipExtraCoords)[clipped_index].w )); } #endif } numberVerticesPerPolygon = srcPolygon.length; #if HUNT_CLIP_ERROR DEBUG_STREAM << "---" << '\n'; #endif // HUNT_CLIP_ERROR (*clipExtraLength)[myNumberUsedClipLength] = numberVerticesPerPolygon; #ifdef _ARMOR (*clipExtraLength)[myNumberUsedClipLength] |= 0x8000; #endif // _ARMOR } myNumberUsedClipVertex += numberVerticesPerPolygon; myNumberUsedClipLength++; ret++; // clip // dont draw the original (*testList)[i] = 0; } } Check_Object(vt); #ifdef I_SAY_YES_TO_BUMP_TEXTURE bool textureAnimation2 = false; Scalar deltaU2=0.0f, deltaV2=0.0f; if(textureNorm) { MLRTexture *texture = (*MLRTexturePool::Instance)[textureNorm]; if(texture!=NULL && true==(textureAnimation2 = texture->GetAnimateTexture())) { Stuff::AffineMatrix4D *textureMatrix = texture->GetTextureMatrix(); deltaU2 = (*textureMatrix)(3, 0); deltaV2 = (*textureMatrix)(3, 1); } } gos_vertices3uv = vt->GetActualVertexPool3UV(db); #else gos_vertices = vt->GetActualVertexPool(db); #endif numGOSVertices = 0; gos_indices = vt->GetActualIndexPool(db); numGOSIndices = 0; k = coords.GetLength(); WORD strideIndex; for(j=0,strideIndex=0;j(j-strideIndex); #ifdef I_SAY_YES_TO_TERRAIN2 #ifdef CALCULATEuvONtheFLY CalculateUV(j, terrainUV[0], terrainUV[1]); #endif // CALCULATEuvONtheFLY #endif // I_SAY_YES_TO_TERRAIN2 #ifdef I_SAY_YES_TO_DUAL_TEXTURES if(MLRState::GetMultitextureLightMap() == true && state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode) { #ifdef CALCULATEuvONtheFLY GOSCopyData( &gos_vertices2uv[numGOSVertices], transformedCoords->GetData(), #ifdef I_SAY_YES_TO_COLOR actualColors->GetData(), #endif // I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_TERRAIN2 &terrainUV-j, #else // I_SAY_YES_TO_TERRAIN2 texCoords.GetData(), #endif // I_SAY_YES_TO_TERRAIN2 texCoords.GetData() + numVertices, j #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #else // CALCULATEuvONtheFLY GOSCopyData( &gos_vertices2uv[numGOSVertices], transformedCoords->GetData(), #ifdef I_SAY_YES_TO_COLOR actualColors->GetData(), #endif // I_SAY_YES_TO_COLOR texCoords.GetData(), texCoords.GetData() + numVertices, j #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #endif // CALCULATEuvONtheFLY if(channelUse & 1<GetData(), #ifdef I_SAY_YES_TO_COLOR actualColors->GetData(), #endif // I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_TERRAIN2 &terrainUV-j, #else // I_SAY_YES_TO_TERRAIN2 texCoords.GetData(), #endif // I_SAY_YES_TO_TERRAIN2 j #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #else // CALCULATEuvONtheFLY GOSCopyData( &gos_vertices[numGOSVertices], transformedCoords->GetData(), #ifdef I_SAY_YES_TO_COLOR actualColors->GetData(), #endif // I_SAY_YES_TO_COLOR texCoords.GetData(), j #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #endif // CALCULATEuvONtheFLY (*texCoords2)[tex2count++] = texCoords[numVertices + j]; if(channelUse & 1<GetData(), #ifdef I_SAY_YES_TO_COLOR actualColors->GetData(), #endif // I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_TERRAIN2 &terrainUV-j, #else // I_SAY_YES_TO_TERRAIN2 texCoords.GetData(), #endif // I_SAY_YES_TO_TERRAIN2 #ifdef I_SAY_YES_TO_TERRAIN2 &terrainUV-j, #else // I_SAY_YES_TO_TERRAIN2 texCoords.GetData(), #endif // I_SAY_YES_TO_TERRAIN2 j #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #else // CALCULATEuvONtheFLY GOSCopyData( &gos_vertices2uv[numGOSVertices], transformedCoords->GetData(), #ifdef I_SAY_YES_TO_COLOR actualColors->GetData(), #endif // I_SAY_YES_TO_COLOR texCoords.GetData(), texCoords.GetData(), j #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #endif // CALCULATEuvONtheFLY if(channelUse & 1<GetData(), #ifdef I_SAY_YES_TO_COLOR actualColors->GetData(), #endif // I_SAY_YES_TO_COLOR #ifdef I_SAY_YES_TO_TERRAIN2 &terrainUV-j, #else // I_SAY_YES_TO_TERRAIN2 texCoords.GetData(), #endif // I_SAY_YES_TO_TERRAIN2 j #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #else // CALCULATEuvONtheFLY GOSCopyData( #ifdef I_SAY_YES_TO_BUMP_TEXTURE &gos_vertices3uv[numGOSVertices], #else // I_SAY_YES_TO_BUMP_TEXTURE &gos_vertices[numGOSVertices], #endif // I_SAY_YES_TO_BUMP_TEXTURE transformedCoords->GetData(), #ifdef I_SAY_YES_TO_COLOR actualColors->GetData(), #endif // I_SAY_YES_TO_COLOR texCoords.GetData(), #ifdef I_SAY_YES_TO_BUMP_TEXTURE (*texCoords2).GetData(), (*texCoords3).GetData(), #endif // I_SAY_YES_TO_BUMP_TEXTURE j #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); #endif // CALCULATEuvONtheFLY if(channelUse & 1<GetLastIndex() + 3 + numGOSIndices) < vt->GetLength()); } else { Verify(3 + numGOSIndices < Limits::Max_Size_Of_Index_Buffer); } Verify(indexOffset[index[j]] < numGOSVertices); gos_indices[numGOSIndices] = indexOffset[index[j]]; Verify(indexOffset[index[j+2]] < numGOSVertices); gos_indices[numGOSIndices+1] = indexOffset[index[j+2]]; Verify(indexOffset[index[j+1]] < numGOSVertices); gos_indices[numGOSIndices+2] = indexOffset[index[j+1]]; numGOSIndices += 3; } WORD stride; if(myNumberUsedClipLength > 0) { for(i=0,j=0;i((*clipExtraLength)[i] & 0x7fff); #else // _ARMOR stride = (*clipExtraLength)[i]; #endif // _ARMOR 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); } #ifdef I_SAY_YES_TO_DUAL_TEXTURES if(MLRState::GetMultitextureLightMap() == true && state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode) { GOSCopyTriangleData( &gos_vertices2uv[numGOSVertices], clipExtraCoords->GetData(), #ifdef I_SAY_YES_TO_COLOR clipExtraColors->GetData(), #endif // I_SAY_YES_TO_COLOR clipExtraTexCoords->GetData(), clipExtraTexCoords2->GetData(), j, j+k+1, j+k #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); // CheckVertices1( gos_vertices2uv+numGOSVertices, 3 ); if(channelUse & 1<GetData(), #ifdef I_SAY_YES_TO_COLOR clipExtraColors->GetData(), #endif // I_SAY_YES_TO_COLOR clipExtraTexCoords->GetData(), j, j+k+1, j+k #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); (*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j]; (*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j+k+1]; (*texCoords2)[tex2count++] = (*clipExtraTexCoords2)[j+k]; if(channelUse & 1<GetData(), #ifdef I_SAY_YES_TO_COLOR clipExtraColors->GetData(), #endif // I_SAY_YES_TO_COLOR clipExtraTexCoords->GetData(), clipExtraTexCoords->GetData(), j, j+k+1, j+k #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); if(channelUse & 1<GetData(), #ifdef I_SAY_YES_TO_COLOR clipExtraColors->GetData(), #endif // I_SAY_YES_TO_COLOR clipExtraTexCoords->GetData(), #ifdef I_SAY_YES_TO_BUMP_TEXTURE clipExtraTexCoords2->GetData(), clipExtraTexCoords3->GetData(), #endif // I_SAY_YES_TO_BUMP_TEXTURE j, j+k+1, j+k #if FOG_HACK , state.GetFogMode() #endif // FOG_HACK ); if(channelUse & 1<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); #ifdef I_SAY_YES_TO_WATER if(channelUse & 1<GetLast() + 2*numGOSVertices < vt->GetLength()); } else { Verify (numGOSVertices < Limits::Max_Size_Of_Vertex_Buffer); } memcpy(gos_vertices + numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex)); if(textureAnimation2) { for(i=0,j=numGOSVertices;iIncrease(2*numGOSVertices); } } else { if(db==false) { vt->Increase2UV(numGOSVertices); } } #else // I_SAY_YES_TO_DUAL_TEXTURES #ifdef I_SAY_YES_TO_DETAIL_TEXTURES if(gEnableDetailTexture==1) { if( MLRState::GetMultitextureLightMap() == true && state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode ) { for(i=0;i=-MLRState::GetMaxUV() && gos_vertices2uv[i].u2<=MLRState::GetMaxUV()) : 1); Verify( MLRState::GetHasMaxUVs() ? (gos_vertices2uv[i].v2>=-MLRState::GetMaxUV() && gos_vertices2uv[i].v2<=MLRState::GetMaxUV()) : 1); #endif // UV_CHECK if(gos_vertices2uv[i].rhw < fadeDetailEnd) { gos_vertices2uv[i].argb &= 0x00ffffff; } else { if(gos_vertices2uv[i].rhwIncrease2UV(numGOSVertices); } } else { 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)); stride = 0; for(i=0,j=numGOSVertices;i=-MLRState::GetMaxUV() && gos_vertices[j].u<=MLRState::GetMaxUV()) : 1); Verify( MLRState::GetHasMaxUVs() ? (gos_vertices[j].v>=-MLRState::GetMaxUV() && gos_vertices[j].v<=MLRState::GetMaxUV()) : 1); #endif // UV_CHECK if(gos_vertices[j].rhw < fadeDetailEnd) { gos_vertices[j].argb &= 0x00ffffff; } else { stride++; if(gos_vertices[j].rhwIncrease(2*numGOSVertices); } } } else { if(db==false) { vt->Increase(numGOSVertices); } } #else // I_SAY_YES_TO_DETAIL_TEXTURES if(db==false) { vt->Increase(numGOSVertices); } #endif // I_SAY_YES_TO_DETAIL_TEXTURES #endif // // I_SAY_YES_TO_DUAL_TEXTURES if(db==false) { vt->IncreaseIndex(numGOSIndices); } visible = numGOSVertices ? (BYTE)1 : (BYTE)0; if(visible) { } else { } #if 0 //def I_SAY_YES_TO_DUAL_TEXTURES if(MLRState::GetMultitextureLightMap() == true && state.GetMultiTextureMode()!=MLRState::MultiTextureOffMode) { CheckVertices1( gos_vertices2uv, numGOSVertices ); } else { CheckVertices( gos_vertices, numGOSVertices, false ); } #endif // // I_SAY_YES_TO_DUAL_TEXTURES Stop_Timer(Clipping_Time); return ret; }