use enum for polyvox surface style

This commit is contained in:
Seth Alves 2015-05-27 09:32:10 -07:00
parent 1749ec83db
commit 3af916e27e
4 changed files with 30 additions and 16 deletions

View file

@ -126,14 +126,19 @@ void RenderablePolyVoxEntityItem::getModel() {
// A mesh object to hold the result of surface extraction
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> polyVoxMesh;
if (_voxelSurfaceStyle == 0) {
PolyVox::MarchingCubesSurfaceExtractor<PolyVox::SimpleVolume<uint8_t>> surfaceExtractor
(_volData, _volData->getEnclosingRegion(), &polyVoxMesh);
surfaceExtractor.execute();
} else {
PolyVox::CubicSurfaceExtractorWithNormals<PolyVox::SimpleVolume<uint8_t>> surfaceExtractor
(_volData, _volData->getEnclosingRegion(), &polyVoxMesh);
surfaceExtractor.execute();
switch (_voxelSurfaceStyle) {
case PolyVoxEntityItem::SURFACE_MARCHING_CUBES: {
PolyVox::MarchingCubesSurfaceExtractor<PolyVox::SimpleVolume<uint8_t>> surfaceExtractor
(_volData, _volData->getEnclosingRegion(), &polyVoxMesh);
surfaceExtractor.execute();
break;
}
case PolyVoxEntityItem::SURFACE_CUBIC: {
PolyVox::CubicSurfaceExtractorWithNormals<PolyVox::SimpleVolume<uint8_t>> surfaceExtractor
(_volData, _volData->getEnclosingRegion(), &polyVoxMesh);
surfaceExtractor.execute();
break;
}
}
// convert PolyVox mesh to a Sam mesh

View file

@ -661,12 +661,12 @@ void EntityItem::adjustEditPacketForClockSkew(unsigned char* editPacketBuffer, s
assert(lastEditedInLocalTime > 0);
quint64 lastEditedInServerTime = lastEditedInLocalTime + clockSkew;
memcpy(dataAt, &lastEditedInServerTime, sizeof(lastEditedInServerTime));
//#ifdef WANT_DEBUG
#ifdef WANT_DEBUG
qCDebug(entities, "EntityItem::adjustEditPacketForClockSkew()...");
qCDebug(entities) << " lastEditedInLocalTime: " << lastEditedInLocalTime;
qCDebug(entities) << " clockSkew: " << clockSkew;
qCDebug(entities) << " lastEditedInServerTime: " << lastEditedInServerTime;
//#endif
#endif
}
float EntityItem::computeMass() const {

View file

@ -23,7 +23,8 @@
const glm::vec3 PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE = glm::vec3(32, 32, 32);
const QByteArray PolyVoxEntityItem::DEFAULT_VOXEL_DATA(qCompress(QByteArray(0), 9));
const int PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE = 0;
const PolyVoxEntityItem::PolyVoxSurfaceStyle PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE =
PolyVoxEntityItem::SURFACE_MARCHING_CUBES;
EntityItemPointer PolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return EntityItemPointer(new PolyVoxEntityItem(entityID, properties));
@ -116,7 +117,7 @@ void PolyVoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeB
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
APPEND_ENTITY_PROPERTY(PROP_VOXEL_VOLUME_SIZE, getVoxelVolumeSize());
APPEND_ENTITY_PROPERTY(PROP_VOXEL_DATA, getVoxelData());
APPEND_ENTITY_PROPERTY(PROP_VOXEL_SURFACE_STYLE, getVoxelSurfaceStyle());
APPEND_ENTITY_PROPERTY(PROP_VOXEL_SURFACE_STYLE, (uint16_t) getVoxelSurfaceStyle());
}
void PolyVoxEntityItem::debugDump() const {

View file

@ -67,12 +67,20 @@ class PolyVoxEntityItem : public EntityItem {
virtual void setVoxelData(QByteArray voxelData) { _voxelData = voxelData; }
virtual const QByteArray& getVoxelData() const { return _voxelData; }
virtual void setVoxelSurfaceStyle(uint16_t voxelSurfaceStyle) { _voxelSurfaceStyle = voxelSurfaceStyle; }
virtual uint16_t getVoxelSurfaceStyle() const { return _voxelSurfaceStyle; }
enum PolyVoxSurfaceStyle {
SURFACE_MARCHING_CUBES,
SURFACE_CUBIC
};
virtual void setVoxelSurfaceStyle(PolyVoxSurfaceStyle voxelSurfaceStyle) { _voxelSurfaceStyle = voxelSurfaceStyle; }
virtual void setVoxelSurfaceStyle(uint16_t voxelSurfaceStyle) {
_voxelSurfaceStyle = (PolyVoxSurfaceStyle) voxelSurfaceStyle;
}
virtual PolyVoxSurfaceStyle getVoxelSurfaceStyle() const { return _voxelSurfaceStyle; }
static const glm::vec3 DEFAULT_VOXEL_VOLUME_SIZE;
static const QByteArray DEFAULT_VOXEL_DATA;
static const int DEFAULT_VOXEL_SURFACE_STYLE;
static const PolyVoxSurfaceStyle DEFAULT_VOXEL_SURFACE_STYLE;
// coords are in voxel-volume space
virtual void setSphereInVolume(glm::vec3 center, float radius, uint8_t toValue) {}
@ -84,7 +92,7 @@ class PolyVoxEntityItem : public EntityItem {
rgbColor _color;
glm::vec3 _voxelVolumeSize; // this is always 3 bytes
QByteArray _voxelData;
uint16_t _voxelSurfaceStyle;
PolyVoxSurfaceStyle _voxelSurfaceStyle;
};
#endif // hifi_PolyVoxEntityItem_h