mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:49:12 +02:00
bump shape stuff from ModelEntityItem down to RenderableModelEntityItem
This commit is contained in:
parent
3a126d4840
commit
f9be7dda36
5 changed files with 59 additions and 63 deletions
|
@ -266,4 +266,53 @@ bool RenderableModelEntityItem::findDetailedRayIntersection(const glm::vec3& ori
|
||||||
return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, extraInfo, precisionPicking);
|
return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, extraInfo, precisionPicking);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RenderableModelEntityItem::isReadyToComputeShape() {
|
||||||
|
if (_collisionModelURL == "") {
|
||||||
|
// no model url, so we're ready to compute a shape.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! _collisionNetworkGeometry.isNull() && _collisionNetworkGeometry->isLoadedWithTextures()) {
|
||||||
|
// we have a _collisionModelURL AND a _collisionNetworkGeometry AND it's fully loaded.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_collisionNetworkGeometry.isNull()) {
|
||||||
|
// we have a _collisionModelURL but we don't yet have a _collisionNetworkGeometry.
|
||||||
|
_collisionNetworkGeometry =
|
||||||
|
DependencyManager::get<GeometryCache>()->getGeometry(_collisionModelURL, QUrl(), false, false);
|
||||||
|
|
||||||
|
if (! _collisionNetworkGeometry.isNull() && _collisionNetworkGeometry->isLoadedWithTextures()) {
|
||||||
|
// shortcut in case it's already loaded.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the model is still being downloaded.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
|
if (_collisionModelURL == "") {
|
||||||
|
info.setParams(getShapeType(), 0.5f * getDimensions());
|
||||||
|
} else {
|
||||||
|
const FBXGeometry& fbxGeometry = _collisionNetworkGeometry->getFBXGeometry();
|
||||||
|
|
||||||
|
_points.clear();
|
||||||
|
foreach (const FBXMesh& mesh, fbxGeometry.meshes) {
|
||||||
|
_points << mesh.vertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
info.setParams(getShapeType(), 0.5f * getDimensions(), NULL, _collisionModelURL);
|
||||||
|
info.setConvexHull(_points);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShapeType RenderableModelEntityItem::getShapeType() const {
|
||||||
|
// XXX make hull an option in edit.js ?
|
||||||
|
if (_collisionModelURL != "") {
|
||||||
|
return SHAPE_TYPE_CONVEX_HULL;
|
||||||
|
} else {
|
||||||
|
return _shapeType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@ public:
|
||||||
_needsInitialSimulation(true),
|
_needsInitialSimulation(true),
|
||||||
_needsModelReload(true),
|
_needsModelReload(true),
|
||||||
_myRenderer(NULL),
|
_myRenderer(NULL),
|
||||||
_originalTexturesRead(false) { }
|
_originalTexturesRead(false),
|
||||||
|
_collisionNetworkGeometry(QSharedPointer<NetworkGeometry>()) { }
|
||||||
|
|
||||||
virtual ~RenderableModelEntityItem();
|
virtual ~RenderableModelEntityItem();
|
||||||
|
|
||||||
|
@ -52,6 +53,10 @@ public:
|
||||||
|
|
||||||
bool needsToCallUpdate() const;
|
bool needsToCallUpdate() const;
|
||||||
|
|
||||||
|
bool isReadyToComputeShape();
|
||||||
|
void computeShapeInfo(ShapeInfo& info);
|
||||||
|
ShapeType getShapeType() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void remapTextures();
|
void remapTextures();
|
||||||
|
|
||||||
|
@ -62,6 +67,9 @@ private:
|
||||||
QString _currentTextures;
|
QString _currentTextures;
|
||||||
QStringList _originalTextures;
|
QStringList _originalTextures;
|
||||||
bool _originalTexturesRead;
|
bool _originalTexturesRead;
|
||||||
|
|
||||||
|
QSharedPointer<NetworkGeometry> _collisionNetworkGeometry;
|
||||||
|
QVector<glm::vec3> _points;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_RenderableModelEntityItem_h
|
#endif // hifi_RenderableModelEntityItem_h
|
||||||
|
|
|
@ -13,4 +13,4 @@ find_package(Bullet REQUIRED)
|
||||||
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS})
|
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS})
|
||||||
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})
|
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})
|
||||||
|
|
||||||
link_hifi_libraries(avatars shared octree gpu model fbx networking animation render-utils)
|
link_hifi_libraries(avatars shared octree gpu model fbx networking animation)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "EntityTree.h"
|
#include "EntityTree.h"
|
||||||
#include "EntityTreeElement.h"
|
#include "EntityTreeElement.h"
|
||||||
#include "ModelEntityItem.h"
|
#include "ModelEntityItem.h"
|
||||||
#include "GeometryCache.h"
|
|
||||||
#include "ResourceCache.h"
|
#include "ResourceCache.h"
|
||||||
|
|
||||||
const QString ModelEntityItem::DEFAULT_MODEL_URL = QString("");
|
const QString ModelEntityItem::DEFAULT_MODEL_URL = QString("");
|
||||||
|
@ -35,8 +34,6 @@ EntityItem* ModelEntityItem::factory(const EntityItemID& entityID, const EntityI
|
||||||
ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||||
EntityItem(entityItemID, properties)
|
EntityItem(entityItemID, properties)
|
||||||
{
|
{
|
||||||
_collisionNetworkGeometry = QSharedPointer<NetworkGeometry>();
|
|
||||||
|
|
||||||
_type = EntityTypes::Model;
|
_type = EntityTypes::Model;
|
||||||
setProperties(properties);
|
setProperties(properties);
|
||||||
_lastAnimated = usecTimestampNow();
|
_lastAnimated = usecTimestampNow();
|
||||||
|
@ -415,46 +412,3 @@ QString ModelEntityItem::getAnimationSettings() const {
|
||||||
QString jsonByteString(jsonByteArray);
|
QString jsonByteString(jsonByteArray);
|
||||||
return jsonByteString;
|
return jsonByteString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ModelEntityItem::isReadyToComputeShape() {
|
|
||||||
if (_collisionModelURL == "") {
|
|
||||||
// no model url, so we're ready to compute a shape.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! _collisionNetworkGeometry.isNull() && _collisionNetworkGeometry->isLoadedWithTextures()) {
|
|
||||||
// we have a _collisionModelURL AND a _collisionNetworkGeometry AND it's fully loaded.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_collisionNetworkGeometry.isNull()) {
|
|
||||||
// we have a _collisionModelURL but we don't yet have a _collisionNetworkGeometry.
|
|
||||||
_collisionNetworkGeometry =
|
|
||||||
DependencyManager::get<GeometryCache>()->getGeometry(_collisionModelURL, QUrl(), false, false);
|
|
||||||
|
|
||||||
if (! _collisionNetworkGeometry.isNull() && _collisionNetworkGeometry->isLoadedWithTextures()) {
|
|
||||||
// shortcut in case it's already loaded.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// the model is still being downloaded.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
|
||||||
if (_collisionModelURL == "") {
|
|
||||||
info.setParams(getShapeType(), 0.5f * getDimensions());
|
|
||||||
} else {
|
|
||||||
const FBXGeometry& fbxGeometry = _collisionNetworkGeometry->getFBXGeometry();
|
|
||||||
|
|
||||||
_points.clear();
|
|
||||||
foreach (const FBXMesh& mesh, fbxGeometry.meshes) {
|
|
||||||
_points << mesh.vertices;
|
|
||||||
}
|
|
||||||
|
|
||||||
info.setParams(getShapeType(), 0.5f * getDimensions(), NULL, _collisionModelURL);
|
|
||||||
info.setConvexHull(_points);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -51,17 +51,7 @@ public:
|
||||||
virtual bool needsToCallUpdate() const;
|
virtual bool needsToCallUpdate() const;
|
||||||
virtual void debugDump() const;
|
virtual void debugDump() const;
|
||||||
|
|
||||||
virtual void computeShapeInfo(ShapeInfo& info);
|
|
||||||
|
|
||||||
void updateShapeType(ShapeType type);
|
void updateShapeType(ShapeType type);
|
||||||
virtual ShapeType getShapeType() const {
|
|
||||||
// XXX make hull an option in edit.js ?
|
|
||||||
if (_collisionModelURL != "") {
|
|
||||||
return SHAPE_TYPE_CONVEX_HULL;
|
|
||||||
} else {
|
|
||||||
return _shapeType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move these to subclasses, or other appropriate abstraction
|
// TODO: Move these to subclasses, or other appropriate abstraction
|
||||||
// getters/setters applicable to models and particles
|
// getters/setters applicable to models and particles
|
||||||
|
@ -132,8 +122,6 @@ public:
|
||||||
|
|
||||||
static void cleanupLoadedAnimations();
|
static void cleanupLoadedAnimations();
|
||||||
|
|
||||||
bool isReadyToComputeShape();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
bool isAnimatingSomething() const;
|
bool isAnimatingSomething() const;
|
||||||
|
@ -156,9 +144,6 @@ protected:
|
||||||
static Animation* getAnimation(const QString& url);
|
static Animation* getAnimation(const QString& url);
|
||||||
static QMap<QString, AnimationPointer> _loadedAnimations;
|
static QMap<QString, AnimationPointer> _loadedAnimations;
|
||||||
static AnimationCache _animationCache;
|
static AnimationCache _animationCache;
|
||||||
|
|
||||||
QSharedPointer<NetworkGeometry> _collisionNetworkGeometry;
|
|
||||||
QVector<glm::vec3> _points;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ModelEntityItem_h
|
#endif // hifi_ModelEntityItem_h
|
||||||
|
|
Loading…
Reference in a new issue