Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 151 vs 152 for /trunk/Source Code/Libs/src/ReCast/DebugUtils/Source/DetourDebugDraw.cpp

Diff revisions: vs.
  @@ -23,7 +23,6 @@
23 23 #include <Detour/Include/DetourCommon.h>
24 24 #include <Detour/Include/DetourNode.h>
25 25
26 -
27 26 static float distancePtLine2d(const float* pt, const float* p, const float* q)
28 27 {
29 28 float pqx = q[0] - p[0];
  @@ -49,11 +48,11 @@
49 48 for (int i = 0; i < tile->header->polyCount; ++i)
50 49 {
51 50 const dtPoly* p = &tile->polys[i];
52 -
51 +
53 52 if (p->getType() == DT_POLYTYPE_OFFMESH_CONNECTION) continue;
54 -
53 +
55 54 const dtPolyDetail* pd = &tile->detailMeshes[i];
56 -
55 +
57 56 for (int j = 0, nj = (int)p->vertCount; j < nj; ++j)
58 57 {
59 58 unsigned int c = col;
  @@ -83,10 +82,10 @@
83 82 {
84 83 if (p->neis[j] != 0) continue;
85 84 }
86 -
85 +
87 86 const float* v0 = &tile->verts[p->verts[j]*3];
88 87 const float* v1 = &tile->verts[p->verts[(j+1) % nj]*3];
89 -
88 +
90 89 // Draw detail mesh edges which align with the actual poly edge.
91 90 // This is really slow.
92 91 for (int k = 0; k < pd->triCount; ++k)
  @@ -122,7 +121,7 @@
122 121 dtPolyRef base = mesh.getPolyRefBase(tile);
123 122
124 123 int tileNum = mesh.decodePolyIdTile(base);
125 -
124 +
126 125 dd->depthMask(false);
127 126
128 127 dd->begin(DU_DRAW_TRIS);
  @@ -131,7 +130,7 @@
131 130 const dtPoly* p = &tile->polys[i];
132 131 if (p->getType() == DT_POLYTYPE_OFFMESH_CONNECTION) // Skip off-mesh links.
133 132 continue;
134 -
133 +
135 134 const dtPolyDetail* pd = &tile->detailMeshes[i];
136 135
137 136 unsigned int col;
  @@ -151,7 +150,7 @@
151 150 col = duIntToCol(p->getArea(), 64);
152 151 }
153 152 }
154 -
153 +
155 154 for (int j = 0; j < pd->triCount; ++j)
156 155 {
157 156 const unsigned char* t = &tile->detailTris[(pd->triBase+j)*4];
  @@ -165,10 +164,10 @@
165 164 }
166 165 }
167 166 dd->end();
168 -
167 +
169 168 // Draw inter poly boundaries
170 169 drawPolyBoundaries(dd, tile, duRGBA(0,48,64,32), 1.5f, true);
171 -
170 +
172 171 // Draw outer poly boundaries
173 172 drawPolyBoundaries(dd, tile, duRGBA(0,48,64,220), 2.5f, false);
174 173
  @@ -180,13 +179,13 @@
180 179 const dtPoly* p = &tile->polys[i];
181 180 if (p->getType() != DT_POLYTYPE_OFFMESH_CONNECTION) // Skip regular polys.
182 181 continue;
183 -
182 +
184 183 unsigned int col, col2;
185 184 if (query && query->isInClosedList(base | (dtPolyRef)i))
186 185 col = duRGBA(255,196,0,220);
187 186 else
188 187 col = duDarkenCol(duIntToCol(p->getArea(), 220));
189 -
188 +
190 189 const dtOffMeshConnection* con = &tile->offMeshCons[i - tile->header->offMeshBase];
191 190 const float* va = &tile->verts[p->verts[0]*3];
192 191 const float* vb = &tile->verts[p->verts[1]*3];
  @@ -201,7 +200,7 @@
201 200 if (tile->links[k].edge == 1)
202 201 endSet = true;
203 202 }
204 -
203 +
205 204 // End points and their on-mesh locations.
206 205 dd->vertex(va[0],va[1],va[2], col);
207 206 dd->vertex(con->pos[0],con->pos[1],con->pos[2], col);
  @@ -212,21 +211,21 @@
212 211 dd->vertex(con->pos[3],con->pos[4],con->pos[5], col);
213 212 col2 = endSet ? col : duRGBA(220,32,16,196);
214 213 duAppendCircle(dd, con->pos[3],con->pos[4]+0.1f,con->pos[5], con->rad, col2);
215 -
214 +
216 215 // End point vertices.
217 216 dd->vertex(con->pos[0],con->pos[1],con->pos[2], duRGBA(0,48,64,196));
218 217 dd->vertex(con->pos[0],con->pos[1]+0.2f,con->pos[2], duRGBA(0,48,64,196));
219 -
218 +
220 219 dd->vertex(con->pos[3],con->pos[4],con->pos[5], duRGBA(0,48,64,196));
221 220 dd->vertex(con->pos[3],con->pos[4]+0.2f,con->pos[5], duRGBA(0,48,64,196));
222 -
221 +
223 222 // Connection arc.
224 223 duAppendArc(dd, con->pos[0],con->pos[1],con->pos[2], con->pos[3],con->pos[4],con->pos[5], 0.25f,
225 224 (con->flags & 1) ? 0.6f : 0, 0.6f, col);
226 225 }
227 226 dd->end();
228 227 }
229 -
228 +
230 229 const unsigned int vcol = duRGBA(0,0,0,196);
231 230 dd->begin(DU_DRAW_POINTS, 3.0f);
232 231 for (int i = 0; i < tile->header->vertCount; ++i)
  @@ -242,7 +241,7 @@
242 241 void duDebugDrawNavMesh(duDebugDraw* dd, const dtNavMesh& mesh, unsigned char flags)
243 242 {
244 243 if (!dd) return;
245 -
244 +
246 245 for (int i = 0; i < mesh.getMaxTiles(); ++i)
247 246 {
248 247 const dtMeshTile* tile = mesh.getTile(i);
  @@ -256,7 +255,7 @@
256 255 if (!dd) return;
257 256
258 257 const dtNavMeshQuery* q = (flags & DU_DRAWNAVMESH_CLOSEDLIST) ? &query : 0;
259 -
258 +
260 259 for (int i = 0; i < mesh.getMaxTiles(); ++i)
261 260 {
262 261 const dtMeshTile* tile = mesh.getTile(i);
  @@ -268,7 +267,7 @@
268 267 void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query)
269 268 {
270 269 if (!dd) return;
271 -
270 +
272 271 const dtNodePool* pool = query.getNodePool();
273 272 if (pool)
274 273 {
  @@ -284,7 +283,7 @@
284 283 }
285 284 }
286 285 dd->end();
287 -
286 +
288 287 dd->begin(DU_DRAW_LINES, 2.0f);
289 288 for (int i = 0; i < pool->getHashSize(); ++i)
290 289 {
  @@ -303,7 +302,6 @@
303 302 }
304 303 }
305 304
306 -
307 305 static void drawMeshTileBVTree(duDebugDraw* dd, const dtMeshTile* tile)
308 306 {
309 307 // Draw BV nodes.
  @@ -328,7 +326,7 @@
328 326 void duDebugDrawNavMeshBVTree(duDebugDraw* dd, const dtNavMesh& mesh)
329 327 {
330 328 if (!dd) return;
331 -
329 +
332 330 for (int i = 0; i < mesh.getMaxTiles(); ++i)
333 331 {
334 332 const dtMeshTile* tile = mesh.getTile(i);
  @@ -348,11 +346,11 @@
348 346 for (int side = 0; side < 8; ++side)
349 347 {
350 348 unsigned short m = DT_EXT_LINK | (unsigned short)side;
351 -
349 +
352 350 for (int i = 0; i < tile->header->polyCount; ++i)
353 351 {
354 352 dtPoly* poly = &tile->polys[i];
355 -
353 +
356 354 // Create new links.
357 355 const int nv = poly->vertCount;
358 356 for (int j = 0; j < nv; ++j)
  @@ -360,17 +358,17 @@
360 358 // Skip edges which do not point to the right side.
361 359 if (poly->neis[j] != m)
362 360 continue;
363 -
361 +
364 362 // Create new links
365 363 const float* va = &tile->verts[poly->verts[j]*3];
366 364 const float* vb = &tile->verts[poly->verts[(j+1) % nv]*3];
367 -
365 +
368 366 if (side == 0 || side == 4)
369 367 {
370 368 unsigned int col = side == 0 ? duRGBA(128,0,0,128) : duRGBA(128,0,128,128);
371 369
372 370 const float x = va[0] + ((side == 0) ? -padx : padx);
373 -
371 +
374 372 dd->vertex(x,va[1]-pady,va[2], col);
375 373 dd->vertex(x,va[1]+pady,va[2], col);
376 374
  @@ -388,31 +386,30 @@
388 386 unsigned int col = side == 2 ? duRGBA(0,128,0,128) : duRGBA(0,128,128,128);
389 387
390 388 const float z = va[2] + ((side == 2) ? -padx : padx);
391 -
389 +
392 390 dd->vertex(va[0],va[1]-pady,z, col);
393 391 dd->vertex(va[0],va[1]+pady,z, col);
394 -
392 +
395 393 dd->vertex(va[0],va[1]+pady,z, col);
396 394 dd->vertex(vb[0],vb[1]+pady,z, col);
397 -
395 +
398 396 dd->vertex(vb[0],vb[1]+pady,z, col);
399 397 dd->vertex(vb[0],vb[1]-pady,z, col);
400 -
398 +
401 399 dd->vertex(vb[0],vb[1]-pady,z, col);
402 400 dd->vertex(va[0],va[1]-pady,z, col);
403 401 }
404 -
405 402 }
406 403 }
407 404 }
408 -
405 +
409 406 dd->end();
410 407 }
411 408
412 409 void duDebugDrawNavMeshPortals(duDebugDraw* dd, const dtNavMesh& mesh)
413 410 {
414 411 if (!dd) return;
415 -
412 +
416 413 for (int i = 0; i < mesh.getMaxTiles(); ++i)
417 414 {
418 415 const dtMeshTile* tile = mesh.getTile(i);
  @@ -425,7 +422,7 @@
425 422 const unsigned short polyFlags, const unsigned int col)
426 423 {
427 424 if (!dd) return;
428 -
425 +
429 426 for (int i = 0; i < mesh.getMaxTiles(); ++i)
430 427 {
431 428 const dtMeshTile* tile = mesh.getTile(i);
  @@ -444,14 +441,14 @@
444 441 void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef ref, const unsigned int col)
445 442 {
446 443 if (!dd) return;
447 -
444 +
448 445 const dtMeshTile* tile = 0;
449 446 const dtPoly* poly = 0;
450 447 if (dtStatusFailed(mesh.getTileAndPolyByRef(ref, &tile, &poly)))
451 448 return;
452 -
449 +
453 450 dd->depthMask(false);
454 -
451 +
455 452 const unsigned int c = (col & 0x00ffffff) | (64 << 24);
456 453 const unsigned int ip = (unsigned int)(poly - tile->polys);
457 454
  @@ -464,7 +461,7 @@
464 461 // Connection arc.
465 462 duAppendArc(dd, con->pos[0],con->pos[1],con->pos[2], con->pos[3],con->pos[4],con->pos[5], 0.25f,
466 463 (con->flags & 1) ? 0.6f : 0, 0.6f, c);
467 -
464 +
468 465 dd->end();
469 466 }
470 467 else
  @@ -485,9 +482,8 @@
485 482 }
486 483 dd->end();
487 484 }
488 -
489 - dd->depthMask(true);
490 485
486 + dd->depthMask(true);
491 487 }
492 488
493 489 static void debugDrawTileCachePortals(struct duDebugDraw* dd, const dtTileCacheLayer& layer, const float cs, const float ch)
  @@ -498,9 +494,9 @@
498 494
499 495 // Portals
500 496 unsigned int pcol = duRGBA(255,255,255,255);
501 -
497 +
502 498 const int segs[4*4] = {0,0,0,1, 0,1,1,1, 1,1,1,0, 1,0,0,0};
503 -
499 +
504 500 // Layer portals
505 501 dd->begin(DU_DRAW_LINES, 2.0f);
506 502 for (int y = 0; y < h; ++y)
  @@ -510,7 +506,7 @@
510 506 const int idx = x+y*w;
511 507 const int lh = (int)layer.heights[idx];
512 508 if (lh == 0xff) continue;
513 -
509 +
514 510 for (int dir = 0; dir < 4; ++dir)
515 511 {
516 512 if (layer.cons[idx] & (1<<(dir+4)))
  @@ -538,9 +534,9 @@
538 534 const float* bmin = layer.header->bmin;
539 535 const float* bmax = layer.header->bmax;
540 536 const int idx = layer.header->tlayer;
541 -
537 +
542 538 unsigned int color = duIntToCol(idx+1, 255);
543 -
539 +
544 540 // Layer bounds
545 541 float lbmin[3], lbmax[3];
546 542 lbmin[0] = bmin[0] + layer.header->minx*cs;
  @@ -550,7 +546,7 @@
550 546 lbmax[1] = bmax[1];
551 547 lbmax[2] = bmin[2] + (layer.header->maxy+1)*cs;
552 548 duDebugDrawBoxWire(dd, lbmin[0],lbmin[1],lbmin[2], lbmax[0],lbmax[1],lbmax[2], duTransCol(color,128), 2.0f);
553 -
549 +
554 550 // Layer height
555 551 dd->begin(DU_DRAW_QUADS);
556 552 for (int y = 0; y < h; ++y)
  @@ -561,7 +557,7 @@
561 557 const int lh = (int)layer.heights[lidx];
562 558 if (lh == 0xff) continue;
563 559 const unsigned char area = layer.areas[lidx];
564 -
560 +
565 561 unsigned int col;
566 562 if (area == 63)
567 563 col = duLerpCol(color, duRGBA(0,192,255,64), 32);
  @@ -569,11 +565,11 @@
569 565 col = duLerpCol(color, duRGBA(0,0,0,64), 32);
570 566 else
571 567 col = duLerpCol(color, duIntToCol(area, 255), 32);
572 -
568 +
573 569 const float fx = bmin[0] + x*cs;
574 570 const float fy = bmin[1] + (lh+1)*ch;
575 571 const float fz = bmin[2] + y*cs;
576 -
572 +
577 573 dd->vertex(fx, fy, fz, col);
578 574 dd->vertex(fx, fy, fz+cs, col);
579 575 dd->vertex(fx+cs, fy, fz+cs, col);
  @@ -581,7 +577,7 @@
581 577 }
582 578 }
583 579 dd->end();
584 -
580 +
585 581 debugDrawTileCachePortals(dd, layer, cs, ch);
586 582 }
587 583
  @@ -592,9 +588,9 @@
592 588 const float* bmin = layer.header->bmin;
593 589 const float* bmax = layer.header->bmax;
594 590 const int idx = layer.header->tlayer;
595 -
591 +
596 592 unsigned int color = duIntToCol(idx+1, 255);
597 -
593 +
598 594 // Layer bounds
599 595 float lbmin[3], lbmax[3];
600 596 lbmin[0] = bmin[0] + layer.header->minx*cs;
  @@ -604,7 +600,7 @@
604 600 lbmax[1] = bmax[1];
605 601 lbmax[2] = bmin[2] + (layer.header->maxy+1)*cs;
606 602 duDebugDrawBoxWire(dd, lbmin[0],lbmin[1],lbmin[2], lbmax[0],lbmax[1],lbmax[2], duTransCol(color,128), 2.0f);
607 -
603 +
608 604 // Layer height
609 605 dd->begin(DU_DRAW_QUADS);
610 606 for (int y = 0; y < h; ++y)
  @@ -615,13 +611,13 @@
615 611 const int lh = (int)layer.heights[lidx];
616 612 if (lh == 0xff) continue;
617 613 const unsigned char reg = layer.regs[lidx];
618 -
614 +
619 615 unsigned int col = duLerpCol(color, duIntToCol(reg, 255), 192);
620 -
616 +
621 617 const float fx = bmin[0] + x*cs;
622 618 const float fy = bmin[1] + (lh+1)*ch;
623 619 const float fz = bmin[2] + y*cs;
624 -
620 +
625 621 dd->vertex(fx, fy, fz, col);
626 622 dd->vertex(fx, fy, fz+cs, col);
627 623 dd->vertex(fx+cs, fy, fz+cs, col);
  @@ -629,13 +625,10 @@
629 625 }
630 626 }
631 627 dd->end();
632 -
628 +
633 629 debugDrawTileCachePortals(dd, layer, cs, ch);
634 630 }
635 631
636 -
637 -
638 -
639 632 /*struct dtTileCacheContour
640 633 {
641 634 int nverts;
  @@ -654,20 +647,20 @@
654 647 const float* orig, const float cs, const float ch)
655 648 {
656 649 if (!dd) return;
657 -
650 +
658 651 const unsigned char a = 255;// (unsigned char)(alpha*255.0f);
659 -
652 +
660 653 const int offs[2*4] = {-1,0, 0,1, 1,0, 0,-1};
661 -
654 +
662 655 dd->begin(DU_DRAW_LINES, 2.0f);
663 -
656 +
664 657 for (int i = 0; i < lcset.nconts; ++i)
665 658 {
666 659 const dtTileCacheContour& c = lcset.conts[i];
667 660 unsigned int color = 0;
668 -
661 +
669 662 color = duIntToCol(i, a);
670 -
663 +
671 664 for (int j = 0; j < c.nverts; ++j)
672 665 {
673 666 const int k = (j+1) % c.nverts;
  @@ -685,42 +678,42 @@
685 678 // Portal segment
686 679 col = duRGBA(255,255,255,128);
687 680 int d = va[3] & 0xf;
688 -
681 +
689 682 const float cx = (ax+bx)*0.5f;
690 683 const float cy = (ay+by)*0.5f;
691 684 const float cz = (az+bz)*0.5f;
692 -
685 +
693 686 const float dx = cx + offs[d*2+0]*2*cs;
694 687 const float dy = cy;
695 688 const float dz = cz + offs[d*2+1]*2*cs;
696 -
689 +
697 690 dd->vertex(cx,cy,cz,duRGBA(255,0,0,255));
698 691 dd->vertex(dx,dy,dz,duRGBA(255,0,0,255));
699 692 }
700 -
693 +
701 694 duAppendArrow(dd, ax,ay,az, bx,by,bz, 0.0f, cs*0.5f, col);
702 695 }
703 696 }
704 697 dd->end();
705 -
706 - dd->begin(DU_DRAW_POINTS, 4.0f);
707 -
698 +
699 + dd->begin(DU_DRAW_POINTS, 4.0f);
700 +
708 701 for (int i = 0; i < lcset.nconts; ++i)
709 702 {
710 703 const dtTileCacheContour& c = lcset.conts[i];
711 704 unsigned int color = 0;
712 -
705 +
713 706 for (int j = 0; j < c.nverts; ++j)
714 707 {
715 708 const unsigned char* va = &c.verts[j*4];
716 -
709 +
717 710 color = duDarkenCol(duIntToCol(i, a));
718 711 if (va[3] & 0x80)
719 712 {
720 713 // Border vertex
721 714 color = duRGBA(255,0,0,255);
722 715 }
723 -
716 +
724 717 float fx = orig[0] + va[0]*cs;
725 718 float fy = orig[1] + (va[1]+1+(i&1))*ch;
726 719 float fz = orig[2] + va[2]*cs;
  @@ -734,17 +727,17 @@
734 727 const float* orig, const float cs, const float ch)
735 728 {
736 729 if (!dd) return;
737 -
730 +
738 731 const int nvp = lmesh.nvp;
739 -
732 +
740 733 const int offs[2*4] = {-1,0, 0,1, 1,0, 0,-1};
741 -
734 +
742 735 dd->begin(DU_DRAW_TRIS);
743 -
736 +
744 737 for (int i = 0; i < lmesh.npolys; ++i)
745 738 {
746 739 const unsigned short* p = &lmesh.polys[i*nvp*2];
747 -
740 +
748 741 unsigned int color;
749 742 if (lmesh.areas[i] == DT_TILECACHE_WALKABLE_AREA)
750 743 color = duRGBA(0,192,255,64);
  @@ -752,7 +745,7 @@
752 745 color = duRGBA(0,0,0,64);
753 746 else
754 747 color = duIntToCol(lmesh.areas[i], 255);
755 -
748 +
756 749 unsigned short vi[3];
757 750 for (int j = 2; j < nvp; ++j)
758 751 {
  @@ -771,7 +764,7 @@
771 764 }
772 765 }
773 766 dd->end();
774 -
767 +
775 768 // Draw neighbours edges
776 769 const unsigned int coln = duRGBA(0,48,64,32);
777 770 dd->begin(DU_DRAW_LINES, 1.5f);
  @@ -782,9 +775,9 @@
782 775 {
783 776 if (p[j] == DT_TILECACHE_NULL_IDX) break;
784 777 if (p[nvp+j] & 0x8000) continue;
785 - const int nj = (j+1 >= nvp || p[j+1] == DT_TILECACHE_NULL_IDX) ? 0 : j+1;
778 + const int nj = (j+1 >= nvp || p[j+1] == DT_TILECACHE_NULL_IDX) ? 0 : j+1;
786 779 int vi[2] = {p[j], p[nj]};
787 -
780 +
788 781 for (int k = 0; k < 2; ++k)
789 782 {
790 783 const unsigned short* v = &lmesh.verts[vi[k]*3];
  @@ -796,7 +789,7 @@
796 789 }
797 790 }
798 791 dd->end();
799 -
792 +
800 793 // Draw boundary edges
801 794 const unsigned int colb = duRGBA(0,48,64,220);
802 795 dd->begin(DU_DRAW_LINES, 2.5f);
  @@ -807,38 +800,38 @@
807 800 {
808 801 if (p[j] == DT_TILECACHE_NULL_IDX) break;
809 802 if ((p[nvp+j] & 0x8000) == 0) continue;
810 - const int nj = (j+1 >= nvp || p[j+1] == DT_TILECACHE_NULL_IDX) ? 0 : j+1;
803 + const int nj = (j+1 >= nvp || p[j+1] == DT_TILECACHE_NULL_IDX) ? 0 : j+1;
811 804 int vi[2] = {p[j], p[nj]};
812 -
805 +
813 806 unsigned int col = colb;
814 807 if ((p[nvp+j] & 0xf) != 0xf)
815 808 {
816 809 const unsigned short* va = &lmesh.verts[vi[0]*3];
817 810 const unsigned short* vb = &lmesh.verts[vi[1]*3];
818 -
811 +
819 812 const float ax = orig[0] + va[0]*cs;
820 813 const float ay = orig[1] + (va[1]+1+(i&1))*ch;
821 814 const float az = orig[2] + va[2]*cs;
822 815 const float bx = orig[0] + vb[0]*cs;
823 816 const float by = orig[1] + (vb[1]+1+(i&1))*ch;
824 817 const float bz = orig[2] + vb[2]*cs;
825 -
818 +
826 819 const float cx = (ax+bx)*0.5f;
827 820 const float cy = (ay+by)*0.5f;
828 821 const float cz = (az+bz)*0.5f;
829 -
822 +
830 823 int d = p[nvp+j] & 0xf;
831 -
824 +
832 825 const float dx = cx + offs[d*2+0]*2*cs;
833 826 const float dy = cy;
834 827 const float dz = cz + offs[d*2+1]*2*cs;
835 -
828 +
836 829 dd->vertex(cx,cy,cz,duRGBA(255,0,0,255));
837 830 dd->vertex(dx,dy,dz,duRGBA(255,0,0,255));
838 -
831 +
839 832 col = duRGBA(255,255,255,128);
840 833 }
841 -
834 +
842 835 for (int k = 0; k < 2; ++k)
843 836 {
844 837 const unsigned short* v = &lmesh.verts[vi[k]*3];
  @@ -850,7 +843,7 @@
850 843 }
851 844 }
852 845 dd->end();
853 -
846 +
854 847 dd->begin(DU_DRAW_POINTS, 3.0f);
855 848 const unsigned int colv = duRGBA(0,0,0,220);
856 849 for (int i = 0; i < lmesh.nverts; ++i)
  @@ -862,7 +855,4 @@
862 855 dd->vertex(x,y,z, colv);
863 856 }
864 857 dd->end();
865 - }
866 -
867 -
868 -
858 + }