diff options
author | UbitUmarov | 2016-11-07 18:34:45 +0000 |
---|---|---|
committer | UbitUmarov | 2016-11-07 18:34:45 +0000 |
commit | 7ebc08ad6512670ed9897c27475e278168eab18d (patch) | |
tree | 050ead2d78e7f5575641622ff70afcc5365a550c /OpenSim | |
parent | a few more changes on the avatars Velocity/TargetVelocity/SetMomentum. Need t... (diff) | |
download | opensim-SC_OLD-7ebc08ad6512670ed9897c27475e278168eab18d.zip opensim-SC_OLD-7ebc08ad6512670ed9897c27475e278168eab18d.tar.gz opensim-SC_OLD-7ebc08ad6512670ed9897c27475e278168eab18d.tar.bz2 opensim-SC_OLD-7ebc08ad6512670ed9897c27475e278168eab18d.tar.xz |
partially revert commit f29d5ad662387b97d9e881f28df584dc19fa8c07: if mesh asset does not contain data for PRIM type warn and use convex, do avoid physical peims going underground etc
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs | 276 |
1 files changed, 141 insertions, 135 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs index bcd1530..ca94034 100644 --- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs +++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs | |||
@@ -395,6 +395,10 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
395 | { | 395 | { |
396 | // m_log.DebugFormat("[MESH]: experimental mesh proxy generation for {0}", primName); | 396 | // m_log.DebugFormat("[MESH]: experimental mesh proxy generation for {0}", primName); |
397 | 397 | ||
398 | |||
399 | // for ubOde we have a diferent mesh use priority | ||
400 | // priority is to use full mesh then decomposition | ||
401 | // SL does the oposite | ||
398 | bool usemesh = false; | 402 | bool usemesh = false; |
399 | 403 | ||
400 | coords = new List<Coord>(); | 404 | coords = new List<Coord>(); |
@@ -443,16 +447,10 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
443 | 447 | ||
444 | if (physicsParms != null) | 448 | if (physicsParms != null) |
445 | usemesh = true; | 449 | usemesh = true; |
446 | else | ||
447 | { | ||
448 | m_log.WarnFormat("[MESH]: Data for PRIM shape type not found for prim {0}",primName); | ||
449 | return false; | ||
450 | } | ||
451 | } | 450 | } |
452 | 451 | ||
453 | if(!usemesh && (map.ContainsKey("physics_convex"))) | 452 | if(!usemesh && (map.ContainsKey("physics_convex"))) |
454 | physicsParms = (OSDMap)map["physics_convex"]; | 453 | physicsParms = (OSDMap)map["physics_convex"]; |
455 | |||
456 | 454 | ||
457 | if (physicsParms == null) | 455 | if (physicsParms == null) |
458 | { | 456 | { |
@@ -555,160 +553,168 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
555 | range = range - min; | 553 | range = range - min; |
556 | range *= invMaxU16; | 554 | range *= invMaxU16; |
557 | 555 | ||
558 | if (!convex && cmap.ContainsKey("HullList") && cmap.ContainsKey("Positions")) | 556 | if(!convex) |
559 | { | 557 | { |
560 | List<int> hsizes = new List<int>(); | 558 | // if mesh data not present and not convex then we need convex decomposition data |
561 | int totalpoints = 0; | 559 | if (cmap.ContainsKey("HullList") && cmap.ContainsKey("Positions")) |
562 | data = cmap["HullList"].AsBinary(); | ||
563 | for (i = 0; i < data.Length; i++) | ||
564 | { | 560 | { |
565 | t1 = data[i]; | 561 | List<int> hsizes = new List<int>(); |
566 | if (t1 == 0) | 562 | int totalpoints = 0; |
567 | t1 = 256; | 563 | data = cmap["HullList"].AsBinary(); |
568 | totalpoints += t1; | 564 | for (i = 0; i < data.Length; i++) |
569 | hsizes.Add(t1); | 565 | { |
570 | } | 566 | t1 = data[i]; |
567 | if (t1 == 0) | ||
568 | t1 = 256; | ||
569 | totalpoints += t1; | ||
570 | hsizes.Add(t1); | ||
571 | } | ||
571 | 572 | ||
572 | data = cmap["Positions"].AsBinary(); | 573 | data = cmap["Positions"].AsBinary(); |
573 | int ptr = 0; | 574 | int ptr = 0; |
574 | int vertsoffset = 0; | 575 | int vertsoffset = 0; |
575 | 576 | ||
576 | if (totalpoints == data.Length / 6) // 2 bytes per coord, 3 coords per point | 577 | if (totalpoints == data.Length / 6) // 2 bytes per coord, 3 coords per point |
577 | { | ||
578 | foreach (int hullsize in hsizes) | ||
579 | { | 578 | { |
580 | for (i = 0; i < hullsize; i++ ) | 579 | foreach (int hullsize in hsizes) |
581 | { | ||
582 | t1 = data[ptr++]; | ||
583 | t1 += data[ptr++] << 8; | ||
584 | t2 = data[ptr++]; | ||
585 | t2 += data[ptr++] << 8; | ||
586 | t3 = data[ptr++]; | ||
587 | t3 += data[ptr++] << 8; | ||
588 | |||
589 | f3 = new float3((t1 * range.X + min.X), | ||
590 | (t2 * range.Y + min.Y), | ||
591 | (t3 * range.Z + min.Z)); | ||
592 | vs.Add(f3); | ||
593 | } | ||
594 | |||
595 | if(hullsize <3) | ||
596 | { | 580 | { |
597 | vs.Clear(); | 581 | for (i = 0; i < hullsize; i++ ) |
598 | continue; | 582 | { |
599 | } | 583 | t1 = data[ptr++]; |
584 | t1 += data[ptr++] << 8; | ||
585 | t2 = data[ptr++]; | ||
586 | t2 += data[ptr++] << 8; | ||
587 | t3 = data[ptr++]; | ||
588 | t3 += data[ptr++] << 8; | ||
589 | |||
590 | f3 = new float3((t1 * range.X + min.X), | ||
591 | (t2 * range.Y + min.Y), | ||
592 | (t3 * range.Z + min.Z)); | ||
593 | vs.Add(f3); | ||
594 | } | ||
600 | 595 | ||
601 | if (hullsize <5) | 596 | if(hullsize <3) |
602 | { | ||
603 | foreach (float3 point in vs) | ||
604 | { | 597 | { |
605 | c.X = point.x; | 598 | vs.Clear(); |
606 | c.Y = point.y; | 599 | continue; |
607 | c.Z = point.z; | ||
608 | coords.Add(c); | ||
609 | } | 600 | } |
610 | f = new Face(vertsoffset, vertsoffset + 1, vertsoffset + 2); | ||
611 | faces.Add(f); | ||
612 | 601 | ||
613 | if (hullsize == 4) | 602 | if (hullsize <5) |
614 | { | 603 | { |
615 | // not sure about orientation.. | 604 | foreach (float3 point in vs) |
616 | f = new Face(vertsoffset, vertsoffset + 2, vertsoffset + 3); | 605 | { |
617 | faces.Add(f); | 606 | c.X = point.x; |
618 | f = new Face(vertsoffset, vertsoffset + 3, vertsoffset + 1); | 607 | c.Y = point.y; |
619 | faces.Add(f); | 608 | c.Z = point.z; |
620 | f = new Face(vertsoffset + 3, vertsoffset + 2, vertsoffset + 1); | 609 | coords.Add(c); |
610 | } | ||
611 | f = new Face(vertsoffset, vertsoffset + 1, vertsoffset + 2); | ||
621 | faces.Add(f); | 612 | faces.Add(f); |
613 | |||
614 | if (hullsize == 4) | ||
615 | { | ||
616 | // not sure about orientation.. | ||
617 | f = new Face(vertsoffset, vertsoffset + 2, vertsoffset + 3); | ||
618 | faces.Add(f); | ||
619 | f = new Face(vertsoffset, vertsoffset + 3, vertsoffset + 1); | ||
620 | faces.Add(f); | ||
621 | f = new Face(vertsoffset + 3, vertsoffset + 2, vertsoffset + 1); | ||
622 | faces.Add(f); | ||
623 | } | ||
624 | vertsoffset += vs.Count; | ||
625 | vs.Clear(); | ||
626 | continue; | ||
627 | } | ||
628 | /* | ||
629 | if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f)) | ||
630 | { | ||
631 | vs.Clear(); | ||
632 | continue; | ||
622 | } | 633 | } |
623 | vertsoffset += vs.Count; | ||
624 | vs.Clear(); | ||
625 | continue; | ||
626 | } | ||
627 | /* | ||
628 | if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f)) | ||
629 | { | ||
630 | vs.Clear(); | ||
631 | continue; | ||
632 | } | ||
633 | 634 | ||
634 | nverts = hullr.Vertices.Count; | 635 | nverts = hullr.Vertices.Count; |
635 | nindexs = hullr.Indices.Count; | 636 | nindexs = hullr.Indices.Count; |
636 | 637 | ||
637 | if (nindexs % 3 != 0) | 638 | if (nindexs % 3 != 0) |
638 | { | 639 | { |
639 | vs.Clear(); | 640 | vs.Clear(); |
640 | continue; | 641 | continue; |
641 | } | 642 | } |
642 | 643 | ||
643 | for (i = 0; i < nverts; i++) | 644 | for (i = 0; i < nverts; i++) |
644 | { | 645 | { |
645 | c.X = hullr.Vertices[i].x; | 646 | c.X = hullr.Vertices[i].x; |
646 | c.Y = hullr.Vertices[i].y; | 647 | c.Y = hullr.Vertices[i].y; |
647 | c.Z = hullr.Vertices[i].z; | 648 | c.Z = hullr.Vertices[i].z; |
648 | coords.Add(c); | 649 | coords.Add(c); |
649 | } | 650 | } |
650 | 651 | ||
651 | for (i = 0; i < nindexs; i += 3) | 652 | for (i = 0; i < nindexs; i += 3) |
652 | { | 653 | { |
653 | t1 = hullr.Indices[i]; | 654 | t1 = hullr.Indices[i]; |
654 | if (t1 > nverts) | 655 | if (t1 > nverts) |
655 | break; | 656 | break; |
656 | t2 = hullr.Indices[i + 1]; | 657 | t2 = hullr.Indices[i + 1]; |
657 | if (t2 > nverts) | 658 | if (t2 > nverts) |
658 | break; | 659 | break; |
659 | t3 = hullr.Indices[i + 2]; | 660 | t3 = hullr.Indices[i + 2]; |
660 | if (t3 > nverts) | 661 | if (t3 > nverts) |
661 | break; | 662 | break; |
662 | f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); | 663 | f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); |
663 | faces.Add(f); | 664 | faces.Add(f); |
664 | } | 665 | } |
665 | */ | 666 | */ |
666 | List<int> indices; | 667 | List<int> indices; |
667 | if (!HullUtils.ComputeHull(vs, out indices)) | 668 | if (!HullUtils.ComputeHull(vs, out indices)) |
668 | { | 669 | { |
669 | vs.Clear(); | 670 | vs.Clear(); |
670 | continue; | 671 | continue; |
671 | } | 672 | } |
672 | 673 | ||
673 | nverts = vs.Count; | 674 | nverts = vs.Count; |
674 | nindexs = indices.Count; | 675 | nindexs = indices.Count; |
675 | 676 | ||
676 | if (nindexs % 3 != 0) | 677 | if (nindexs % 3 != 0) |
677 | { | 678 | { |
678 | vs.Clear(); | 679 | vs.Clear(); |
679 | continue; | 680 | continue; |
680 | } | 681 | } |
681 | 682 | ||
682 | for (i = 0; i < nverts; i++) | 683 | for (i = 0; i < nverts; i++) |
683 | { | 684 | { |
684 | c.X = vs[i].x; | 685 | c.X = vs[i].x; |
685 | c.Y = vs[i].y; | 686 | c.Y = vs[i].y; |
686 | c.Z = vs[i].z; | 687 | c.Z = vs[i].z; |
687 | coords.Add(c); | 688 | coords.Add(c); |
688 | } | 689 | } |
689 | 690 | ||
690 | for (i = 0; i < nindexs; i += 3) | 691 | for (i = 0; i < nindexs; i += 3) |
691 | { | 692 | { |
692 | t1 = indices[i]; | 693 | t1 = indices[i]; |
693 | if (t1 > nverts) | 694 | if (t1 > nverts) |
694 | break; | 695 | break; |
695 | t2 = indices[i + 1]; | 696 | t2 = indices[i + 1]; |
696 | if (t2 > nverts) | 697 | if (t2 > nverts) |
697 | break; | 698 | break; |
698 | t3 = indices[i + 2]; | 699 | t3 = indices[i + 2]; |
699 | if (t3 > nverts) | 700 | if (t3 > nverts) |
700 | break; | 701 | break; |
701 | f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); | 702 | f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); |
702 | faces.Add(f); | 703 | faces.Add(f); |
704 | } | ||
705 | vertsoffset += nverts; | ||
706 | vs.Clear(); | ||
703 | } | 707 | } |
704 | vertsoffset += nverts; | ||
705 | vs.Clear(); | ||
706 | } | 708 | } |
709 | if (coords.Count > 0 && faces.Count > 0) | ||
710 | return true; | ||
711 | } | ||
712 | else | ||
713 | { | ||
714 | // if neither mesh or decomposition present, warn and use convex | ||
715 | m_log.WarnFormat("[MESH]: Data for PRIM shape type ( mesh or decomposition) not found for prim {0}",primName); | ||
707 | } | 716 | } |
708 | if (coords.Count > 0 && faces.Count > 0) | ||
709 | return true; | ||
710 | } | 717 | } |
711 | |||
712 | vs.Clear(); | 718 | vs.Clear(); |
713 | 719 | ||
714 | if (cmap.ContainsKey("BoundingVerts")) | 720 | if (cmap.ContainsKey("BoundingVerts")) |