mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +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);
|
||||
}
|
||||
|
||||
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),
|
||||
_needsModelReload(true),
|
||||
_myRenderer(NULL),
|
||||
_originalTexturesRead(false) { }
|
||||
_originalTexturesRead(false),
|
||||
_collisionNetworkGeometry(QSharedPointer<NetworkGeometry>()) { }
|
||||
|
||||
virtual ~RenderableModelEntityItem();
|
||||
|
||||
|
@ -52,6 +53,10 @@ public:
|
|||
|
||||
bool needsToCallUpdate() const;
|
||||
|
||||
bool isReadyToComputeShape();
|
||||
void computeShapeInfo(ShapeInfo& info);
|
||||
ShapeType getShapeType() const;
|
||||
|
||||
private:
|
||||
void remapTextures();
|
||||
|
||||
|
@ -62,6 +67,9 @@ private:
|
|||
QString _currentTextures;
|
||||
QStringList _originalTextures;
|
||||
bool _originalTexturesRead;
|
||||
|
||||
QSharedPointer<NetworkGeometry> _collisionNetworkGeometry;
|
||||
QVector<glm::vec3> _points;
|
||||
};
|
||||
|
||||
#endif // hifi_RenderableModelEntityItem_h
|
||||
|
|
|
@ -13,4 +13,4 @@ find_package(Bullet REQUIRED)
|
|||
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS})
|
||||
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 "EntityTreeElement.h"
|
||||
#include "ModelEntityItem.h"
|
||||
#include "GeometryCache.h"
|
||||
#include "ResourceCache.h"
|
||||
|
||||
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) :
|
||||
EntityItem(entityItemID, properties)
|
||||
{
|
||||
_collisionNetworkGeometry = QSharedPointer<NetworkGeometry>();
|
||||
|
||||
_type = EntityTypes::Model;
|
||||
setProperties(properties);
|
||||
_lastAnimated = usecTimestampNow();
|
||||
|
@ -415,46 +412,3 @@ QString ModelEntityItem::getAnimationSettings() const {
|
|||
QString jsonByteString(jsonByteArray);
|
||||
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 void debugDump() const;
|
||||
|
||||
virtual void computeShapeInfo(ShapeInfo& info);
|
||||
|
||||
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
|
||||
// getters/setters applicable to models and particles
|
||||
|
@ -132,8 +122,6 @@ public:
|
|||
|
||||
static void cleanupLoadedAnimations();
|
||||
|
||||
bool isReadyToComputeShape();
|
||||
|
||||
protected:
|
||||
|
||||
bool isAnimatingSomething() const;
|
||||
|
@ -156,9 +144,6 @@ protected:
|
|||
static Animation* getAnimation(const QString& url);
|
||||
static QMap<QString, AnimationPointer> _loadedAnimations;
|
||||
static AnimationCache _animationCache;
|
||||
|
||||
QSharedPointer<NetworkGeometry> _collisionNetworkGeometry;
|
||||
QVector<glm::vec3> _points;
|
||||
};
|
||||
|
||||
#endif // hifi_ModelEntityItem_h
|
||||
|
|
Loading…
Reference in a new issue