mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
read old format files correctly
This commit is contained in:
parent
25d051090a
commit
e8c1cb7db8
3 changed files with 50 additions and 8 deletions
|
@ -244,8 +244,6 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
|
|||
glTranslatef(position.x, position.y, position.z);
|
||||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glm::vec3 positionToCenter = center - position;
|
||||
glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z);
|
||||
|
@ -257,6 +255,8 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg
|
|||
}
|
||||
|
||||
void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args) {
|
||||
bool wantDebug = false;
|
||||
|
||||
args->_elementsTouched++;
|
||||
// actually render it here...
|
||||
// we need to iterate the actual entityItems of the element
|
||||
|
@ -288,6 +288,21 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
|
|||
// TODO: some entity types (like lights) might want to be rendered even
|
||||
// when they are outside of the view frustum...
|
||||
float distance = distanceToCamera(entityBox.calcCenter(), *args->_viewFrustum);
|
||||
|
||||
if (wantDebug) {
|
||||
qDebug() << "------- renderElement() ----------";
|
||||
qDebug() << " type:" << EntityTypes::getEntityTypeName(entityItem->getType());
|
||||
if (entityItem->getType() == EntityTypes::Model) {
|
||||
ModelEntityItem* modelEntity = static_cast<ModelEntityItem*>(entityItem);
|
||||
qDebug() << " url:" << modelEntity->getModelURL();
|
||||
}
|
||||
qDebug() << " entityBox:" << entityBox;
|
||||
qDebug() << " dimensions:" << entityItem->getDimensionsInMeters() << "in meters";
|
||||
qDebug() << " largestDimension:" << entityBox.getLargestDimension() << "in meters";
|
||||
qDebug() << " shouldRender:" << shouldRenderEntity(entityBox.getLargestDimension(), distance);
|
||||
qDebug() << " in frustum:" << (args->_viewFrustum->boxInFrustum(entityBox) != ViewFrustum::OUTSIDE);
|
||||
}
|
||||
|
||||
if (shouldRenderEntity(entityBox.getLargestDimension(), distance) &&
|
||||
args->_viewFrustum->boxInFrustum(entityBox) != ViewFrustum::OUTSIDE) {
|
||||
|
||||
|
|
|
@ -206,6 +206,11 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
|||
|
||||
APPEND_ENTITY_PROPERTY(PROP_POSITION, appendPosition, getPosition());
|
||||
APPEND_ENTITY_PROPERTY(PROP_DIMENSIONS, appendValue, getDimensions()); // NOTE: PROP_RADIUS obsolete
|
||||
|
||||
if (wantDebug) {
|
||||
qDebug() << " APPEND_ENTITY_PROPERTY() PROP_DIMENSIONS:" << getDimensions();
|
||||
}
|
||||
|
||||
APPEND_ENTITY_PROPERTY(PROP_ROTATION, appendValue, getRotation());
|
||||
APPEND_ENTITY_PROPERTY(PROP_MASS, appendValue, getMass());
|
||||
APPEND_ENTITY_PROPERTY(PROP_VELOCITY, appendValue, getVelocity());
|
||||
|
@ -447,12 +452,25 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
dataAt += sizeof(fromBuffer);
|
||||
bytesRead += sizeof(fromBuffer);
|
||||
if (overwriteLocalData) {
|
||||
setRadiusInMeters(fromBuffer);
|
||||
setRadius(fromBuffer);
|
||||
}
|
||||
|
||||
if (wantDebug) {
|
||||
qDebug() << " readEntityDataFromBuffer() OLD FORMAT... found PROP_RADIUS";
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
READ_ENTITY_PROPERTY(PROP_DIMENSIONS, glm::vec3, _dimensions);
|
||||
if (wantDebug) {
|
||||
qDebug() << " readEntityDataFromBuffer() NEW FORMAT... look for PROP_DIMENSIONS";
|
||||
}
|
||||
}
|
||||
|
||||
if (wantDebug) {
|
||||
qDebug() << " readEntityDataFromBuffer() _dimensions:" << getDimensionsInMeters() << " in meters";
|
||||
}
|
||||
|
||||
READ_ENTITY_PROPERTY_QUAT(PROP_ROTATION, _rotation);
|
||||
READ_ENTITY_PROPERTY(PROP_MASS, float, _mass);
|
||||
READ_ENTITY_PROPERTY(PROP_VELOCITY, glm::vec3, _velocity);
|
||||
|
@ -465,6 +483,11 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, _angularDamping);
|
||||
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, _visible);
|
||||
|
||||
if (wantDebug) {
|
||||
qDebug() << " readEntityDataFromBuffer() _registrationPoint:" << _registrationPoint;
|
||||
qDebug() << " readEntityDataFromBuffer() _visible:" << _visible;
|
||||
}
|
||||
|
||||
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData);
|
||||
|
||||
}
|
||||
|
@ -855,6 +878,15 @@ void EntityItem::setRadius(float value) {
|
|||
float diameter = value * 2.0f;
|
||||
float maxDimension = sqrt((diameter * diameter) / 3.0f);
|
||||
_dimensions = glm::vec3(maxDimension, maxDimension, maxDimension);
|
||||
|
||||
bool wantDebug = false;
|
||||
if (wantDebug) {
|
||||
qDebug() << "EntityItem::setRadius()...";
|
||||
qDebug() << " radius:" << value;
|
||||
qDebug() << " diameter:" << diameter;
|
||||
qDebug() << " maxDimension:" << maxDimension;
|
||||
qDebug() << " _dimensions:" << _dimensions;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: get rid of all users of this function...
|
||||
|
|
|
@ -257,11 +257,6 @@ protected:
|
|||
|
||||
/// set radius in domain scale units (0.0 - 1.0) this will also reset dimensions to be equal for each axis
|
||||
void setRadius(float value);
|
||||
/// set radius in meter units (0.0 - TREE_SCALE), this will also reset dimensions to be equal for each axis
|
||||
void setRadiusInMeters(float value) {
|
||||
float valueInTreeUnits = value / (float) TREE_SCALE;
|
||||
setRadius(valueInTreeUnits);
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO: We need to get rid of these users of getRadius()... but for now, we'll make them friends
|
||||
|
|
Loading…
Reference in a new issue