Skip to content
Permalink
Browse files

triply: Cull based on much tighter AABBs instead of bounding spheres

Removes all bounding sphere calculations from triply and client
code. Should improve culling efficiency (and consequently sort-first)
quiet a bit.
  • Loading branch information...
Stefan Eilemann authored and eile committed May 23, 2017
1 parent d882e13 commit 514077f1eeb7144f5a047c26848c156169828e9f
@@ -1,13 +1,13 @@
Name: Equalizer
Version: 1.12.0
Version:
Release: 1%{?dist}
Summary: Middleware to create and deploy parallel OpenGL-based applications

Group: Development/Libraries
License: LGPLv2, examples are BSD licensed
URL: http://www.equalizergraphics.com/
Source0: http://www.equalizergraphics.com/downloads/%{name}-%{version}.tar.gz
Patch0: Equalizer-1.12.0-build-fix.patch
Patch0: Equalizer--build-fix.patch
BuildRequires: cmake bison flex
BuildRequires: boost-devel glew-devel
BuildRequires: libX11-devel mesa-libGL-devel
@@ -3,6 +3,9 @@ Changelog {#Changelog}

# git master

* [632](https://github.com/Eyescale/Equalizer/pull/632)
Add uxmal: A ZeroBuf vocabulary and application for LOD and cull debugging

# Release 2.1 (29-May-2017)

* [629](https://github.com/Eyescale/Equalizer/pull/629)
@@ -130,7 +130,7 @@ void Channel::frameDraw(const eq::uint128_t& frameID)
state.setFrustumCulling(false); // create all display lists/VBOs

if (model)
_updateNearFar(model->getBoundingSphere());
_updateNearFar(model->getBoundingBox());

eq::Channel::frameDraw(frameID); // Setup OpenGL state

@@ -735,7 +735,7 @@ void Channel::_drawHelp()
resetOverlayState();
}

void Channel::_updateNearFar(const triply::BoundingSphere& boundingSphere)
void Channel::_updateNearFar(const triply::BoundingBox& box)
{
// compute dynamic near/far plane of whole model
const FrameData& frameData = _getFrameData();
@@ -748,10 +748,10 @@ void Channel::_updateNearFar(const triply::BoundingSphere& boundingSphere)

front -= zero;
front.normalize();
front *= boundingSphere.w();
front *= box.getSize().length() * 0.5f;

const eq::Vector3f& center =
frameData.getCameraPosition() - boundingSphere.get_sub_vector<3, 0>();
frameData.getCameraPosition() - box.getCenter();
const eq::Vector3f nearPoint = view * (center - front);
const eq::Vector3f farPoint = view * (center + front);

@@ -793,12 +793,14 @@ void Channel::_updateNearFar(const triply::BoundingSphere& boundingSphere)
#endif
}

void Channel::publishAABB(const triply::BoundingBox& box)
void Channel::publishAABB(const triply::BoundingBox& box LB_UNUSED)
{
#ifdef UXMAL
const auto& min = box.getMin();
const auto& max = box.getMax();
_publisher.publish(uxmal::AABB(getID(), getCurrentFrame(),
{box[0][0], box[0][1], box[0][2]},
{box[1][0], box[1][1], box[1][2]}));
{min[0], min[1], min[2]},
{max[0], max[1], max[2]}));
#endif
}
}
@@ -73,7 +73,7 @@ class Channel : public eq::Channel
void _drawModel(const Model* model);
void _drawOverlay();
void _drawHelp();
void _updateNearFar(const triply::BoundingSphere& boundingSphere);
void _updateNearFar(const triply::BoundingBox& box);

bool _isDone() const;

@@ -1,5 +1,5 @@

/* Copyright (c) 2011-2016, Stefan Eilemann <eile@eyescale.ch>
/* Copyright (c) 2011-2017, Stefan Eilemann <eile@eyescale.ch>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -65,7 +65,7 @@ void Renderer::draw(co::Object* frameDataObj)
if (!model)
return;

updateNearFar(model->getBoundingSphere());
updateNearFar(model->getBoundingBox());
applyRenderContext();

glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
@@ -1,5 +1,5 @@

# Copyright (c) 2011-2015 Stefan Eilemann <eile@eyescale.ch>
# Copyright (c) 2011-2017 Stefan Eilemann <eile@eyescale.ch>

set(TRIPLY_PUBLIC_HEADERS
ply.h
@@ -15,7 +15,6 @@ set(TRIPLY_PUBLIC_HEADERS

set(TRIPLY_SOURCES
plyfile.cpp
vertexBufferBase.cpp
vertexBufferDist.cpp
vertexBufferLeaf.cpp
vertexBufferNode.cpp
@@ -124,8 +124,7 @@ struct ArrayWrapper

// compound type definitions
typedef vmml::vector<3, Index> Triangle;
typedef ArrayWrapper<Vertex, 2> BoundingBox;
typedef vmml::vector<4, float> BoundingSphere;
typedef vmml::AABBf BoundingBox;
typedef ArrayWrapper<float, 2> Range;

// maximum triangle count per leaf node (keep in mind that the number of
@@ -145,10 +144,10 @@ enum Axis
};
inline std::ostream& operator<<(std::ostream& os, const Axis axis)
{
os << (axis == AXIS_X
? "x axis"
: axis == AXIS_Y ? "y axis"
: axis == AXIS_Z ? "z axis" : "ERROR");
os << (axis == AXIS_X ? "x axis" : axis == AXIS_Y
? "y axis"
: axis == AXIS_Z ? "z axis"
: "ERROR");
return os;
}

This file was deleted.

@@ -47,7 +47,6 @@ class VertexBufferBase
TRIPLY_API virtual Index getNumberOfVertices() const = 0;

const BoundingBox& getBoundingBox() const { return _boundingBox; }
const BoundingSphere& getBoundingSphere() const { return _boundingSphere; }
const float* getRange() const { return &_range[0]; }
virtual const VertexBufferBase* getLeft() const { return nullptr; }
virtual const VertexBufferBase* getRight() const { return nullptr; }
@@ -57,7 +56,6 @@ class VertexBufferBase

protected:
VertexBufferBase()
: _boundingSphere(0.0f)
{
_range[0] = 0.0f;
_range[1] = 1.0f;
@@ -66,17 +64,13 @@ class VertexBufferBase
virtual void toStream(std::ostream& os)
{
os.write(reinterpret_cast<char*>(&_boundingBox), sizeof(BoundingBox));
os.write(reinterpret_cast<char*>(&_boundingSphere),
sizeof(BoundingSphere));
os.write(reinterpret_cast<char*>(&_range), sizeof(Range));
}

virtual void fromMemory(char** addr, VertexBufferData& /*globalData*/)
{
memRead(reinterpret_cast<char*>(&_boundingBox), addr,
sizeof(_boundingBox));
memRead(reinterpret_cast<char*>(&_boundingSphere), addr,
sizeof(_boundingSphere));
memRead(reinterpret_cast<char*>(&_range), addr, sizeof(Range));
}

@@ -92,7 +86,6 @@ class VertexBufferBase
virtual Type getType() const = 0;

BoundingBox _boundingBox;
BoundingSphere _boundingSphere;
Range _range;
};
}
@@ -1,5 +1,5 @@

/* Copyright (c) 2008-2016, Stefan Eilemann <eile@equalizergraphics.com>
/* Copyright (c) 2008-2017, Stefan Eilemann <eile@equalizergraphics.com>
* Cedric Stalder <cedric.stalder@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
@@ -102,7 +102,7 @@ void VertexBufferDist::getInstanceData(co::DataOStream& os)
else
os << eq::uint128_t() << Type::none;

os << _node._boundingSphere << _node._range;
os << _node._boundingBox << _node._range;

if (_isRoot())
{
@@ -115,8 +115,7 @@ void VertexBufferDist::getInstanceData(co::DataOStream& os)
const VertexBufferLeaf& leaf =
dynamic_cast<const VertexBufferLeaf&>(_node);

os << leaf._boundingBox[0] << leaf._boundingBox[1]
<< uint64_t(leaf._vertexStart) << uint64_t(leaf._indexStart)
os << uint64_t(leaf._vertexStart) << uint64_t(leaf._indexStart)
<< uint64_t(leaf._indexLength) << leaf._vertexLength;
}
}
@@ -128,7 +127,7 @@ void VertexBufferDist::applyInstanceData(co::DataIStream& is)
const eq::uint128_t& rightID = is.read<eq::uint128_t>();
const Type rightType = is.read<Type>();

is >> _node._boundingSphere >> _node._range;
is >> _node._boundingBox >> _node._range;

if (_isRoot())
{
@@ -142,8 +141,7 @@ void VertexBufferDist::applyInstanceData(co::DataIStream& is)
{
VertexBufferLeaf& leaf = dynamic_cast<VertexBufferLeaf&>(_node);
uint64_t i1, i2, i3;
is >> leaf._boundingBox[0] >> leaf._boundingBox[1] >> i1 >> i2 >> i3 >>
leaf._vertexLength;
is >> i1 >> i2 >> i3 >> leaf._vertexLength;
leaf._vertexStart = size_t(i1);
leaf._indexStart = size_t(i2);
leaf._indexLength = size_t(i3);

0 comments on commit 514077f

Please sign in to comment.
You can’t perform that action at this time.