sam's CR feedback, more use of share_ptr<>

This commit is contained in:
ZappoMan 2015-05-26 09:41:51 -07:00
parent d1520c5502
commit 5f6978a517
4 changed files with 15 additions and 18 deletions

View file

@ -394,7 +394,7 @@ void EntityTreeRenderer::leaveAllEntities() {
} }
} }
void EntityTreeRenderer::applyZonePropertiesToScene(const ZoneEntityItem* zone) { void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityItem> zone) {
QSharedPointer<SceneScriptingInterface> scene = DependencyManager::get<SceneScriptingInterface>(); QSharedPointer<SceneScriptingInterface> scene = DependencyManager::get<SceneScriptingInterface>();
if (zone) { if (zone) {
if (!_hasPreviousZone) { if (!_hasPreviousZone) {
@ -498,7 +498,7 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
_tree->lockForRead(); _tree->lockForRead();
// Whenever you're in an intersection between zones, we will always choose the smallest zone. // Whenever you're in an intersection between zones, we will always choose the smallest zone.
_bestZone = NULL; _bestZone = NULL; // NOTE: Is this what we want?
_bestZoneVolume = std::numeric_limits<float>::max(); _bestZoneVolume = std::numeric_limits<float>::max();
_tree->recurseTreeWithOperation(renderOperation, &args); _tree->recurseTreeWithOperation(renderOperation, &args);
@ -538,8 +538,8 @@ const FBXGeometry* EntityTreeRenderer::getGeometryForEntity(EntityItemPointer en
const FBXGeometry* result = NULL; const FBXGeometry* result = NULL;
if (entityItem->getType() == EntityTypes::Model) { if (entityItem->getType() == EntityTypes::Model) {
const RenderableModelEntityItem* constModelEntityItem = dynamic_cast<const RenderableModelEntityItem*>(entityItem.get()); std::shared_ptr<RenderableModelEntityItem> modelEntityItem =
RenderableModelEntityItem* modelEntityItem = const_cast<RenderableModelEntityItem*>(constModelEntityItem); std::dynamic_pointer_cast<RenderableModelEntityItem>(entityItem);
assert(modelEntityItem); // we need this!!! assert(modelEntityItem); // we need this!!!
Model* model = modelEntityItem->getModel(this); Model* model = modelEntityItem->getModel(this);
if (model) { if (model) {
@ -552,8 +552,8 @@ const FBXGeometry* EntityTreeRenderer::getGeometryForEntity(EntityItemPointer en
const Model* EntityTreeRenderer::getModelForEntityItem(EntityItemPointer entityItem) { const Model* EntityTreeRenderer::getModelForEntityItem(EntityItemPointer entityItem) {
const Model* result = NULL; const Model* result = NULL;
if (entityItem->getType() == EntityTypes::Model) { if (entityItem->getType() == EntityTypes::Model) {
const RenderableModelEntityItem* constModelEntityItem = dynamic_cast<const RenderableModelEntityItem*>(entityItem.get()); std::shared_ptr<RenderableModelEntityItem> modelEntityItem =
RenderableModelEntityItem* modelEntityItem = const_cast<RenderableModelEntityItem*>(constModelEntityItem); std::dynamic_pointer_cast<RenderableModelEntityItem>(entityItem);
result = modelEntityItem->getModel(this); result = modelEntityItem->getModel(this);
} }
return result; return result;
@ -563,9 +563,9 @@ const FBXGeometry* EntityTreeRenderer::getCollisionGeometryForEntity(EntityItemP
const FBXGeometry* result = NULL; const FBXGeometry* result = NULL;
if (entityItem->getType() == EntityTypes::Model) { if (entityItem->getType() == EntityTypes::Model) {
const RenderableModelEntityItem* constModelEntityItem = dynamic_cast<const RenderableModelEntityItem*>(entityItem.get()); std::shared_ptr<RenderableModelEntityItem> modelEntityItem =
if (constModelEntityItem->hasCompoundShapeURL()) { std::dynamic_pointer_cast<RenderableModelEntityItem>(entityItem);
RenderableModelEntityItem* modelEntityItem = const_cast<RenderableModelEntityItem*>(constModelEntityItem); if (modelEntityItem->hasCompoundShapeURL()) {
Model* model = modelEntityItem->getModel(this); Model* model = modelEntityItem->getModel(this);
if (model) { if (model) {
const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = model->getCollisionGeometry(); const QSharedPointer<NetworkGeometry> collisionNetworkGeometry = model->getCollisionGeometry();
@ -680,17 +680,17 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
float entityVolumeEstimate = entityItem->getVolumeEstimate(); float entityVolumeEstimate = entityItem->getVolumeEstimate();
if (entityVolumeEstimate < _bestZoneVolume) { if (entityVolumeEstimate < _bestZoneVolume) {
_bestZoneVolume = entityVolumeEstimate; _bestZoneVolume = entityVolumeEstimate;
_bestZone = dynamic_cast<const ZoneEntityItem*>(entityItem.get()); _bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entityItem);
} else if (entityVolumeEstimate == _bestZoneVolume) { } else if (entityVolumeEstimate == _bestZoneVolume) {
if (!_bestZone) { if (!_bestZone) {
_bestZoneVolume = entityVolumeEstimate; _bestZoneVolume = entityVolumeEstimate;
_bestZone = dynamic_cast<const ZoneEntityItem*>(entityItem.get()); _bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entityItem);
} else { } else {
// in the case of the volume being equal, we will use the // in the case of the volume being equal, we will use the
// EntityItemID to deterministically pick one entity over the other // EntityItemID to deterministically pick one entity over the other
if (entityItem->getEntityItemID() < _bestZone->getEntityItemID()) { if (entityItem->getEntityItemID() < _bestZone->getEntityItemID()) {
_bestZoneVolume = entityVolumeEstimate; _bestZoneVolume = entityVolumeEstimate;
_bestZone = dynamic_cast<const ZoneEntityItem*>(entityItem.get()); _bestZone = std::dynamic_pointer_cast<ZoneEntityItem>(entityItem);
} }
} }
} }

View file

@ -125,7 +125,7 @@ protected:
virtual Octree* createTree() { return new EntityTree(true); } virtual Octree* createTree() { return new EntityTree(true); }
private: private:
void applyZonePropertiesToScene(const ZoneEntityItem* zone); void applyZonePropertiesToScene(std::shared_ptr<ZoneEntityItem> zone);
void renderElementProxy(EntityTreeElement* entityTreeElement, RenderArgs* args); void renderElementProxy(EntityTreeElement* entityTreeElement, RenderArgs* args);
void checkAndCallPreload(const EntityItemID& entityID); void checkAndCallPreload(const EntityItemID& entityID);
void checkAndCallUnload(const EntityItemID& entityID); void checkAndCallUnload(const EntityItemID& entityID);
@ -174,7 +174,8 @@ private:
QMultiMap<QUrl, EntityItemID> _waitingOnPreload; QMultiMap<QUrl, EntityItemID> _waitingOnPreload;
bool _hasPreviousZone = false; bool _hasPreviousZone = false;
const ZoneEntityItem* _bestZone; std::shared_ptr<ZoneEntityItem> _bestZone;
float _bestZoneVolume; float _bestZoneVolume;
glm::vec3 _previousKeyLightColor; glm::vec3 _previousKeyLightColor;

View file

@ -87,9 +87,6 @@ EntityItem::~EntityItem() {
assert(!_simulated); assert(!_simulated);
assert(!_element); assert(!_element);
assert(!_physicsInfo); assert(!_physicsInfo);
qDebug() << "EntityItem::~EntityItem()";
debugDump();
} }
EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& params) const { EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& params) const {

View file

@ -21,7 +21,6 @@
class EntityItem; class EntityItem;
typedef std::shared_ptr<EntityItem> EntityItemPointer; typedef std::shared_ptr<EntityItem> EntityItemPointer;
//typedef EntityItem* EntityItemPointer;
inline uint qHash(const EntityItemPointer& a, uint seed) { inline uint qHash(const EntityItemPointer& a, uint seed) {
return qHash(a.get(), seed); return qHash(a.get(), seed);