Skip to content

Commit 7cda5cb

Browse files
committed
Reimplemented more gltools functions, improved drawSphereSimple(), fixes
1 parent 9191aa6 commit 7cda5cb

File tree

9 files changed

+773
-608
lines changed

9 files changed

+773
-608
lines changed

src/gl/BSMesh.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,7 @@ void BSMesh::drawSelection() const
216216
t.scale = 1.0f / t.scale;
217217
sph.radius *= t.scale;
218218
sph.center = t * sph.center;
219-
scene->setGLColor( 1.0f, 1.0f, 1.0f, 0.33f );
220-
scene->setGLLineParams( GLView::Settings::lineWidthWireframe );
221-
scene->setModelViewMatrix( viewTrans() );
222-
scene->drawSphereSimple( sph.center, sph.radius, 72 );
219+
drawBoundingSphere( sph, FloatVector4( 1.0f, 1.0f, 1.0f, 0.33f ) );
223220
bindShape();
224221
}
225222
}

src/gl/bsshape.cpp

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ void BSShape::drawSelection() const
377377
if ( normalScale < 0.1f )
378378
normalScale = 0.1f;
379379

380-
381380
if ( !extraData ) {
382381
if ( n == "Bounding Sphere" ) {
383382
auto sph = BoundSphere( nif, idx );
@@ -417,25 +416,12 @@ void BSShape::drawSelection() const
417416
}
418417
}
419418

420-
if ( !idxs.size() ) {
421-
glPopMatrix();
422-
return;
423-
}
424-
425419
#if 0
426420
Vector3 pTrans = nif->get<Vector3>( nif->getIndex( pBlock, 1 ), "Translation" );
427421
#endif
428-
auto iBSphere = nif->getIndex( pBlock, "Bounding Sphere" );
429-
Vector3 pbvC = nif->get<Vector3>( nif->getIndex( iBSphere, 0, 2 ) );
430-
float pbvR = nif->get<float>( nif->getIndex( iBSphere, 1, 2 ) );
431-
432-
if ( pbvR > 0.0 ) {
433-
scene->setGLColor( 0.0f, 1.0f, 0.0f, 0.33f );
434-
scene->drawSphereSimple( pbvC, pbvR, 72 );
435-
bindShape();
436-
}
437-
438-
glPopMatrix();
422+
BoundSphere sph( nif, pBlock );
423+
if ( sph.radius > 0.0f )
424+
Shape::drawBoundingSphere( sph, FloatVector4( 0.0f, 1.0f, 0.0f, 0.33f ) );
439425

440426
for ( auto i : idxs ) {
441427
// Transform compound
@@ -452,22 +438,17 @@ void BSShape::drawSelection() const
452438
t.translation = bvC;
453439
t.scale = scale;
454440

455-
glPushMatrix();
456-
glMultMatrix( scene->view * t );
441+
scene->loadModelViewMatrix( scene->view.toMatrix4() * t );
457442

458443
if ( bvR > 0.0 ) {
459444
scene->setGLColor( 1.0f, 1.0f, 1.0f, 0.33f );
460445
scene->drawSphereSimple( Vector3( 0, 0, 0 ), bvR, 72 );
461-
bindShape();
462446
}
463-
464-
glPopMatrix();
465447
}
466-
467-
glPushMatrix();
468-
glMultMatrix( viewTrans() );
469448
}
470449

450+
bindShape();
451+
471452
if ( n == "Vertex Data" || n == "Vertex" || n == "Vertices" ) {
472453
int s = -1;
473454
if ( (n == "Vertex Data" && p == "Vertex Data")

0 commit comments

Comments
 (0)