History

Rescale models if necessary to have their largest dimension be 1m

Models are still rescaled beforehand if thought to be in cm.

David Rowe committed 9 years ago

Commit a63beed1 parent d2468b61 file · +24 −6Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+24−6
@@ -5815,13 +5815,31 @@ void Application::addAssetToWorldCheckModelSize() { · 5814 unmodified lines
5815 const glm::vec3 DEFAULT_DIMENSIONS = glm::vec3(0.1f, 0.1f, 0.1f);5815 const glm::vec3 DEFAULT_DIMENSIONS = glm::vec3(0.1f, 0.1f, 0.1f);
5816 if (dimensions != DEFAULT_DIMENSIONS) {5816 if (dimensions != DEFAULT_DIMENSIONS) {
5817 // Entity has been auto-resized; adjust dimensions if it seems too big.5817 // Entity has been auto-resized; adjust dimensions if it seems too big.
5818 EntityItemProperties properties;5818 auto isResized = false;
5819 const float RESCALE_THRESHOLD = 10.0f; // Resize entities larger than this as the FBX is likely in cm or mm.5819
5820 // Entities with a dimension large than 10m are likely modelled in cm so scale to 1%.
5821 const float RESCALE_THRESHOLD = 10.0f;
5820 if (dimensions.x > RESCALE_THRESHOLD || dimensions.y > RESCALE_THRESHOLD || dimensions.z > RESCALE_THRESHOLD) {5822 if (dimensions.x > RESCALE_THRESHOLD || dimensions.y > RESCALE_THRESHOLD || dimensions.z > RESCALE_THRESHOLD) {
5821 auto dimensionsResized = dimensions * 0.01f;5823 auto previousDimensions = dimensions;
5822 properties.setDimensions(dimensionsResized);5824 dimensions *= 0.01f;
5823 qInfo(interfaceapp) << "Asset" << name << "auto-resized from" << dimensions << " to "5825 qInfo(interfaceapp) << "Asset" << name << "auto-resized from" << previousDimensions << " to " << dimensions;
5824 << dimensionsResized;5826 isResized = true;
5827 }
5828
5829 // Scale model to have a maximum dimension of 1m
5830 const float MAXIMUM_DIMENSION = 1.0f;
5831 if (dimensions.x > MAXIMUM_DIMENSION || dimensions.y > MAXIMUM_DIMENSION || dimensions.z > MAXIMUM_DIMENSION) {
5832 auto previousDimensions = dimensions;
5833 auto scale = std::min(MAXIMUM_DIMENSION / dimensions.x, std::min(MAXIMUM_DIMENSION / dimensions.y,
5834 MAXIMUM_DIMENSION / dimensions.z));
5835 dimensions *= scale;
5836 qInfo(interfaceapp) << "Asset" << name << "auto-resized from" << previousDimensions << " to " << dimensions;
5837 isResized = true;
5838 }
5839
5840 EntityItemProperties properties;
5841 if (isResized) {
5842 properties.setDimensions(dimensions);
5825 } else {5843 } else {
5826 qInfo(interfaceapp) << "Asset" << name << "does not need to be auto-resized";5844 qInfo(interfaceapp) << "Asset" << name << "does not need to be auto-resized";
5827 }5845 }