Mesh: Apply clang-format
This commit is contained in:
@@ -22,23 +22,23 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <Windows.h>
|
||||
# endif
|
||||
# ifdef FC_OS_MACOSX
|
||||
# include <OpenGL/gl.h>
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#ifdef FC_OS_MACOSX
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
|
||||
# include <Inventor/actions/SoGLRenderAction.h>
|
||||
# include <Inventor/bundles/SoMaterialBundle.h>
|
||||
# include <Inventor/bundles/SoTextureCoordinateBundle.h>
|
||||
# include <Inventor/elements/SoCoordinateElement.h>
|
||||
# include <Inventor/elements/SoLazyElement.h>
|
||||
# include <Inventor/misc/SoState.h>
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
#include <Inventor/bundles/SoMaterialBundle.h>
|
||||
#include <Inventor/bundles/SoTextureCoordinateBundle.h>
|
||||
#include <Inventor/elements/SoCoordinateElement.h>
|
||||
#include <Inventor/elements/SoLazyElement.h>
|
||||
#include <Inventor/misc/SoState.h>
|
||||
#endif
|
||||
|
||||
#include "SoPolygon.h"
|
||||
@@ -66,17 +66,18 @@ SoPolygon::SoPolygon()
|
||||
/**
|
||||
* Renders the polygon.
|
||||
*/
|
||||
void SoPolygon::GLRender(SoGLRenderAction *action)
|
||||
void SoPolygon::GLRender(SoGLRenderAction* action)
|
||||
{
|
||||
if (shouldGLRender(action) && render.getValue())
|
||||
{
|
||||
SoState* state = action->getState();
|
||||
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
|
||||
if (!coords)
|
||||
if (shouldGLRender(action) && render.getValue()) {
|
||||
SoState* state = action->getState();
|
||||
const SoCoordinateElement* coords = SoCoordinateElement::getInstance(state);
|
||||
if (!coords) {
|
||||
return;
|
||||
const SbVec3f * points = coords->getArrayPtr3();
|
||||
if (!points)
|
||||
}
|
||||
const SbVec3f* points = coords->getArrayPtr3();
|
||||
if (!points) {
|
||||
return;
|
||||
}
|
||||
|
||||
SoMaterialBundle mb(action);
|
||||
SoTextureCoordinateBundle tb(action, true, false);
|
||||
@@ -91,18 +92,19 @@ void SoPolygon::GLRender(SoGLRenderAction *action)
|
||||
/**
|
||||
* Renders the polygon.
|
||||
*/
|
||||
void SoPolygon::drawPolygon(const SbVec3f * points,int32_t len) const
|
||||
void SoPolygon::drawPolygon(const SbVec3f* points, int32_t len) const
|
||||
{
|
||||
glLineWidth(3.0f);
|
||||
int32_t beg = startIndex.getValue();
|
||||
int32_t cnt = numVertices.getValue();
|
||||
int32_t end = beg + cnt;
|
||||
if (end > len)
|
||||
return; // wrong setup, too few points
|
||||
if (end > len) {
|
||||
return; // wrong setup, too few points
|
||||
}
|
||||
// draw control mesh
|
||||
glBegin(GL_LINES);
|
||||
for (int32_t i = beg; i < end; ++i) {
|
||||
int32_t j = (i-beg+1) % cnt + beg;
|
||||
int32_t j = (i - beg + 1) % cnt + beg;
|
||||
glVertex3fv(points[i].getValue());
|
||||
glVertex3fv(points[j].getValue());
|
||||
}
|
||||
@@ -112,11 +114,10 @@ void SoPolygon::drawPolygon(const SbVec3f * points,int32_t len) const
|
||||
/**
|
||||
* Calculates picked point based on primitives generated by subclasses.
|
||||
*/
|
||||
void
|
||||
SoPolygon::rayPick(SoRayPickAction * action)
|
||||
void SoPolygon::rayPick(SoRayPickAction* action)
|
||||
{
|
||||
//if (this->shouldRayPick(action)) {
|
||||
// this->computeObjectSpaceRay(action);
|
||||
// if (this->shouldRayPick(action)) {
|
||||
// this->computeObjectSpaceRay(action);
|
||||
|
||||
// const SoBoundingBoxCache* bboxcache = getBoundingBoxCache();
|
||||
// if (!bboxcache || !bboxcache->isValid(action->getState()) ||
|
||||
@@ -128,43 +129,43 @@ SoPolygon::rayPick(SoRayPickAction * action)
|
||||
}
|
||||
|
||||
void SoPolygon::generatePrimitives(SoAction* /*action*/)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* Sets the bounding box of the mesh to \a box and its center to \a center.
|
||||
*/
|
||||
void SoPolygon::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er)
|
||||
void SoPolygon::computeBBox(SoAction* action, SbBox3f& box, SbVec3f& center)
|
||||
{
|
||||
SoState* state = action->getState();
|
||||
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
|
||||
if (!coords)
|
||||
SoState* state = action->getState();
|
||||
const SoCoordinateElement* coords = SoCoordinateElement::getInstance(state);
|
||||
if (!coords) {
|
||||
return;
|
||||
const SbVec3f * points = coords->getArrayPtr3();
|
||||
if (!points)
|
||||
}
|
||||
const SbVec3f* points = coords->getArrayPtr3();
|
||||
if (!points) {
|
||||
return;
|
||||
float maxX=-FLT_MAX, minX=FLT_MAX,
|
||||
maxY=-FLT_MAX, minY=FLT_MAX,
|
||||
maxZ=-FLT_MAX, minZ=FLT_MAX;
|
||||
}
|
||||
float maxX = -FLT_MAX, minX = FLT_MAX, maxY = -FLT_MAX, minY = FLT_MAX, maxZ = -FLT_MAX,
|
||||
minZ = FLT_MAX;
|
||||
int32_t len = coords->getNum();
|
||||
int32_t beg = startIndex.getValue();
|
||||
int32_t cnt = numVertices.getValue();
|
||||
int32_t end = beg + cnt;
|
||||
if (end <= len) {
|
||||
for (int32_t i=beg; i<end; i++) {
|
||||
maxX = std::max<float>(maxX,points[i][0]);
|
||||
minX = std::min<float>(minX,points[i][0]);
|
||||
maxY = std::max<float>(maxY,points[i][1]);
|
||||
minY = std::min<float>(minY,points[i][1]);
|
||||
maxZ = std::max<float>(maxZ,points[i][2]);
|
||||
minZ = std::min<float>(minZ,points[i][2]);
|
||||
for (int32_t i = beg; i < end; i++) {
|
||||
maxX = std::max<float>(maxX, points[i][0]);
|
||||
minX = std::min<float>(minX, points[i][0]);
|
||||
maxY = std::max<float>(maxY, points[i][1]);
|
||||
minY = std::min<float>(minY, points[i][1]);
|
||||
maxZ = std::max<float>(maxZ, points[i][2]);
|
||||
minZ = std::min<float>(minZ, points[i][2]);
|
||||
}
|
||||
|
||||
box.setBounds(minX,minY,minZ,maxX,maxY,maxZ);
|
||||
center.setValue(0.5f*(minX+maxX),0.5f*(minY+maxY),0.5f*(minZ+maxZ));
|
||||
box.setBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
center.setValue(0.5f * (minX + maxX), 0.5f * (minY + maxY), 0.5f * (minZ + maxZ));
|
||||
}
|
||||
else {
|
||||
box.setBounds(SbVec3f(0,0,0), SbVec3f(0,0,0));
|
||||
center.setValue(0.0f,0.0f,0.0f);
|
||||
box.setBounds(SbVec3f(0, 0, 0), SbVec3f(0, 0, 0));
|
||||
center.setValue(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user