mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
move modelScale before translation and rotation since that seems to fix the corruption
This commit is contained in:
parent
305e34e834
commit
a35e5eeb92
2 changed files with 59 additions and 58 deletions
|
@ -190,6 +190,12 @@ bool Particle::appendParticleData(OctreePacketData* packetData) const {
|
||||||
success = packetData->appendRawData((const unsigned char*)qPrintable(_modelURL), modelURLLength);
|
success = packetData->appendRawData((const unsigned char*)qPrintable(_modelURL), modelURLLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modelScale
|
||||||
|
if (success) {
|
||||||
|
success = packetData->appendValue(getModelScale());
|
||||||
|
}
|
||||||
|
|
||||||
// modelTranslation
|
// modelTranslation
|
||||||
if (success) {
|
if (success) {
|
||||||
success = packetData->appendValue(getModelTranslation());
|
success = packetData->appendValue(getModelTranslation());
|
||||||
|
@ -198,11 +204,6 @@ bool Particle::appendParticleData(OctreePacketData* packetData) const {
|
||||||
if (success) {
|
if (success) {
|
||||||
success = packetData->appendValue(getModelRotation());
|
success = packetData->appendValue(getModelRotation());
|
||||||
}
|
}
|
||||||
// modelScale
|
|
||||||
if (success) {
|
|
||||||
success = packetData->appendValue(getModelScale());
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,6 +320,11 @@ int Particle::readParticleDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
dataAt += modelURLLength;
|
dataAt += modelURLLength;
|
||||||
bytesRead += modelURLLength;
|
bytesRead += modelURLLength;
|
||||||
|
|
||||||
|
// modelScale
|
||||||
|
memcpy(&_modelScale, dataAt, sizeof(_modelScale));
|
||||||
|
dataAt += sizeof(_modelScale);
|
||||||
|
bytesRead += sizeof(_modelScale);
|
||||||
|
|
||||||
// modelTranslation
|
// modelTranslation
|
||||||
memcpy(&_modelTranslation, dataAt, sizeof(_modelTranslation));
|
memcpy(&_modelTranslation, dataAt, sizeof(_modelTranslation));
|
||||||
dataAt += sizeof(_modelTranslation);
|
dataAt += sizeof(_modelTranslation);
|
||||||
|
@ -329,11 +335,6 @@ int Particle::readParticleDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
dataAt += bytes;
|
dataAt += bytes;
|
||||||
bytesRead += bytes;
|
bytesRead += bytes;
|
||||||
|
|
||||||
// modelScale
|
|
||||||
memcpy(&_modelScale, dataAt, sizeof(_modelScale));
|
|
||||||
dataAt += sizeof(_modelScale);
|
|
||||||
bytesRead += sizeof(_modelScale);
|
|
||||||
|
|
||||||
//printf("Particle::readParticleDataFromBuffer()... "); debugDump();
|
//printf("Particle::readParticleDataFromBuffer()... "); debugDump();
|
||||||
}
|
}
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
|
@ -498,6 +499,13 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
|
||||||
processedBytes += modelURLLength;
|
processedBytes += modelURLLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modelScale
|
||||||
|
if (isNewParticle || ((packetContainsBits & CONTAINS_MODEL_SCALE) == CONTAINS_MODEL_SCALE)) {
|
||||||
|
memcpy(&newParticle._modelScale, dataAt, sizeof(newParticle._modelScale));
|
||||||
|
dataAt += sizeof(newParticle._modelScale);
|
||||||
|
processedBytes += sizeof(newParticle._modelScale);
|
||||||
|
}
|
||||||
|
|
||||||
// modelTranslation
|
// modelTranslation
|
||||||
if (isNewParticle || ((packetContainsBits & CONTAINS_MODEL_TRANSLATION) == CONTAINS_MODEL_TRANSLATION)) {
|
if (isNewParticle || ((packetContainsBits & CONTAINS_MODEL_TRANSLATION) == CONTAINS_MODEL_TRANSLATION)) {
|
||||||
memcpy(&newParticle._modelTranslation, dataAt, sizeof(newParticle._modelTranslation));
|
memcpy(&newParticle._modelTranslation, dataAt, sizeof(newParticle._modelTranslation));
|
||||||
|
@ -512,13 +520,6 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
|
||||||
processedBytes += bytes;
|
processedBytes += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// modelScale
|
|
||||||
if (isNewParticle || ((packetContainsBits & CONTAINS_MODEL_SCALE) == CONTAINS_MODEL_SCALE)) {
|
|
||||||
memcpy(&newParticle._modelScale, dataAt, sizeof(newParticle._modelScale));
|
|
||||||
dataAt += sizeof(newParticle._modelScale);
|
|
||||||
processedBytes += sizeof(newParticle._modelScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool wantDebugging = false;
|
const bool wantDebugging = false;
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
qDebug("Particle::fromEditPacket()...");
|
qDebug("Particle::fromEditPacket()...");
|
||||||
|
@ -696,6 +697,14 @@ bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID i
|
||||||
sizeOut += urlLength;
|
sizeOut += urlLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modelScale
|
||||||
|
if (isNewParticle || ((packetContainsBits & CONTAINS_MODEL_SCALE) == CONTAINS_MODEL_SCALE)) {
|
||||||
|
float modelScale = properties.getModelScale();
|
||||||
|
memcpy(copyAt, &modelScale, sizeof(modelScale));
|
||||||
|
copyAt += sizeof(modelScale);
|
||||||
|
sizeOut += sizeof(modelScale);
|
||||||
|
}
|
||||||
|
|
||||||
// modelTranslation
|
// modelTranslation
|
||||||
if (isNewParticle || ((packetContainsBits & CONTAINS_MODEL_TRANSLATION) == CONTAINS_MODEL_TRANSLATION)) {
|
if (isNewParticle || ((packetContainsBits & CONTAINS_MODEL_TRANSLATION) == CONTAINS_MODEL_TRANSLATION)) {
|
||||||
glm::vec3 modelTranslation = properties.getModelTranslation(); // should this be relative to TREE_SCALE??
|
glm::vec3 modelTranslation = properties.getModelTranslation(); // should this be relative to TREE_SCALE??
|
||||||
|
@ -711,14 +720,6 @@ bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID i
|
||||||
sizeOut += bytes;
|
sizeOut += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// modelScale
|
|
||||||
if (isNewParticle || ((packetContainsBits & CONTAINS_MODEL_SCALE) == CONTAINS_MODEL_SCALE)) {
|
|
||||||
float modelScale = properties.getModelScale();
|
|
||||||
memcpy(copyAt, &modelScale, sizeof(modelScale));
|
|
||||||
copyAt += sizeof(modelScale);
|
|
||||||
sizeOut += sizeof(modelScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wantDebugging = false;
|
bool wantDebugging = false;
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
printf("encodeParticleEditMessageDetails()....\n");
|
printf("encodeParticleEditMessageDetails()....\n");
|
||||||
|
@ -931,9 +932,9 @@ ParticleProperties::ParticleProperties() :
|
||||||
_inHand(false),
|
_inHand(false),
|
||||||
_shouldDie(false),
|
_shouldDie(false),
|
||||||
_modelURL(""),
|
_modelURL(""),
|
||||||
|
_modelScale(DEFAULT_MODEL_SCALE),
|
||||||
_modelTranslation(DEFAULT_MODEL_TRANSLATION),
|
_modelTranslation(DEFAULT_MODEL_TRANSLATION),
|
||||||
_modelRotation(DEFAULT_MODEL_ROTATION),
|
_modelRotation(DEFAULT_MODEL_ROTATION),
|
||||||
_modelScale(DEFAULT_MODEL_SCALE),
|
|
||||||
|
|
||||||
_id(UNKNOWN_PARTICLE_ID),
|
_id(UNKNOWN_PARTICLE_ID),
|
||||||
_idSet(false),
|
_idSet(false),
|
||||||
|
@ -950,9 +951,9 @@ ParticleProperties::ParticleProperties() :
|
||||||
_inHandChanged(false),
|
_inHandChanged(false),
|
||||||
_shouldDieChanged(false),
|
_shouldDieChanged(false),
|
||||||
_modelURLChanged(false),
|
_modelURLChanged(false),
|
||||||
|
_modelScaleChanged(false),
|
||||||
_modelTranslationChanged(false),
|
_modelTranslationChanged(false),
|
||||||
_modelRotationChanged(false),
|
_modelRotationChanged(false),
|
||||||
_modelScaleChanged(false),
|
|
||||||
_defaultSettings(true)
|
_defaultSettings(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1004,6 +1005,10 @@ uint16_t ParticleProperties::getChangedBits() const {
|
||||||
changedBits += CONTAINS_MODEL_URL;
|
changedBits += CONTAINS_MODEL_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_modelScaleChanged) {
|
||||||
|
changedBits += CONTAINS_MODEL_SCALE;
|
||||||
|
}
|
||||||
|
|
||||||
if (_modelTranslationChanged) {
|
if (_modelTranslationChanged) {
|
||||||
changedBits += CONTAINS_MODEL_TRANSLATION;
|
changedBits += CONTAINS_MODEL_TRANSLATION;
|
||||||
}
|
}
|
||||||
|
@ -1012,10 +1017,6 @@ uint16_t ParticleProperties::getChangedBits() const {
|
||||||
changedBits += CONTAINS_MODEL_ROTATION;
|
changedBits += CONTAINS_MODEL_ROTATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_modelScaleChanged) {
|
|
||||||
changedBits += CONTAINS_MODEL_SCALE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return changedBits;
|
return changedBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,14 +1046,14 @@ QScriptValue ParticleProperties::copyToScriptValue(QScriptEngine* engine) const
|
||||||
|
|
||||||
properties.setProperty("modelURL", _modelURL);
|
properties.setProperty("modelURL", _modelURL);
|
||||||
|
|
||||||
|
properties.setProperty("modelScale", _modelScale);
|
||||||
|
|
||||||
QScriptValue modelTranslation = vec3toScriptValue(engine, _modelTranslation);
|
QScriptValue modelTranslation = vec3toScriptValue(engine, _modelTranslation);
|
||||||
properties.setProperty("modelTranslation", modelTranslation);
|
properties.setProperty("modelTranslation", modelTranslation);
|
||||||
|
|
||||||
QScriptValue modelRotation = quatToScriptValue(engine, _modelRotation);
|
QScriptValue modelRotation = quatToScriptValue(engine, _modelRotation);
|
||||||
properties.setProperty("modelRotation", modelRotation);
|
properties.setProperty("modelRotation", modelRotation);
|
||||||
|
|
||||||
properties.setProperty("modelScale", _modelScale);
|
|
||||||
|
|
||||||
|
|
||||||
if (_idSet) {
|
if (_idSet) {
|
||||||
properties.setProperty("id", _id);
|
properties.setProperty("id", _id);
|
||||||
|
@ -1203,7 +1204,17 @@ void ParticleProperties::copyFromScriptValue(const QScriptValue &object) {
|
||||||
_modelURLChanged = true;
|
_modelURLChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScriptValue modelScale = object.property("modelScale");
|
||||||
|
if (modelScale.isValid()) {
|
||||||
|
float newModelScale;
|
||||||
|
newModelScale = modelScale.toVariant().toFloat();
|
||||||
|
if (_defaultSettings || newModelScale != _modelScale) {
|
||||||
|
_modelScale = newModelScale;
|
||||||
|
_modelScaleChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QScriptValue modelTranslation = object.property("modelTranslation");
|
QScriptValue modelTranslation = object.property("modelTranslation");
|
||||||
if (modelTranslation.isValid()) {
|
if (modelTranslation.isValid()) {
|
||||||
QScriptValue x = modelTranslation.property("x");
|
QScriptValue x = modelTranslation.property("x");
|
||||||
|
@ -1241,16 +1252,6 @@ void ParticleProperties::copyFromScriptValue(const QScriptValue &object) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue modelScale = object.property("modelScale");
|
|
||||||
if (modelScale.isValid()) {
|
|
||||||
float newModelScale;
|
|
||||||
newModelScale = modelScale.toVariant().toFloat();
|
|
||||||
if (_defaultSettings || newModelScale != _modelScale) {
|
|
||||||
_modelScale = newModelScale;
|
|
||||||
_modelScaleChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_lastEdited = usecTimestampNow();
|
_lastEdited = usecTimestampNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,6 +1311,11 @@ void ParticleProperties::copyToParticle(Particle& particle) const {
|
||||||
particle.setModelURL(_modelURL);
|
particle.setModelURL(_modelURL);
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_modelScaleChanged) {
|
||||||
|
particle.setModelScale(_modelScale);
|
||||||
|
somethingChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (_modelTranslationChanged) {
|
if (_modelTranslationChanged) {
|
||||||
particle.setModelTranslation(_modelTranslation);
|
particle.setModelTranslation(_modelTranslation);
|
||||||
|
@ -1321,11 +1327,6 @@ void ParticleProperties::copyToParticle(Particle& particle) const {
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_modelScaleChanged) {
|
|
||||||
particle.setModelScale(_modelScale);
|
|
||||||
somethingChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (somethingChanged) {
|
if (somethingChanged) {
|
||||||
bool wantDebug = false;
|
bool wantDebug = false;
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
|
@ -1350,9 +1351,9 @@ void ParticleProperties::copyFromParticle(const Particle& particle) {
|
||||||
_inHand = particle.getInHand();
|
_inHand = particle.getInHand();
|
||||||
_shouldDie = particle.getShouldDie();
|
_shouldDie = particle.getShouldDie();
|
||||||
_modelURL = particle.getModelURL();
|
_modelURL = particle.getModelURL();
|
||||||
|
_modelScale = particle.getModelScale();
|
||||||
_modelTranslation = particle.getModelTranslation();
|
_modelTranslation = particle.getModelTranslation();
|
||||||
_modelRotation = particle.getModelRotation();
|
_modelRotation = particle.getModelRotation();
|
||||||
_modelScale = particle.getModelScale();
|
|
||||||
|
|
||||||
_id = particle.getID();
|
_id = particle.getID();
|
||||||
_idSet = true;
|
_idSet = true;
|
||||||
|
@ -1368,9 +1369,9 @@ void ParticleProperties::copyFromParticle(const Particle& particle) {
|
||||||
_inHandChanged = false;
|
_inHandChanged = false;
|
||||||
_shouldDieChanged = false;
|
_shouldDieChanged = false;
|
||||||
_modelURLChanged = false;
|
_modelURLChanged = false;
|
||||||
|
_modelScaleChanged = false;
|
||||||
_modelTranslationChanged = false;
|
_modelTranslationChanged = false;
|
||||||
_modelRotationChanged = false;
|
_modelRotationChanged = false;
|
||||||
_modelScaleChanged = false;
|
|
||||||
_defaultSettings = false;
|
_defaultSettings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,9 +88,9 @@ public:
|
||||||
bool getInHand() const { return _inHand; }
|
bool getInHand() const { return _inHand; }
|
||||||
bool getShouldDie() const { return _shouldDie; }
|
bool getShouldDie() const { return _shouldDie; }
|
||||||
const QString& getModelURL() const { return _modelURL; }
|
const QString& getModelURL() const { return _modelURL; }
|
||||||
|
float getModelScale() const { return _modelScale; }
|
||||||
const glm::vec3& getModelTranslation() const { return _modelTranslation; }
|
const glm::vec3& getModelTranslation() const { return _modelTranslation; }
|
||||||
const glm::quat& getModelRotation() const { return _modelRotation; }
|
const glm::quat& getModelRotation() const { return _modelRotation; }
|
||||||
float getModelScale() const { return _modelScale; }
|
|
||||||
|
|
||||||
quint64 getLastEdited() const { return _lastEdited; }
|
quint64 getLastEdited() const { return _lastEdited; }
|
||||||
uint16_t getChangedBits() const;
|
uint16_t getChangedBits() const;
|
||||||
|
@ -113,10 +113,10 @@ public:
|
||||||
|
|
||||||
// model related properties
|
// model related properties
|
||||||
void setModelURL(const QString& url) { _modelURL = url; _modelURLChanged = true; }
|
void setModelURL(const QString& url) { _modelURL = url; _modelURLChanged = true; }
|
||||||
|
void setModelScale(float scale) { _modelScale = scale; _modelScaleChanged = true; }
|
||||||
void setModelTranslation(const glm::vec3& translation) { _modelTranslation = translation;
|
void setModelTranslation(const glm::vec3& translation) { _modelTranslation = translation;
|
||||||
_modelTranslationChanged = true; }
|
_modelTranslationChanged = true; }
|
||||||
void setModelRotation(const glm::quat& rotation) { _modelRotation = rotation; _modelRotationChanged = true; }
|
void setModelRotation(const glm::quat& rotation) { _modelRotation = rotation; _modelRotationChanged = true; }
|
||||||
void setModelScale(float scale) { _modelScale = scale; _modelScaleChanged = true; }
|
|
||||||
|
|
||||||
/// used by ParticleScriptingInterface to return ParticleProperties for unknown particles
|
/// used by ParticleScriptingInterface to return ParticleProperties for unknown particles
|
||||||
void setIsUnknownID() { _id = UNKNOWN_PARTICLE_ID; _idSet = true; }
|
void setIsUnknownID() { _id = UNKNOWN_PARTICLE_ID; _idSet = true; }
|
||||||
|
@ -133,9 +133,9 @@ private:
|
||||||
bool _inHand;
|
bool _inHand;
|
||||||
bool _shouldDie;
|
bool _shouldDie;
|
||||||
QString _modelURL;
|
QString _modelURL;
|
||||||
|
float _modelScale;
|
||||||
glm::vec3 _modelTranslation;
|
glm::vec3 _modelTranslation;
|
||||||
glm::quat _modelRotation;
|
glm::quat _modelRotation;
|
||||||
float _modelScale;
|
|
||||||
|
|
||||||
uint32_t _id;
|
uint32_t _id;
|
||||||
bool _idSet;
|
bool _idSet;
|
||||||
|
@ -152,9 +152,9 @@ private:
|
||||||
bool _inHandChanged;
|
bool _inHandChanged;
|
||||||
bool _shouldDieChanged;
|
bool _shouldDieChanged;
|
||||||
bool _modelURLChanged;
|
bool _modelURLChanged;
|
||||||
|
bool _modelScaleChanged;
|
||||||
bool _modelTranslationChanged;
|
bool _modelTranslationChanged;
|
||||||
bool _modelRotationChanged;
|
bool _modelRotationChanged;
|
||||||
bool _modelScaleChanged;
|
|
||||||
bool _defaultSettings;
|
bool _defaultSettings;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(ParticleProperties);
|
Q_DECLARE_METATYPE(ParticleProperties);
|
||||||
|
@ -227,9 +227,9 @@ public:
|
||||||
// model related properties
|
// model related properties
|
||||||
bool hasModel() const { return !_modelURL.isEmpty(); }
|
bool hasModel() const { return !_modelURL.isEmpty(); }
|
||||||
const QString& getModelURL() const { return _modelURL; }
|
const QString& getModelURL() const { return _modelURL; }
|
||||||
|
float getModelScale() const { return _modelScale; }
|
||||||
const glm::vec3& getModelTranslation() const { return _modelTranslation; }
|
const glm::vec3& getModelTranslation() const { return _modelTranslation; }
|
||||||
const glm::quat& getModelRotation() const { return _modelRotation; }
|
const glm::quat& getModelRotation() const { return _modelRotation; }
|
||||||
float getModelScale() const { return _modelScale; }
|
|
||||||
|
|
||||||
ParticleID getParticleID() const { return ParticleID(getID(), getCreatorTokenID(), getID() != UNKNOWN_PARTICLE_ID); }
|
ParticleID getParticleID() const { return ParticleID(getID(), getCreatorTokenID(), getID() != UNKNOWN_PARTICLE_ID); }
|
||||||
ParticleProperties getProperties() const;
|
ParticleProperties getProperties() const;
|
||||||
|
@ -277,9 +277,9 @@ public:
|
||||||
|
|
||||||
// model related properties
|
// model related properties
|
||||||
void setModelURL(const QString& url) { _modelURL = url; }
|
void setModelURL(const QString& url) { _modelURL = url; }
|
||||||
|
void setModelScale(float scale) { _modelScale = scale; }
|
||||||
void setModelTranslation(const glm::vec3& translation) { _modelTranslation = translation; }
|
void setModelTranslation(const glm::vec3& translation) { _modelTranslation = translation; }
|
||||||
void setModelRotation(const glm::quat& rotation) { _modelRotation = rotation; }
|
void setModelRotation(const glm::quat& rotation) { _modelRotation = rotation; }
|
||||||
void setModelScale(float scale) { _modelScale = scale; }
|
|
||||||
|
|
||||||
void setProperties(const ParticleProperties& properties);
|
void setProperties(const ParticleProperties& properties);
|
||||||
|
|
||||||
|
@ -344,9 +344,9 @@ protected:
|
||||||
|
|
||||||
// model related items
|
// model related items
|
||||||
QString _modelURL;
|
QString _modelURL;
|
||||||
|
float _modelScale;
|
||||||
glm::vec3 _modelTranslation;
|
glm::vec3 _modelTranslation;
|
||||||
glm::quat _modelRotation;
|
glm::quat _modelRotation;
|
||||||
float _modelScale;
|
|
||||||
|
|
||||||
uint32_t _creatorTokenID;
|
uint32_t _creatorTokenID;
|
||||||
bool _newlyCreated;
|
bool _newlyCreated;
|
||||||
|
|
Loading…
Reference in a new issue