| 200 | */ |
| 201 | |
| 202 | void FaceArray::Draw(const IAnimator* matSource, TLVertexTable& tlTable, const LightList& lights, const Shape& mesh, |
| 203 | ClipFlags clipFlags, int spec, const Matrix4& invTransform) const |
| 204 | { |
| 205 | DoAssert(_sections.Size() == 0 || _sections[_sections.Size() - 1].end == End()); |
| 206 | Engine* engine = GEngine; |
| 207 | if ((spec & OnSurface) == 0) |
| 208 | { |
| 209 | ClipFlags andClip = clipFlags; |
| 210 | clipFlags &= tlTable.CheckClipping(*GScene->GetCamera(), clipFlags, andClip); |
| 211 | if (andClip) |
| 212 | { |
| 213 | return; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | engine->PrepareMesh(render::SplitLegacy(spec)); |
| 218 | if (spec & (OnSurface | IsOnSurface)) |
| 219 | { |
| 220 | engine->SetBias(0x10); |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | int bias = (spec & ZBiasMask) / ZBiasStep; |
| 225 | // max. bias value is 3 |
| 226 | engine->SetBias(bias * 5); |
| 227 | } |
| 228 | |
| 229 | tlTable.DoLighting(matSource, invTransform, lights, mesh, spec); |
| 230 | |
| 231 | // optimize for common case |
| 232 | // no clipping - we can draw directly |
| 233 | const FaceArray* drawFaces = this; |
| 234 | FaceArray clippedFaces; |
| 235 | if ((clipFlags & ClipAll) || (spec & OnSurface)) |
| 236 | { |
| 237 | clippedFaces.ReserveFaces(0, false); |
| 238 | if (spec & OnSurface) |
| 239 | { |
| 240 | float y = ((spec & IsShadow) ? engine->ZShadowEpsilon() : engine->ZRoadEpsilon()); |
| 241 | clippedFaces.SurfaceSplit(*this, tlTable, *GScene, clipFlags, y); |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | clippedFaces.Clip(*this, tlTable, *GScene->GetCamera(), clipFlags); |
| 246 | } |
| 247 | drawFaces = &clippedFaces; |
| 248 | } |
| 249 | |
| 250 | if (drawFaces->Begin() < drawFaces->End()) |
| 251 | { |
| 252 | tlTable.DoPerspective(*GScene->GetCamera(), clipFlags); |
| 253 | engine->BeginMesh(tlTable, render::SplitLegacy(spec)); |
| 254 | Texture* lastTexture = (Texture*)-1; // something that is not equal to any valid texture |
| 255 | int lastSpec = -1; |
| 256 | int nSections = drawFaces->_sections.Size(); |
| 257 | // verify there are some sections |
| 258 | DoAssert(nSections != 0); |
| 259 | // verify all source shape sections are still there |
nothing calls this directly
no test coverage detected