Skip to content

Commit 08a0485

Browse files
committed
[tests] Update DrawPrimitive for collapse.
1 parent ab308ab commit 08a0485

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

tests/ExampleApps/DrawPrimitivesApp/minimalradium.cpp

+34-31
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ void MinimalComponent::initialize() {
732732

733733
if ( ENABLE_COLLAPSE )
734734
{
735+
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
736+
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
735737

736738
using namespace Ra::Core;
737739
using namespace Ra::Core::Utils;
@@ -756,15 +758,16 @@ void MinimalComponent::initialize() {
756758
return {};
757759
};
758760

759-
auto addMesh = [this, colorBoost, shadedRt, plainRt]( Vector3 pos, TopologicalMesh topo1 ) {
761+
auto addMesh = [this, colorBoost, plainMaterial]( Vector3 pos, TopologicalMesh topo1 ) {
760762
topo1.checkIntegrity();
761763
auto mesh1 = topo1.toTriangleMesh();
762764
std::shared_ptr<Mesh> poly( new Mesh( "TEST", std::move( mesh1 ) ) );
763765

764766
auto renderObject2 = RenderObject::createRenderObject(
765-
"TEST", this, RenderObjectType::Geometry, poly, plainRt );
767+
"TEST", this, RenderObjectType::Geometry, poly, {} );
768+
renderObject2->setMaterial( plainMaterial );
766769
renderObject2->setLocalTransform( Transform {
767-
Translation( Vector3( pos ) ) * Eigen::UniformScaling<Scalar>( 0.02_ra )} );
770+
Translation( Vector3( pos ) ) * Eigen::UniformScaling<Scalar>( 0.003_ra )} );
768771

769772
addRenderObject( renderObject2 );
770773
};
@@ -800,21 +803,21 @@ void MinimalComponent::initialize() {
800803
c = colorBoost * Vector4 {dis01( gen ), dis01( gen ), dis01( gen ), 1_ra};
801804
}
802805

803-
VectorArray<Vector3ui> indices1 {
806+
Vector3uArray indices1 {
804807
{0, 2, 1}, {0, 3, 2}, {1, 2, 5}, {2, 3, 5}, {1, 5, 4}, {3, 6, 5}, {5, 6, 7}, {4, 5, 7}};
805808
Vector3uArray indices3 = {{0, 2, 1}, {1, 2, 5}, {1, 5, 4}, {3, 6, 5}, {5, 6, 7}, {4, 5, 7}};
806809

807810
Vector3uArray indices4 = {
808811
{0, 2, 5}, {3, 14, 6}, {4, 12, 15}, {11, 18, 20}, {17, 22, 21}, {16, 13, 23}};
809812

810-
VectorArray<Vector3ui> indices2 {{0, 5, 2},
811-
{1, 9, 8},
812-
{3, 6, 14},
813-
{7, 10, 19},
814-
{4, 15, 12},
815-
{11, 20, 18},
816-
{17, 21, 22},
817-
{16, 23, 13}};
813+
Vector3uArray indices2 {{0, 5, 2},
814+
{1, 9, 8},
815+
{3, 6, 14},
816+
{7, 10, 19},
817+
{4, 15, 12},
818+
{11, 20, 18},
819+
{17, 21, 22},
820+
{16, 23, 13}};
818821
Vector4Array colors2 {24, Color::White()};
819822
for ( const auto& face : indices2 )
820823
{
@@ -871,6 +874,7 @@ void MinimalComponent::initialize() {
871874

872875
auto addMergeScene =
873876
[findHalfedge, addMesh, &cellCorner, toCellCenter, cellSize, nCellX, nCellY](
877+
Vector3 pos,
874878
const Vector3Array& points,
875879
const Vector4Array& colors,
876880
const Vector3uArray& indices1,
@@ -879,9 +883,7 @@ void MinimalComponent::initialize() {
879883
TriangleMesh mesh1;
880884
TopologicalMesh topo1;
881885
optional<TopologicalMesh::HalfedgeHandle> optHe;
882-
Vector3 pos;
883-
pos = cellCorner + toCellCenter;
884-
Vector3 up {0_ra, .25_ra, 0_ra};
886+
Vector3 up {0_ra, .05_ra, 0_ra};
885887

886888
mesh1.setVertices( points );
887889
mesh1.addAttrib( Mesh::getAttribName( Mesh::VERTEX_COLOR ),
@@ -921,38 +923,39 @@ void MinimalComponent::initialize() {
921923
topo1.collapseWedge( *optHe, true );
922924
addMesh( pos, topo1 );
923925
};
924-
926+
Vector3 dx = Vector3( cellSize / 8_ra, 0_ra, 0_ra );
927+
Vector3 pos = cellCorner;
928+
pos[2] += toCellCenter[2];
925929
// With "continuous" wedges.
926-
addMergeScene( points, colors, indices1, points[5], points[2] );
927-
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
930+
addMergeScene( pos, points, colors, indices1, points[5], points[2] );
928931

929932
// with "top/bottom" wedges
930-
addMergeScene( points2, colors3, indices2, points[5], points[2] );
931-
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
933+
addMergeScene( pos, points2, colors3, indices2, points[5], points[2] );
934+
pos += dx;
932935

933936
// with continuous"top/bottom" wedges
934-
addMergeScene( points2, colors4, indices2, points[5], points[2] );
935-
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
937+
addMergeScene( pos, points2, colors4, indices2, points[5], points[2] );
938+
pos += dx;
936939

937940
// with "flat face" wedges
938-
addMergeScene( points2, colors2, indices2, points[5], points[2] );
939-
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
941+
addMergeScene( pos, points2, colors2, indices2, points[5], points[2] );
942+
pos += dx;
940943

941944
// boundary
942945
// With "continuous" wedges.
943-
addMergeScene( points, colors, indices3, points[5], points[2] );
944-
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
946+
addMergeScene( pos, points, colors, indices3, points[5], points[2] );
947+
pos += dx;
945948

946949
// with "top/bottom" wedges
947-
addMergeScene( points2, colors3, indices4, points[5], points[2] );
948-
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
950+
addMergeScene( pos, points2, colors3, indices4, points[5], points[2] );
951+
pos += dx;
949952

950953
// with continuous"top/bottom" wedges
951-
addMergeScene( points2, colors4, indices4, points[5], points[2] );
952-
updateCellCorner( cellCorner, cellSize, nCellX, nCellY );
954+
addMergeScene( pos, points2, colors4, indices4, points[5], points[2] );
955+
pos += dx;
953956

954957
// with "flat face" wedges
955-
addMergeScene( points2, colors2, indices4, points[5], points[2] );
958+
addMergeScene( pos, points2, colors2, indices4, points[5], points[2] );
956959
}
957960
}
958961

0 commit comments

Comments
 (0)