📄 mlrprimitiveclipping.hpp
字号:
#ifdef I_SAY_YES_TO_MULTI_TEXTURES
for(m=0;m<currentNrOfPasses;m++)
{
(*clipExtraMultiTexCoords)[m][clipped_index] = srcPolygon.texCoords[currentNrOfPasses*k+m];
}
#else
(*clipExtraTexCoords)[clipped_index] = srcPolygon.texCoords[k];
#endif
#endif
}
numberVerticesPerPolygon = srcPolygon.length;
#if HUNT_CLIP_ERROR
DEBUG_STREAM << "---" << '\n';
#endif
(*clipExtraLength)[myNumberUsedClipLength] = numberVerticesPerPolygon;
#ifdef _ARMOR
(*clipExtraLength)[myNumberUsedClipLength] |= 0x8000;
#endif
}
myNumberUsedClipVertex += numberVerticesPerPolygon;
myNumberUsedClipLength++;
ret++;
// clip
// dont draw the original
testList[i] = 0;
}
j += stride;
}
Check_Object(vt);
gos_vertices = vt->GetActualVertexPool(db);
numGOSVertices = 0;
gos_indices = vt->GetActualIndexPool(db);
numGOSIndices = 0;
k = visibleIndexedVertices.GetLength();
for(j=0,stride=0;j<k;j++)
{
if(visibleIndexedVertices[j] == 0)
{
stride++;
}
else
{
indexOffset[j] = stride;
#if FOG_HACK
int fogEntry = state.GetFogMode();
if(fogEntry)
{
*((BYTE *)&gos_vertices[numGOSVertices].frgb + 3) =
GOSVertex::fogTable[fogEntry-1][Truncate_Float_To_Word((*transformedCoords)[j].w)];
}
else
{
*((BYTE *)&gos_vertices[numGOSVertices].frgb + 3) = 0xff;
}
#endif
GOSCopyData(
&gos_vertices[numGOSVertices],
transformedCoords->GetData(),
#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
#ifdef I_SAY_YES_TO_MULTI_TEXTURES
for(m=1;m<currentNrOfPasses;m++)
{
(*extraMultiTexCoords)[m][(*tex2count)[m]++] = multiTexCoordsPointers[m][j];
}
#endif
numGOSVertices++;
}
}
for(i=0,j=0;i<len;i++)
{
stride = lengths[i];
Verify(stride >= 3);
if(testList[i] == 0)
{
j += stride;
continue;
}
for(k=1;k<stride-1;k++)
{
if(db==false)
{
Verify((vt->GetLastIndex() + 3 + numGOSIndices) < vt->GetLength());
}
else
{
Verify(3 + numGOSIndices < 2*Limits::Max_Number_Vertices_Per_Mesh);
}
gos_indices[numGOSIndices] = (unsigned short)(index[j] - indexOffset[index[j]]);
gos_indices[numGOSIndices+1] = (unsigned short)(index[j+k+1] - indexOffset[index[j+k+1]]);
gos_indices[numGOSIndices+2] = (unsigned short)(index[j+k] - indexOffset[index[j+k]]);
numGOSIndices += 3;
}
j += stride;
}
if(myNumberUsedClipLength > 0)
{
for(i=0,j=0;i<myNumberUsedClipLength;i++)
{
#ifdef _ARMOR
stride = static_cast<unsigned short>((*clipExtraLength)[i] & 0x7fff);
#else
stride = (*clipExtraLength)[i];
#endif
#if 0
for(k=j;k<stride+j;k++)
{
if(clipExtraCoords[k].x < 0.0f && clipExtraCoords[k].x > -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;k<stride-1;k++)
{
if(db==false)
{
Verify((vt->GetLast() + 3 + numGOSVertices) < vt->GetLength());
Verify((vt->GetLastIndex() + 3 + numGOSIndices) < vt->GetLength());
}
else
{
Verify(3 + numGOSVertices < 2*Limits::Max_Number_Vertices_Per_Mesh);
Verify(3 + numGOSIndices < 2*Limits::Max_Number_Vertices_Per_Mesh);
}
#if FOG_HACK
int fogEntry = state.GetFogMode();
if(fogEntry)
{
fogEntry--;
*((BYTE *)&gos_vertices[numGOSVertices].frgb + 3) =
GOSVertex::fogTable[fogEntry][Truncate_Float_To_Word((*clipExtraCoords)[j].w)];
*((BYTE *)&gos_vertices[numGOSVertices+1].frgb + 3) =
GOSVertex::fogTable[fogEntry][Truncate_Float_To_Word((*clipExtraCoords)[j+k+1].w)];
*((BYTE *)&gos_vertices[numGOSVertices+2].frgb + 3) =
GOSVertex::fogTable[fogEntry][Truncate_Float_To_Word((*clipExtraCoords)[j+k].w)];
}
else
{
*((BYTE *)&gos_vertices[numGOSVertices].frgb + 3) = 0xff;
*((BYTE *)&gos_vertices[numGOSVertices+1].frgb + 3) = 0xff;
*((BYTE *)&gos_vertices[numGOSVertices+2].frgb + 3) = 0xff;
}
#endif
GOSCopyTriangleData(
&gos_vertices[numGOSVertices],
clipExtraCoords->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
#ifdef I_SAY_YES_TO_MULTI_TEXTURES
for(m=1;m<currentNrOfPasses;m++)
{
(*extraMultiTexCoords)[m][(*tex2count)[m]++] = (*clipExtraMultiTexCoords)[m][j];
(*extraMultiTexCoords)[m][(*tex2count)[m]++] = (*clipExtraMultiTexCoords)[m][j+k+1];
(*extraMultiTexCoords)[m][(*tex2count)[m]++] = (*clipExtraMultiTexCoords)[m][j+k];
}
#endif
if(db==false)
{
Verify((vt->GetLastIndex() + 3 + numGOSIndices) < vt->GetLength());
}
else
{
Verify(3 + numGOSIndices < 2*Limits::Max_Number_Vertices_Per_Mesh);
}
Verify(numGOSIndices%3 == 0);
gos_indices[numGOSIndices] = numGOSVertices;
gos_indices[numGOSIndices+1] = (unsigned short)(numGOSVertices + 1);
gos_indices[numGOSIndices+2] = (unsigned short)(numGOSVertices + 2);
numGOSVertices += 3;
numGOSIndices += 3;
}
j += stride;
}
#if HUNT_CLIP_ERROR
DEBUG_STREAM << "***" << endl << endl;
#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;i<numGOSVertices;i++,j++)
{
gos_vertices[j].u = (*texCoords2)[i][0] + deltaU2;
gos_vertices[j].v = (*texCoords2)[i][1] + deltaV2;
}
}
else
{
for(i=0,j=numGOSVertices;i<numGOSVertices;i++,j++)
{
gos_vertices[j].u = (*texCoords2)[i][0];
gos_vertices[j].v = (*texCoords2)[i][1];
}
}
if(db==false)
{
vt->Increase(2*numGOSVertices);
}
#else
#ifdef I_SAY_YES_TO_DETAIL_TEXTURES
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));
for(i=0,j=numGOSVertices;i<numGOSVertices;i++,j++)
{
gos_vertices[j].u = gos_vertices[i].u*xScale + xOffset;
gos_vertices[j].v = gos_vertices[i].v*yScale + yOffset;
}
if(db==false)
{
vt->Increase(2*numGOSVertices);
}
#else
if(db==false)
{
vt->Increase(numGOSVertices);
}
#endif
#endif
#ifdef I_SAY_YES_TO_MULTI_TEXTURES
for(m=1;m<currentNrOfPasses;m++)
{
Verify ((*tex2count)[m] == numGOSVertices);
if(db==false)
{
Verify (vt->GetLast() + numGOSVertices < vt->GetLength());
}
else
{
Verify (numGOSVertices < 2*Limits::Max_Number_Vertices_Per_Mesh);
}
memcpy(gos_vertices + m*numGOSVertices, gos_vertices, numGOSVertices * sizeof(GOSVertex));
for(i=0,j=numGOSVertices;i<numGOSVertices;i++,j++)
{
gos_vertices[j].u = (*extraMultiTexCoords)[m][i][0];
gos_vertices[j].v = (*extraMultiTexCoords)[m][i][1];
}
if(db==false)
{
vt->Increase(numGOSVertices);
}
}
#endif
if(db==false)
{
vt->IncreaseIndex(numGOSIndices);
}
visible = numGOSVertices ? (unsigned char)1 : (unsigned char)0;
if(visible)
{
}
else
{
}
Stop_Timer(Clipping_Time);
return ret;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -