attempting to stitch polyvox entites together

This commit is contained in:
Seth Alves 2015-08-30 09:59:33 -07:00
parent f6fbf4f324
commit 64d0ce47f3
19 changed files with 249 additions and 76 deletions

View file

@ -80,32 +80,33 @@ void OpenGLDisplayPlugin::deactivate() {
// Pass input events on to the application
bool OpenGLDisplayPlugin::eventFilter(QObject* receiver, QEvent* event) {
switch (event->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::MouseMove:
case QEvent::Wheel:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::MouseMove:
case QEvent::Wheel:
case QEvent::TouchBegin:
case QEvent::TouchEnd:
case QEvent::TouchUpdate:
case QEvent::TouchBegin:
case QEvent::TouchEnd:
case QEvent::TouchUpdate:
case QEvent::FocusIn:
case QEvent::FocusOut:
case QEvent::FocusIn:
case QEvent::FocusOut:
case QEvent::KeyPress:
case QEvent::KeyRelease:
case QEvent::ShortcutOverride:
case QEvent::KeyPress:
case QEvent::KeyRelease:
case QEvent::ShortcutOverride:
case QEvent::DragEnter:
case QEvent::Drop:
case QEvent::DragEnter:
case QEvent::Drop:
case QEvent::Resize:
if (QCoreApplication::sendEvent(QCoreApplication::instance(), event)) {
return true;
}
default:
break;
case QEvent::Resize:
if (QCoreApplication::sendEvent(QCoreApplication::instance(), event)) {
return true;
}
break;
default:
break;
}
return false;

View file

@ -78,7 +78,7 @@ void StereoDisplayPlugin::activate() {
}
void StereoDisplayPlugin::updateScreen() {
for (int i = 0; i < (int) _screenActions.size(); ++i) {
for (uint32_t i = 0; i < _screenActions.size(); ++i) {
if (_screenActions[i]->isChecked()) {
CONTAINER->setFullscreen(qApp->screens().at(i));
break;

View file

@ -408,14 +408,17 @@ void RenderablePolyVoxEntityItem::computeShapeInfo(ShapeInfo& info) {
}
void RenderablePolyVoxEntityItem::setXTextureURL(QString xTextureURL) {
_xTexture.clear();
PolyVoxEntityItem::setXTextureURL(xTextureURL);
}
void RenderablePolyVoxEntityItem::setYTextureURL(QString yTextureURL) {
_yTexture.clear();
PolyVoxEntityItem::setYTextureURL(yTextureURL);
}
void RenderablePolyVoxEntityItem::setZTextureURL(QString zTextureURL) {
_zTexture.clear();
PolyVoxEntityItem::setZTextureURL(zTextureURL);
}
@ -598,10 +601,27 @@ void RenderablePolyVoxEntityItem::setVoxelVolumeSize(glm::vec3 voxelVolumeSize)
_volData = new PolyVox::SimpleVolume<uint8_t>(PolyVox::Region(lowCorner, highCorner));
} else {
PolyVox::Vector3DInt32 lowCorner(0, 0, 0);
PolyVox::Vector3DInt32 highCorner(_voxelVolumeSize.x - 1, // -1 because these corners are inclusive
_voxelVolumeSize.y - 1,
_voxelVolumeSize.z - 1);
PolyVox::Vector3DInt32 highCorner(_voxelVolumeSize.x, // -1 because these corners are inclusive
_voxelVolumeSize.y,
_voxelVolumeSize.z);
_volData = new PolyVox::SimpleVolume<uint8_t>(PolyVox::Region(lowCorner, highCorner));
// // XXX
// {
// for (int x = 0; x <= _voxelVolumeSize.x; x++) {
// for (int y = 0; y <= _voxelVolumeSize.y; y++) {
// for (int z = 0; z <= _voxelVolumeSize.z; z++) {
// if (x == _voxelVolumeSize.x ||
// y == _voxelVolumeSize.y ||
// z == _voxelVolumeSize.z) {
// setVoxelInternal(x, y, z, 255);
// }
// }
// }
// }
// }
}
// having the "outside of voxel-space" value be 255 has helped me notice some problems.
@ -851,9 +871,98 @@ void RenderablePolyVoxEntityItem::getMesh() {
}
void RenderablePolyVoxEntityItem::clearOutOfDateNeighbors() {
if (_xNeighborID != UNKNOWN_ENTITY_ID) {
EntityItemPointer currentXNeighbor = _xNeighbor.lock();
if (currentXNeighbor && currentXNeighbor->getID() != _xNeighborID) {
_xNeighbor.reset();
}
}
if (_yNeighborID != UNKNOWN_ENTITY_ID) {
EntityItemPointer currentYNeighbor = _yNeighbor.lock();
if (currentYNeighbor && currentYNeighbor->getID() != _yNeighborID) {
_yNeighbor.reset();
}
}
if (_zNeighborID != UNKNOWN_ENTITY_ID) {
EntityItemPointer currentZNeighbor = _zNeighbor.lock();
if (currentZNeighbor && currentZNeighbor->getID() != _zNeighborID) {
_zNeighbor.reset();
}
}
}
void RenderablePolyVoxEntityItem::cacheNeighbors() {
if (_voxelSurfaceStyle != PolyVoxEntityItem::SURFACE_CUBIC &&
_voxelSurfaceStyle != PolyVoxEntityItem::SURFACE_MARCHING_CUBES) {
return;
}
clearOutOfDateNeighbors();
EntityTreeElement* element = getElement();
EntityTree* tree = element ? element->getTree() : nullptr;
if (!tree) {
return;
}
if (_xNeighborID != UNKNOWN_ENTITY_ID && _xNeighbor.expired()) {
_xNeighbor = tree->findEntityByID(_xNeighborID);
}
if (_yNeighborID != UNKNOWN_ENTITY_ID && _yNeighbor.expired()) {
_yNeighbor = tree->findEntityByID(_yNeighborID);
}
if (_zNeighborID != UNKNOWN_ENTITY_ID && _zNeighbor.expired()) {
_zNeighbor = tree->findEntityByID(_zNeighborID);
}
}
void RenderablePolyVoxEntityItem::copyUpperEdgesFromNeighbors() {
if (_voxelSurfaceStyle != PolyVoxEntityItem::SURFACE_CUBIC &&
_voxelSurfaceStyle != PolyVoxEntityItem::SURFACE_MARCHING_CUBES) {
return;
}
EntityItemPointer currentXNeighbor = _xNeighbor.lock();
EntityItemPointer currentYNeighbor = _yNeighbor.lock();
EntityItemPointer currentZNeighbor = _zNeighbor.lock();
if (currentXNeighbor) {
auto polyVoxXNeighbor = std::dynamic_pointer_cast<PolyVoxEntityItem>(currentXNeighbor);
for (int y = 0; y < _voxelVolumeSize.y; y++) {
for (int z = 0; z < _voxelVolumeSize.z; y++) {
uint8_t neighborValue = polyVoxXNeighbor->getVoxel(0, y, z);
_volData->setVoxelAt(_voxelVolumeSize.x, y, z, neighborValue);
}
}
}
if (currentYNeighbor) {
auto polyVoxYNeighbor = std::dynamic_pointer_cast<PolyVoxEntityItem>(currentYNeighbor);
for (int x = 0; x < _voxelVolumeSize.x; x++) {
for (int z = 0; z < _voxelVolumeSize.z; z++) {
uint8_t neighborValue = polyVoxYNeighbor->getVoxel(x, 0, z);
_volData->setVoxelAt(x, _voxelVolumeSize.y, z, neighborValue);
}
}
}
if (currentZNeighbor) {
auto polyVoxZNeighbor = std::dynamic_pointer_cast<PolyVoxEntityItem>(currentZNeighbor);
for (int x = 0; x < _voxelVolumeSize.x; x++) {
for (int y = 0; y < _voxelVolumeSize.y; y++) {
uint8_t neighborValue = polyVoxZNeighbor->getVoxel(x, y, 0);
_volData->setVoxelAt(x, y, _voxelVolumeSize.z, neighborValue);
}
}
}
}
void RenderablePolyVoxEntityItem::getMeshAsync() {
model::MeshPointer mesh(new model::Mesh());
cacheNeighbors();
copyUpperEdgesFromNeighbors();
// A mesh object to hold the result of surface extraction
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> polyVoxMesh;

View file

@ -147,6 +147,14 @@ private:
void computeShapeInfoWorkerAsync();
QSemaphore _threadRunning{1};
// these are cached lookups of _xNeighborID, _yNeighborID, _zNeighborID
EntityItemWeakPointer _xNeighbor;
EntityItemWeakPointer _yNeighbor;
EntityItemWeakPointer _zNeighbor;
void clearOutOfDateNeighbors();
void cacheNeighbors();
void copyUpperEdgesFromNeighbors();
};

View file

@ -32,26 +32,8 @@ public:
QScriptValue toScriptValue(QScriptEngine* engine) const;
bool isInvalidID() const { return *this == UNKNOWN_ENTITY_ID; }
// QUuid id;
};
// inline bool operator<(const EntityItemID& a, const EntityItemID& b) {
// return a.id < b.id;
// }
// inline bool operator==(const EntityItemID& a, const EntityItemID& b) {
// return a.id == b.id;
// }
// inline bool operator!=(const EntityItemID& a, const EntityItemID& b) {
// return !(a == b);
// }
// inline uint qHash(const EntityItemID& a, uint seed) {
// return qHash(a.id, seed);
// }
inline QDebug operator<<(QDebug debug, const EntityItemID& id) {
debug << "[entity-id:" << id.toString() << "]";
return debug;

View file

@ -109,6 +109,10 @@ CONSTRUCT_PROPERTY(strokeWidths, QVector<float>()),
CONSTRUCT_PROPERTY(xTextureURL, ""),
CONSTRUCT_PROPERTY(yTextureURL, ""),
CONSTRUCT_PROPERTY(zTextureURL, ""),
CONSTRUCT_PROPERTY(xNeighborID, UNKNOWN_ENTITY_ID),
CONSTRUCT_PROPERTY(yNeighborID, UNKNOWN_ENTITY_ID),
CONSTRUCT_PROPERTY(zNeighborID, UNKNOWN_ENTITY_ID),
_id(UNKNOWN_ENTITY_ID),
_idSet(false),
@ -377,6 +381,9 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_X_TEXTURE_URL, xTextureURL);
CHECK_PROPERTY_CHANGE(PROP_Y_TEXTURE_URL, yTextureURL);
CHECK_PROPERTY_CHANGE(PROP_Z_TEXTURE_URL, zTextureURL);
CHECK_PROPERTY_CHANGE(PROP_X_NEIGHBOR_ID, xNeighborID);
CHECK_PROPERTY_CHANGE(PROP_Y_NEIGHBOR_ID, yNeighborID);
CHECK_PROPERTY_CHANGE(PROP_Z_NEIGHBOR_ID, zNeighborID);
changedProperties += _stage.getChangedProperties();
changedProperties += _atmosphere.getChangedProperties();
@ -521,6 +528,10 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(yTextureURL);
COPY_PROPERTY_TO_QSCRIPTVALUE(zTextureURL);
COPY_PROPERTY_TO_QSCRIPTVALUE(xNeighborID);
COPY_PROPERTY_TO_QSCRIPTVALUE(yNeighborID);
COPY_PROPERTY_TO_QSCRIPTVALUE(zNeighborID);
return properties;
}
@ -620,6 +631,10 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
COPY_PROPERTY_FROM_QSCRIPTVALUE(yTextureURL, QString, setYTextureURL);
COPY_PROPERTY_FROM_QSCRIPTVALUE(zTextureURL, QString, setZTextureURL);
COPY_PROPERTY_FROM_QSCRIPTVALUE(xNeighborID, EntityItemID, setXNeighborID);
COPY_PROPERTY_FROM_QSCRIPTVALUE(yNeighborID, EntityItemID, setYNeighborID);
COPY_PROPERTY_FROM_QSCRIPTVALUE(zNeighborID, EntityItemID, setZNeighborID);
_lastEdited = usecTimestampNow();
}
@ -852,6 +867,9 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType::Value command, Ent
APPEND_ENTITY_PROPERTY(PROP_X_TEXTURE_URL, properties.getXTextureURL());
APPEND_ENTITY_PROPERTY(PROP_Y_TEXTURE_URL, properties.getYTextureURL());
APPEND_ENTITY_PROPERTY(PROP_Z_TEXTURE_URL, properties.getZTextureURL());
APPEND_ENTITY_PROPERTY(PROP_X_NEIGHBOR_ID, properties.getXNeighborID());
APPEND_ENTITY_PROPERTY(PROP_Y_NEIGHBOR_ID, properties.getYNeighborID());
APPEND_ENTITY_PROPERTY(PROP_Z_NEIGHBOR_ID, properties.getZNeighborID());
}
if (properties.getType() == EntityTypes::Line) {
@ -1115,6 +1133,9 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_X_TEXTURE_URL, QString, setXTextureURL);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_Y_TEXTURE_URL, QString, setYTextureURL);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_Z_TEXTURE_URL, QString, setZTextureURL);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_X_NEIGHBOR_ID, EntityItemID, setXNeighborID);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_Y_NEIGHBOR_ID, EntityItemID, setYNeighborID);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_Z_NEIGHBOR_ID, EntityItemID, setZNeighborID);
}
if (properties.getType() == EntityTypes::Line) {
@ -1248,13 +1269,17 @@ void EntityItemProperties::markAllChanged() {
_descriptionChanged = true;
_faceCameraChanged = true;
_actionDataChanged = true;
_normalsChanged = true;
_strokeWidthsChanged = true;
_xTextureURLChanged = true;
_yTextureURLChanged = true;
_zTextureURLChanged = true;
_xNeighborIDChanged = true;
_yNeighborIDChanged = true;
_zNeighborIDChanged = true;
}
/// The maximum bounding cube for the entity, independent of it's rotation.

View file

@ -161,6 +161,9 @@ public:
DEFINE_PROPERTY_REF(PROP_X_TEXTURE_URL, XTextureURL, xTextureURL, QString);
DEFINE_PROPERTY_REF(PROP_Y_TEXTURE_URL, YTextureURL, yTextureURL, QString);
DEFINE_PROPERTY_REF(PROP_Z_TEXTURE_URL, ZTextureURL, zTextureURL, QString);
DEFINE_PROPERTY_REF(PROP_X_NEIGHBOR_ID, XNeighborID, xNeighborID, EntityItemID);
DEFINE_PROPERTY_REF(PROP_Y_NEIGHBOR_ID, YNeighborID, yNeighborID, EntityItemID);
DEFINE_PROPERTY_REF(PROP_Z_NEIGHBOR_ID, ZNeighborID, zNeighborID, EntityItemID);
static QString getBackgroundModeString(BackgroundMode mode);
@ -327,6 +330,9 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
DEBUG_PROPERTY_IF_CHANGED(debug, properties, XTextureURL, xTextureURL, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, YTextureURL, yTextureURL, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, ZTextureURL, zTextureURL, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, XNeighborID, xNeighborID, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, YNeighborID, yNeighborID, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, ZNeighborID, zNeighborID, "");
properties.getStage().debugDump();
properties.getAtmosphere().debugDump();

View file

@ -14,6 +14,8 @@
#ifndef hifi_EntityItemPropertiesMacros_h
#define hifi_EntityItemPropertiesMacros_h
#include "EntityItemID.h"
#define APPEND_ENTITY_PROPERTY(P,V) \
if (requestedProperties.getHasProperty(P)) { \
LevelDetails propertyLevel = packetData->startLevel(); \
@ -106,6 +108,9 @@ inline QScriptValue convertScriptValue(QScriptEngine* e, const QByteArray& v) {
return QScriptValue(QString(b64));
}
inline QScriptValue convertScriptValue(QScriptEngine* e, const EntityItemID& v) { return QScriptValue(QUuid(v).toString()); }
#define COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(G,g,P,p) \
if (!skipDefaults || defaultEntityProperties.get##G().get##P() != get##P()) { \
QScriptValue groupProperties = properties.property(#g); \
@ -143,6 +148,9 @@ inline int int_convertFromScriptValue(const QScriptValue& v, bool& isValid) { re
inline bool bool_convertFromScriptValue(const QScriptValue& v, bool& isValid) { isValid = true; return v.toVariant().toBool(); }
inline QString QString_convertFromScriptValue(const QScriptValue& v, bool& isValid) { isValid = true; return v.toVariant().toString().trimmed(); }
inline QUuid QUuid_convertFromScriptValue(const QScriptValue& v, bool& isValid) { isValid = true; return v.toVariant().toUuid(); }
inline EntityItemID EntityItemID_convertFromScriptValue(const QScriptValue& v, bool& isValid) { isValid = true; return v.toVariant().toUuid(); }
inline QDateTime QDateTime_convertFromScriptValue(const QScriptValue& v, bool& isValid) {
isValid = true;

View file

@ -124,21 +124,25 @@ enum EntityPropertyList {
PROP_FACE_CAMERA,
PROP_SCRIPT_TIMESTAMP,
PROP_ACTION_DATA,
PROP_X_TEXTURE_URL, // used by PolyVox
PROP_Y_TEXTURE_URL, // used by PolyVox
PROP_Z_TEXTURE_URL, // used by PolyVox
// Used by PolyLine entity
PROP_NORMALS,
PROP_STROKE_WIDTHS,
// used by particles
PROP_VELOCITY_SPREAD,
PROP_ACCELERATION_SPREAD,
PROP_X_NEIGHBOR_ID, // used by PolyVox
PROP_Y_NEIGHBOR_ID, // used by PolyVox
PROP_Z_NEIGHBOR_ID, // used by PolyVox
////////////////////////////////////////////////////////////////////////////////////////////////////
// ATTENTION: add new properties to end of list just ABOVE this line
PROP_AFTER_LAST_ITEM,

View file

@ -131,20 +131,20 @@ void ParticleEffectEntityItem::computeAndUpdateDimensions() {
float maxVelocityX = fabsf(_velocity.x) + _velocitySpread.x;
float maxAccelerationX = fabsf(_acceleration.x) + _accelerationSpread.x;
float maxXDistance = (maxVelocityX * time) + (0.5 * maxAccelerationX * time * time);
float maxXDistance = (maxVelocityX * time) + (0.5f * maxAccelerationX * time * time);
float maxVelocityY = fabs(_velocity.y) + _velocitySpread.y;
float maxVelocityY = fabsf(_velocity.y) + _velocitySpread.y;
float maxAccelerationY = fabsf(_acceleration.y) + _accelerationSpread.y;
float maxYDistance = (maxVelocityY * time) + (0.5 * maxAccelerationY * time * time);
float maxYDistance = (maxVelocityY * time) + (0.5f * maxAccelerationY * time * time);
float maxVelocityZ = fabsf(_velocity.z) + _velocitySpread.z;
float maxAccelerationZ = fabsf(_acceleration.z) + _accelerationSpread.z;
float maxZDistance = (maxVelocityZ * time) + (0.5 * maxAccelerationZ * time * time);
float maxZDistance = (maxVelocityZ * time) + (0.5f * maxAccelerationZ * time * time);
float maxDistance = std::max(maxXDistance, std::max(maxYDistance, maxZDistance));
//times 2 because dimensions are diameters not radii
glm::vec3 dims(2.0 * maxDistance);
glm::vec3 dims(2.0f * maxDistance);
EntityItem::setDimensions(dims);
}

View file

@ -56,7 +56,10 @@ PolyVoxEntityItem::PolyVoxEntityItem(const EntityItemID& entityItemID, const Ent
_voxelSurfaceStyle(PolyVoxEntityItem::DEFAULT_VOXEL_SURFACE_STYLE),
_xTextureURL(PolyVoxEntityItem::DEFAULT_X_TEXTURE_URL),
_yTextureURL(PolyVoxEntityItem::DEFAULT_Y_TEXTURE_URL),
_zTextureURL(PolyVoxEntityItem::DEFAULT_Z_TEXTURE_URL)
_zTextureURL(PolyVoxEntityItem::DEFAULT_Z_TEXTURE_URL),
_xNeighborID(UNKNOWN_ENTITY_ID),
_yNeighborID(UNKNOWN_ENTITY_ID),
_zNeighborID(UNKNOWN_ENTITY_ID)
{
_type = EntityTypes::PolyVox;
setProperties(properties);
@ -104,6 +107,9 @@ EntityItemProperties PolyVoxEntityItem::getProperties() const {
COPY_ENTITY_PROPERTY_TO_PROPERTIES(xTextureURL, getXTextureURL);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(yTextureURL, getYTextureURL);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(zTextureURL, getZTextureURL);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(xNeighborID, getXNeighborID);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(yNeighborID, getYNeighborID);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(zNeighborID, getZNeighborID);
return properties;
}
@ -116,6 +122,9 @@ bool PolyVoxEntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(xTextureURL, setXTextureURL);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(yTextureURL, setYTextureURL);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(zTextureURL, setZTextureURL);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(xNeighborID, setXNeighborID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(yNeighborID, setYNeighborID);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(zNeighborID, setZNeighborID);
if (somethingChanged) {
bool wantDebug = false;
@ -143,6 +152,9 @@ int PolyVoxEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* dat
READ_ENTITY_PROPERTY(PROP_X_TEXTURE_URL, QString, setXTextureURL);
READ_ENTITY_PROPERTY(PROP_Y_TEXTURE_URL, QString, setYTextureURL);
READ_ENTITY_PROPERTY(PROP_Z_TEXTURE_URL, QString, setZTextureURL);
READ_ENTITY_PROPERTY(PROP_X_NEIGHBOR_ID, EntityItemID, setXNeighborID);
READ_ENTITY_PROPERTY(PROP_Y_NEIGHBOR_ID, EntityItemID, setYNeighborID);
READ_ENTITY_PROPERTY(PROP_Z_NEIGHBOR_ID, EntityItemID, setZNeighborID);
return bytesRead;
}
@ -160,13 +172,13 @@ EntityPropertyFlags PolyVoxEntityItem::getEntityProperties(EncodeBitstreamParams
return requestedProperties;
}
void PolyVoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
void PolyVoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
EntityTreeElementExtraEncodeData* modelTreeElementExtraEncodeData,
EntityPropertyFlags& requestedProperties,
EntityPropertyFlags& propertyFlags,
EntityPropertyFlags& propertiesDidntFit,
int& propertyCount,
OctreeElement::AppendState& appendState) const {
int& propertyCount,
OctreeElement::AppendState& appendState) const {
bool successPropertyFits = true;
APPEND_ENTITY_PROPERTY(PROP_VOXEL_VOLUME_SIZE, getVoxelVolumeSize());
@ -175,7 +187,9 @@ void PolyVoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeB
APPEND_ENTITY_PROPERTY(PROP_X_TEXTURE_URL, getXTextureURL());
APPEND_ENTITY_PROPERTY(PROP_Y_TEXTURE_URL, getYTextureURL());
APPEND_ENTITY_PROPERTY(PROP_Z_TEXTURE_URL, getZTextureURL());
APPEND_ENTITY_PROPERTY(PROP_X_NEIGHBOR_ID, getXNeighborID());
APPEND_ENTITY_PROPERTY(PROP_Y_NEIGHBOR_ID, getYNeighborID());
APPEND_ENTITY_PROPERTY(PROP_Z_NEIGHBOR_ID, getZNeighborID());
}
void PolyVoxEntityItem::debugDump() const {

View file

@ -103,6 +103,17 @@ class PolyVoxEntityItem : public EntityItem {
virtual void setZTextureURL(QString zTextureURL) { _zTextureURL = zTextureURL; }
virtual const QString& getZTextureURL() const { return _zTextureURL; }
virtual void setXNeighborID(const EntityItemID& xNeighborID) { _xNeighborID = xNeighborID; }
virtual void setXNeighborID(const QString& xNeighborID) { _xNeighborID = QUuid(xNeighborID); }
virtual const EntityItemID& getXNeighborID() const { return _xNeighborID; }
virtual void setYNeighborID(const EntityItemID& yNeighborID) { _yNeighborID = yNeighborID; }
virtual void setYNeighborID(const QString& yNeighborID) { _yNeighborID = QUuid(yNeighborID); }
virtual const EntityItemID& getYNeighborID() const { return _yNeighborID; }
virtual void setZNeighborID(const EntityItemID& zNeighborID) { _zNeighborID = zNeighborID; }
virtual void setZNeighborID(const QString& zNeighborID) { _zNeighborID = QUuid(zNeighborID); }
virtual const EntityItemID& getZNeighborID() const { return _zNeighborID; }
protected:
glm::vec3 _voxelVolumeSize; // this is always 3 bytes
@ -116,6 +127,10 @@ class PolyVoxEntityItem : public EntityItem {
QString _yTextureURL;
QString _zTextureURL;
// for non-edged surface styles, these are used to compute the high-axis edges
EntityItemID _xNeighborID;
EntityItemID _yNeighborID;
EntityItemID _zNeighborID;
};
#endif // hifi_PolyVoxEntityItem_h

View file

@ -230,7 +230,7 @@ void UserInputMapper::update(float deltaTime) {
for (auto i = 0; i < NUM_ACTIONS; i++) {
_actionStates[i] *= _actionScales[i];
// Emit only on change, and emit when moving back to 0
if (fabs(_actionStates[i] - _lastActionStates[i]) > EPSILON) {
if (fabsf(_actionStates[i] - _lastActionStates[i]) > EPSILON) {
_lastActionStates[i] = _actionStates[i];
emit actionEvent(i, _actionStates[i]);
}
@ -319,4 +319,4 @@ void UserInputMapper::createActionNames() {
_actionNames[SHIFT] = "SHIFT";
_actionNames[ACTION1] = "ACTION1";
_actionNames[ACTION2] = "ACTION2";
}
}

View file

@ -67,7 +67,7 @@ PacketVersion versionForPacketType(PacketType::Value packetType) {
case EntityAdd:
case EntityEdit:
case EntityData:
return VERSION_ENTITIES_PARTICLE_MODIFICATIONS;
return VERSION_ENTITIES_POLYVOX_NEIGHBORS;
case AvatarData:
return 12;
default:

View file

@ -144,5 +144,6 @@ const PacketVersion VERSION_POLYVOX_TEXTURES = 36;
const PacketVersion VERSION_ENTITIES_POLYLINE = 37;
const PacketVersion VERSION_OCTREE_CENTERED_ORIGIN = 38;
const PacketVersion VERSION_ENTITIES_PARTICLE_MODIFICATIONS = 39;
const PacketVersion VERSION_ENTITIES_POLYVOX_NEIGHBORS = 40;
#endif // hifi_PacketHeaders_h
#endif // hifi_PacketHeaders_h

View file

@ -243,7 +243,7 @@ void AmbientOcclusion::run(const render::SceneContextPointer& sceneContext, cons
batch._glUniform2f(_depthTexCoordScaleLoc, depthTexCoordScaleS, depthTexCoordScaleT);
batch._glUniform2f(_renderTargetResLoc, fbWidth, fbHeight);
batch._glUniform2f(_renderTargetResInvLoc, 1.0/fbWidth, 1.0/fbHeight);
batch._glUniform2f(_renderTargetResInvLoc, 1.0f / fbWidth, 1.0f / fbHeight);
glm::vec4 color(0.0f, 0.0f, 0.0f, 1.0f);
glm::vec2 bottomLeft(-1.0f, -1.0f);

View file

@ -372,20 +372,20 @@ QRectF glmToRect(const glm::vec2 & pos, const glm::vec2 & size) {
// create matrix from orientation and position
glm::mat4 createMatFromQuatAndPos(const glm::quat& q, const glm::vec3& p) {
glm::mat4 m = glm::mat4_cast(q);
m[3] = glm::vec4(p, 1);
m[3] = glm::vec4(p, 1.0f);
return m;
}
// cancel out roll and pitch
glm::quat cancelOutRollAndPitch(const glm::quat& q) {
glm::vec3 zAxis = q * glm::vec3(0, 0, 1);
glm::vec3 zAxis = q * glm::vec3(0.0f, 0.0f, 1.0f);
// cancel out the roll and pitch
glm::vec3 newZ = (zAxis.x == 0 && zAxis.z == 0) ? vec3(1, 0, 0) : glm::normalize(vec3(zAxis.x, 0, zAxis.z));
glm::vec3 newX = glm::cross(vec3(0, 1, 0), newZ);
glm::vec3 newZ = (zAxis.x == 0 && zAxis.z == 0.0f) ? vec3(1.0f, 0.0f, 0.0f) : glm::normalize(vec3(zAxis.x, 0.0f, zAxis.z));
glm::vec3 newX = glm::cross(vec3(0.0f, 1.0f, 0.0f), newZ);
glm::vec3 newY = glm::cross(newZ, newX);
glm::mat4 temp(glm::vec4(newX, 0), glm::vec4(newY, 0), glm::vec4(newZ, 0), glm::vec4(0, 0, 0, 1));
glm::mat4 temp(glm::vec4(newX, 0.0f), glm::vec4(newY, 0.0f), glm::vec4(newZ, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
return glm::quat_cast(temp);
}
@ -394,15 +394,15 @@ glm::mat4 cancelOutRollAndPitch(const glm::mat4& m) {
glm::vec3 zAxis = glm::vec3(m[2]);
// cancel out the roll and pitch
glm::vec3 newZ = (zAxis.x == 0 && zAxis.z == 0) ? vec3(1, 0, 0) : glm::normalize(vec3(zAxis.x, 0, zAxis.z));
glm::vec3 newX = glm::cross(vec3(0, 1, 0), newZ);
glm::vec3 newZ = (zAxis.x == 0.0f && zAxis.z == 0.0f) ? vec3(1.0f, 0.0f, 0.0f) : glm::normalize(vec3(zAxis.x, 0.0f, zAxis.z));
glm::vec3 newX = glm::cross(vec3(0.0f, 1.0f, 0.0f), newZ);
glm::vec3 newY = glm::cross(newZ, newX);
glm::mat4 temp(glm::vec4(newX, 0), glm::vec4(newY, 0), glm::vec4(newZ, 0), m[3]);
glm::mat4 temp(glm::vec4(newX, 0.0f), glm::vec4(newY, 0.0f), glm::vec4(newZ, 0.0f), m[3]);
return temp;
}
glm::vec3 transformPoint(const glm::mat4& m, const glm::vec3& p) {
glm::vec4 temp = m * glm::vec4(p, 1);
glm::vec4 temp = m * glm::vec4(p, 1.0f);
return glm::vec3(temp.x / temp.w, temp.y / temp.w, temp.z / temp.w);
}

View file

@ -93,8 +93,8 @@ template <typename T>
void testByteCountCoded() {
testByteCountCodedStable<T>(0);
testByteCountCodedStable<T>(1);
testByteCountCodedStable<T>(1 << 16);
testByteCountCodedStable<T>(std::numeric_limits<T>::max() >> 16);
testByteCountCodedStable<T>(1 << 8*sizeof(T));
testByteCountCodedStable<T>(std::numeric_limits<T>::max() >> 8*sizeof(T));
testByteCountCodedStable<T>(std::numeric_limits<T>::max() >> 8);
testByteCountCodedStable<T>(std::numeric_limits<T>::max() >> 1);
testByteCountCodedStable<T>(std::numeric_limits<T>::max());

View file

@ -342,8 +342,8 @@ public:
glm::vec3 unitscale { 1.0f };
glm::vec3 up { 0.0f, 1.0f, 0.0f };
glm::vec3 cam_pos { 1.5f * sin(t), 0.0f, 2.0f };
// glm::vec3 camera_focus { 5.0f * cos(t * 0.1f), 0.0f, 0.0f };
glm::vec3 cam_pos { 1.5f * sinf(t), 0.0f, 2.0f };
// glm::vec3 camera_focus { 5.0f * cosf(t * 0.1f), 0.0f, 0.0f };
glm::vec3 camera_focus { 0.0f, 0.0f, 0.0f };
glm::quat cam_rotation;
// glm::quat cam_rotation = glm::quat_cast(glm::lookAt(cam_pos, camera_focus, up));