mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Fix for voxelizing heightfields.
This commit is contained in:
parent
8669398048
commit
1a1b1ca3f3
3 changed files with 19 additions and 1 deletions
|
@ -1014,6 +1014,7 @@ QColor VoxelMaterialSpannerTool::getColor() {
|
|||
}
|
||||
|
||||
void VoxelMaterialSpannerTool::applyEdit(const AttributePointer& attribute, const SharedObjectPointer& spanner) {
|
||||
static_cast<Spanner*>(spanner.data())->setWillBeVoxelized(true);
|
||||
MetavoxelEditMessage message = { QVariant::fromValue(VoxelMaterialSpannerEdit(spanner,
|
||||
_materialControl->getMaterial(), _materialControl->getColor())) };
|
||||
Application::getInstance()->getMetavoxels()->applyEdit(message, true);
|
||||
|
|
|
@ -61,7 +61,8 @@ Spanner::Spanner() :
|
|||
_renderer(NULL),
|
||||
_placementGranularity(DEFAULT_PLACEMENT_GRANULARITY),
|
||||
_voxelizationGranularity(DEFAULT_VOXELIZATION_GRANULARITY),
|
||||
_merged(false) {
|
||||
_merged(false),
|
||||
_willBeVoxelized(false) {
|
||||
}
|
||||
|
||||
void Spanner::setBounds(const Box& bounds) {
|
||||
|
@ -2542,6 +2543,9 @@ MetavoxelLOD Heightfield::transformLOD(const MetavoxelLOD& lod) const {
|
|||
|
||||
SharedObject* Heightfield::clone(bool withID, SharedObject* target) const {
|
||||
Heightfield* newHeightfield = static_cast<Heightfield*>(Spanner::clone(withID, target));
|
||||
newHeightfield->setHeight(_height);
|
||||
newHeightfield->setColor(_color);
|
||||
newHeightfield->setMaterial(_material);
|
||||
newHeightfield->setRoot(_root);
|
||||
return newHeightfield;
|
||||
}
|
||||
|
@ -2920,6 +2924,10 @@ bool Heightfield::intersects(const glm::vec3& start, const glm::vec3& end, float
|
|||
}
|
||||
|
||||
void Heightfield::writeExtra(Bitstream& out) const {
|
||||
if (getWillBeVoxelized()) {
|
||||
out << _height << _color << _material;
|
||||
return;
|
||||
}
|
||||
MetavoxelLOD lod;
|
||||
if (out.getContext()) {
|
||||
lod = transformLOD(static_cast<MetavoxelStreamBase*>(out.getContext())->lod);
|
||||
|
@ -2930,6 +2938,10 @@ void Heightfield::writeExtra(Bitstream& out) const {
|
|||
}
|
||||
|
||||
void Heightfield::readExtra(Bitstream& in) {
|
||||
if (getWillBeVoxelized()) {
|
||||
in >> _height >> _color >> _material;
|
||||
return;
|
||||
}
|
||||
MetavoxelLOD lod;
|
||||
if (in.getContext()) {
|
||||
lod = transformLOD(static_cast<MetavoxelStreamBase*>(in.getContext())->lod);
|
||||
|
|
|
@ -29,6 +29,7 @@ class Spanner : public SharedObject {
|
|||
Q_PROPERTY(Box bounds MEMBER _bounds WRITE setBounds NOTIFY boundsChanged DESIGNABLE false)
|
||||
Q_PROPERTY(float placementGranularity MEMBER _placementGranularity DESIGNABLE false)
|
||||
Q_PROPERTY(float voxelizationGranularity MEMBER _voxelizationGranularity DESIGNABLE false)
|
||||
Q_PROPERTY(bool willBeVoxelized MEMBER _willBeVoxelized DESIGNABLE false)
|
||||
|
||||
public:
|
||||
|
||||
|
@ -49,6 +50,9 @@ public:
|
|||
void setMerged(bool merged) { _merged = merged; }
|
||||
bool isMerged() const { return _merged; }
|
||||
|
||||
void setWillBeVoxelized(bool willBeVoxelized) { _willBeVoxelized = willBeVoxelized; }
|
||||
bool getWillBeVoxelized() const { return _willBeVoxelized; }
|
||||
|
||||
/// Checks whether we've visited this object on the current traversal. If we have, returns false.
|
||||
/// If we haven't, sets the last visit identifier and returns true.
|
||||
bool testAndSetVisited(int visit);
|
||||
|
@ -118,6 +122,7 @@ private:
|
|||
float _placementGranularity;
|
||||
float _voxelizationGranularity;
|
||||
bool _merged;
|
||||
bool _willBeVoxelized;
|
||||
QHash<QThread*, int> _lastVisits; ///< last visit identifiers for each thread
|
||||
QMutex _lastVisitsMutex;
|
||||
|
||||
|
|
Loading…
Reference in a new issue