More consistent name handling across various shape implementations (patch by Lorenzo Tessari)
parent
23eb714038
commit
b821dc9e33
|
@ -184,7 +184,6 @@ public:
|
||||||
/// Return the name of this shape (e.g. the filename)
|
/// Return the name of this shape (e.g. the filename)
|
||||||
virtual std::string getName() const;
|
virtual std::string getName() const;
|
||||||
|
|
||||||
|
|
||||||
/// Is this a compound shape consisting of several sub-objects?
|
/// Is this a compound shape consisting of several sub-objects?
|
||||||
virtual bool isCompound() const;
|
virtual bool isCompound() const;
|
||||||
|
|
||||||
|
@ -519,6 +518,7 @@ protected:
|
||||||
/// Virtual destructor
|
/// Virtual destructor
|
||||||
virtual ~Shape();
|
virtual ~Shape();
|
||||||
protected:
|
protected:
|
||||||
|
std::string m_name;
|
||||||
ref<BSDF> m_bsdf;
|
ref<BSDF> m_bsdf;
|
||||||
ref<Subsurface> m_subsurface;
|
ref<Subsurface> m_subsurface;
|
||||||
ref<Emitter> m_emitter;
|
ref<Emitter> m_emitter;
|
||||||
|
|
|
@ -94,9 +94,6 @@ public:
|
||||||
//! @{ \name General query functions
|
//! @{ \name General query functions
|
||||||
// =============================================================
|
// =============================================================
|
||||||
|
|
||||||
/// Return the name of this shape (e.g. the filename)
|
|
||||||
std::string getName() const;
|
|
||||||
|
|
||||||
/// Return the total surface area
|
/// Return the total surface area
|
||||||
Float getSurfaceArea() const;
|
Float getSurfaceArea() const;
|
||||||
|
|
||||||
|
@ -356,7 +353,6 @@ protected:
|
||||||
/// Prepare internal tables for sampling uniformly wrt. area
|
/// Prepare internal tables for sampling uniformly wrt. area
|
||||||
void prepareSamplingTable();
|
void prepareSamplingTable();
|
||||||
protected:
|
protected:
|
||||||
std::string m_name;
|
|
||||||
AABB m_aabb;
|
AABB m_aabb;
|
||||||
Triangle *m_triangles;
|
Triangle *m_triangles;
|
||||||
Point *m_positions;
|
Point *m_positions;
|
||||||
|
|
|
@ -191,7 +191,7 @@ bool ManifoldPerturbation::sampleMutationRecord(
|
||||||
Float sample = m_sampler->next1D();
|
Float sample = m_sampler->next1D();
|
||||||
a = -1;
|
a = -1;
|
||||||
|
|
||||||
if (source.vertex(k-1)->isConnectable()) {
|
if (source.vertex(k-1)->isConnectable() && false) {
|
||||||
/* Extra optimization: slightly prefer perturbations from the sensor */
|
/* Extra optimization: slightly prefer perturbations from the sensor */
|
||||||
#define SENSOR_PROB (Float) 0.25f
|
#define SENSOR_PROB (Float) 0.25f
|
||||||
|
|
||||||
|
@ -203,6 +203,9 @@ bool ManifoldPerturbation::sampleMutationRecord(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a = 1;
|
||||||
|
step = 1;
|
||||||
|
|
||||||
if (a < 0) {
|
if (a < 0) {
|
||||||
step = sample < 0.5f ? 1 : -1;
|
step = sample < 0.5f ? 1 : -1;
|
||||||
|
|
||||||
|
@ -515,7 +518,7 @@ bool ManifoldPerturbation::sampleMutation(
|
||||||
Point p1 = m_manifold->getPosition(1);
|
Point p1 = m_manifold->getPosition(1);
|
||||||
Float relerr = (p0-p1).length() / std::max(std::max(std::abs(p0.x),
|
Float relerr = (p0-p1).length() / std::max(std::max(std::abs(p0.x),
|
||||||
std::abs(p0.y)), std::abs(p0.z));
|
std::abs(p0.y)), std::abs(p0.z));
|
||||||
if (relerr > Epsilon) {
|
if (relerr > ShadowEpsilon) {
|
||||||
++statsNonReversible;
|
++statsNonReversible;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,13 @@
|
||||||
MTS_NAMESPACE_BEGIN
|
MTS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
Shape::Shape(const Properties &props)
|
Shape::Shape(const Properties &props)
|
||||||
: ConfigurableObject(props) { }
|
: ConfigurableObject(props) {
|
||||||
|
m_name = props.getID();
|
||||||
|
}
|
||||||
|
|
||||||
Shape::Shape(Stream *stream, InstanceManager *manager)
|
Shape::Shape(Stream *stream, InstanceManager *manager)
|
||||||
: ConfigurableObject(stream, manager) {
|
: ConfigurableObject(stream, manager) {
|
||||||
|
m_name = stream->readString();
|
||||||
m_bsdf = static_cast<BSDF *>(manager->getInstance(stream));
|
m_bsdf = static_cast<BSDF *>(manager->getInstance(stream));
|
||||||
m_subsurface = static_cast<Subsurface *>(manager->getInstance(stream));
|
m_subsurface = static_cast<Subsurface *>(manager->getInstance(stream));
|
||||||
m_emitter = static_cast<Emitter *>(manager->getInstance(stream));
|
m_emitter = static_cast<Emitter *>(manager->getInstance(stream));
|
||||||
|
@ -83,7 +86,7 @@ bool Shape::isCompound() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Shape::getName() const {
|
std::string Shape::getName() const {
|
||||||
return "Unnamed";
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shape *Shape::getElement(int i) {
|
Shape *Shape::getElement(int i) {
|
||||||
|
@ -183,6 +186,7 @@ const KDTreeBase<AABB> *Shape::getKDTree() const {
|
||||||
|
|
||||||
void Shape::serialize(Stream *stream, InstanceManager *manager) const {
|
void Shape::serialize(Stream *stream, InstanceManager *manager) const {
|
||||||
ConfigurableObject::serialize(stream, manager);
|
ConfigurableObject::serialize(stream, manager);
|
||||||
|
stream->writeString(m_name);
|
||||||
manager->serialize(stream, m_bsdf.get());
|
manager->serialize(stream, m_bsdf.get());
|
||||||
manager->serialize(stream, m_subsurface.get());
|
manager->serialize(stream, m_subsurface.get());
|
||||||
manager->serialize(stream, m_emitter.get());
|
manager->serialize(stream, m_emitter.get());
|
||||||
|
|
|
@ -351,10 +351,6 @@ TriMesh::~TriMesh() {
|
||||||
delete[] m_triangles;
|
delete[] m_triangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TriMesh::getName() const {
|
|
||||||
return m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
AABB TriMesh::getAABB() const {
|
AABB TriMesh::getAABB() const {
|
||||||
return m_aabb;
|
return m_aabb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ static uint32_t CubeData_triangles[][3] = {{0, 1, 2}, {3, 0, 2}, {4, 5, 6}, {7,
|
||||||
class Cube : public TriMesh {
|
class Cube : public TriMesh {
|
||||||
public:
|
public:
|
||||||
Cube(const Properties &props) : TriMesh(props) {
|
Cube(const Properties &props) : TriMesh(props) {
|
||||||
m_name = props.getID();
|
|
||||||
m_triangleCount = 12;
|
m_triangleCount = 12;
|
||||||
m_vertexCount = 24;
|
m_vertexCount = 24;
|
||||||
m_positions = new Point[m_vertexCount];
|
m_positions = new Point[m_vertexCount];
|
||||||
|
|
|
@ -350,7 +350,6 @@ public:
|
||||||
|
|
||||||
WavefrontOBJ(Stream *stream, InstanceManager *manager) : Shape(stream, manager) {
|
WavefrontOBJ(Stream *stream, InstanceManager *manager) : Shape(stream, manager) {
|
||||||
m_aabb = AABB(stream);
|
m_aabb = AABB(stream);
|
||||||
m_name = stream->readString();
|
|
||||||
uint32_t meshCount = stream->readUInt();
|
uint32_t meshCount = stream->readUInt();
|
||||||
m_meshes.resize(meshCount);
|
m_meshes.resize(meshCount);
|
||||||
|
|
||||||
|
@ -364,7 +363,6 @@ public:
|
||||||
Shape::serialize(stream, manager);
|
Shape::serialize(stream, manager);
|
||||||
|
|
||||||
m_aabb.serialize(stream);
|
m_aabb.serialize(stream);
|
||||||
stream->writeString(m_name);
|
|
||||||
stream->writeUInt((uint32_t) m_meshes.size());
|
stream->writeUInt((uint32_t) m_meshes.size());
|
||||||
for (size_t i=0; i<m_meshes.size(); ++i)
|
for (size_t i=0; i<m_meshes.size(); ++i)
|
||||||
manager->serialize(stream, m_meshes[i]);
|
manager->serialize(stream, m_meshes[i]);
|
||||||
|
@ -806,10 +804,6 @@ public:
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getName() const {
|
|
||||||
return m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
AABB getAABB() const {
|
AABB getAABB() const {
|
||||||
return m_aabb;
|
return m_aabb;
|
||||||
}
|
}
|
||||||
|
@ -840,7 +834,6 @@ private:
|
||||||
std::vector<TriMesh *> m_meshes;
|
std::vector<TriMesh *> m_meshes;
|
||||||
std::vector<std::string> m_materialAssignment;
|
std::vector<std::string> m_materialAssignment;
|
||||||
bool m_flipNormals, m_faceNormals;
|
bool m_flipNormals, m_faceNormals;
|
||||||
std::string m_name;
|
|
||||||
AABB m_aabb;
|
AABB m_aabb;
|
||||||
bool m_collapse;
|
bool m_collapse;
|
||||||
};
|
};
|
||||||
|
|
|
@ -72,7 +72,6 @@ MTS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
ShapeGroup::ShapeGroup(const Properties &props) : Shape(props) {
|
ShapeGroup::ShapeGroup(const Properties &props) : Shape(props) {
|
||||||
m_kdtree = new ShapeKDTree();
|
m_kdtree = new ShapeKDTree();
|
||||||
m_name = props.getID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeGroup::ShapeGroup(Stream *stream, InstanceManager *manager)
|
ShapeGroup::ShapeGroup(Stream *stream, InstanceManager *manager)
|
||||||
|
@ -143,10 +142,6 @@ bool ShapeGroup::isCompound() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ShapeGroup::getName() const {
|
|
||||||
return m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t ShapeGroup::getPrimitiveCount() const {
|
size_t ShapeGroup::getPrimitiveCount() const {
|
||||||
const std::vector<const Shape *> &shapes = m_kdtree->getShapes();
|
const std::vector<const Shape *> &shapes = m_kdtree->getShapes();
|
||||||
size_t result = 0;
|
size_t result = 0;
|
||||||
|
|
|
@ -68,16 +68,12 @@ public:
|
||||||
/// Return the effective primitive count of this shape (always zero)
|
/// Return the effective primitive count of this shape (always zero)
|
||||||
size_t getEffectivePrimitiveCount() const;
|
size_t getEffectivePrimitiveCount() const;
|
||||||
|
|
||||||
/// Return the name of the geometry group
|
|
||||||
std::string getName() const;
|
|
||||||
|
|
||||||
/// Return a string representation
|
/// Return a string representation
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
MTS_DECLARE_CLASS()
|
MTS_DECLARE_CLASS()
|
||||||
private:
|
private:
|
||||||
ref<ShapeKDTree> m_kdtree;
|
ref<ShapeKDTree> m_kdtree;
|
||||||
std::string m_name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MTS_NAMESPACE_END
|
MTS_NAMESPACE_END
|
||||||
|
|
Loading…
Reference in New Issue