summaryrefslogtreecommitdiff
path: root/indra/newview/gltfscenemanager.cpp
diff options
context:
space:
mode:
authorRunitaiLinden <davep@lindenlab.com>2024-05-01 09:51:32 -0500
committerRunitaiLinden <davep@lindenlab.com>2024-05-01 09:51:32 -0500
commita701cce8e0959503156a010683f6d0d57beaae36 (patch)
treec9a3850ea63474f83fe2150fb71fb798ad71d001 /indra/newview/gltfscenemanager.cpp
parent170765fd3505410dced83b342f87030fd9151e35 (diff)
#1357 Preserve asset "extras" and switch to std::shared_ptr for referencing Asset from LLViewerObject to cut down rebuild time
Diffstat (limited to 'indra/newview/gltfscenemanager.cpp')
-rw-r--r--indra/newview/gltfscenemanager.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp
index 0aedcd653d..6533f283e2 100644
--- a/indra/newview/gltfscenemanager.cpp
+++ b/indra/newview/gltfscenemanager.cpp
@@ -77,7 +77,7 @@ void GLTFSceneManager::load()
void GLTFSceneManager::saveAs()
{
LLViewerObject* obj = LLSelectMgr::instance().getSelection()->getFirstRootObject();
- if (obj && obj->mGLTFAsset.notNull())
+ if (obj && obj->mGLTFAsset)
{
LLFilePickerReplyThread::startPicker(
[](const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter load_filter, LLFilePicker::ESaveFilter save_filter)
@@ -103,7 +103,7 @@ void GLTFSceneManager::saveAs()
void GLTFSceneManager::decomposeSelection()
{
LLViewerObject* obj = LLSelectMgr::instance().getSelection()->getFirstRootObject();
- if (obj && obj->mGLTFAsset.notNull())
+ if (obj && obj->mGLTFAsset)
{
LLFilePickerReplyThread::startPicker(
[](const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter load_filter, LLFilePicker::ESaveFilter save_filter)
@@ -129,7 +129,7 @@ void GLTFSceneManager::decomposeSelection()
void GLTFSceneManager::decomposeSelection(const std::string& filename)
{
LLViewerObject* obj = LLSelectMgr::instance().getSelection()->getFirstRootObject();
- if (obj && obj->mGLTFAsset.notNull())
+ if (obj && obj->mGLTFAsset)
{
// copy asset out for decomposition
Asset asset = *obj->mGLTFAsset;
@@ -148,9 +148,9 @@ void GLTFSceneManager::decomposeSelection(const std::string& filename)
void GLTFSceneManager::save(const std::string& filename)
{
LLViewerObject* obj = LLSelectMgr::instance().getSelection()->getFirstRootObject();
- if (obj && obj->mGLTFAsset.notNull())
+ if (obj && obj->mGLTFAsset)
{
- Asset* asset = obj->mGLTFAsset;
+ Asset* asset = obj->mGLTFAsset.get();
tinygltf::Model model;
asset->save(model);
@@ -163,7 +163,7 @@ void GLTFSceneManager::load(const std::string& filename)
tinygltf::Model model;
LLTinyGLTFHelper::loadModel(filename, model);
- LLPointer<Asset> asset = new Asset();
+ std::shared_ptr<Asset> asset = std::make_shared<Asset>();
*asset = model;
gDebugProgram.bind(); // bind a shader to satisfy LLVertexBuffer assertions
@@ -210,10 +210,7 @@ void GLTFSceneManager::update()
continue;
}
- Asset* asset = mObjects[i]->mGLTFAsset;
-
- asset->update();
-
+ mObjects[i]->mGLTFAsset->update();
}
}
@@ -235,7 +232,7 @@ void GLTFSceneManager::render(bool opaque, bool rigged)
continue;
}
- Asset* asset = mObjects[i]->mGLTFAsset;
+ Asset* asset = mObjects[i]->mGLTFAsset.get();
gGL.pushMatrix();
@@ -382,7 +379,7 @@ LLDrawable* GLTFSceneManager::lineSegmentIntersect(const LLVector4a& start, cons
}
// temporary debug -- always double check objects that have GLTF scenes hanging off of them even if the ray doesn't intersect the object bounds
- if (lineSegmentIntersect((LLVOVolume*) mObjects[i].get(), mObjects[i]->mGLTFAsset, start, local_end, -1, pick_transparent, pick_rigged, pick_unselectable, node_hit, primitive_hit, &position, tex_coord, normal, tangent))
+ if (lineSegmentIntersect((LLVOVolume*) mObjects[i].get(), mObjects[i]->mGLTFAsset.get(), start, local_end, -1, pick_transparent, pick_rigged, pick_unselectable, node_hit, primitive_hit, &position, tex_coord, normal, tangent))
{
local_end = position;
if (intersection)
@@ -509,7 +506,7 @@ void GLTFSceneManager::renderDebug()
matMul(mat, modelview, modelview);
- Asset* asset = obj->mGLTFAsset;
+ Asset* asset = obj->mGLTFAsset.get();
for (auto& node : asset->mNodes)
{
@@ -524,7 +521,7 @@ void GLTFSceneManager::renderDebug()
continue;
}
- Asset* asset = obj->mGLTFAsset;
+ Asset* asset = obj->mGLTFAsset.get();
LLMatrix4a mat = obj->getGLTFAssetToAgentTransform();
@@ -561,7 +558,7 @@ void GLTFSceneManager::renderDebug()
matMul(mat, modelview, modelview);
- Asset* asset = obj->mGLTFAsset;
+ Asset* asset = obj->mGLTFAsset.get();
for (auto& node : asset->mNodes)
{
@@ -622,7 +619,7 @@ void GLTFSceneManager::renderDebug()
if (drawable)
{
gGL.pushMatrix();
- Asset* asset = drawable->getVObj()->mGLTFAsset;
+ Asset* asset = drawable->getVObj()->mGLTFAsset.get();
Node* node = &asset->mNodes[node_hit];
Primitive* primitive = &asset->mMeshes[node->mMesh].mPrimitives[primitive_hit];