#1357 Preserve asset "extras" and switch to std::shared_ptr for referencing Asset from LLViewerObject to cut down rebuild time
parent
170765fd35
commit
a701cce8e0
|
|
@ -34,8 +34,6 @@
|
|||
|
||||
using namespace LL::GLTF;
|
||||
|
||||
#pragma optimize("", off)
|
||||
|
||||
namespace LL
|
||||
{
|
||||
namespace GLTF
|
||||
|
|
@ -280,6 +278,7 @@ namespace LL
|
|||
dst.asset.version = src.mVersion;
|
||||
dst.asset.minVersion = src.mMinVersion;
|
||||
dst.asset.generator = "Linden Lab Experimental GLTF Export";
|
||||
dst.asset.extras = src.mExtras;
|
||||
|
||||
copy(src.mScenes, dst.scenes);
|
||||
copy(src.mNodes, dst.nodes);
|
||||
|
|
@ -739,9 +738,10 @@ const Asset& Asset::operator=(const tinygltf::Model& src)
|
|||
mMinVersion = src.asset.minVersion;
|
||||
mGenerator = src.asset.generator;
|
||||
mCopyright = src.asset.copyright;
|
||||
mExtras = src.asset.extras;
|
||||
|
||||
mDefaultScene = src.defaultScene;
|
||||
|
||||
|
||||
|
||||
mScenes.resize(src.scenes.size());
|
||||
for (U32 i = 0; i < src.scenes.size(); ++i)
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ namespace LL
|
|||
};
|
||||
|
||||
// C++ representation of a GLTF Asset
|
||||
class Asset : public LLRefCount
|
||||
class Asset
|
||||
{
|
||||
public:
|
||||
std::vector<Scene> mScenes;
|
||||
|
|
@ -287,6 +287,8 @@ namespace LL
|
|||
std::string mCopyright;
|
||||
|
||||
S32 mDefaultScene = INVALID_INDEX;
|
||||
tinygltf::Value mExtras;
|
||||
|
||||
|
||||
// the last time update() was called according to gFrameTimeSeconds
|
||||
F32 mLastUpdateTime = gFrameTimeSeconds;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,16 @@
|
|||
|
||||
#include "llsingleton.h"
|
||||
#include "llviewerobject.h"
|
||||
class LLVOVolume;
|
||||
class LLDrawable;
|
||||
|
||||
namespace LL
|
||||
{
|
||||
namespace GLTF
|
||||
{
|
||||
class Asset;
|
||||
}
|
||||
}
|
||||
|
||||
namespace LL
|
||||
{
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@
|
|||
#include "llmeshrepository.h"
|
||||
#include "llgltfmateriallist.h"
|
||||
#include "llgl.h"
|
||||
#include "gltf/asset.h"
|
||||
|
||||
//#define DEBUG_UPDATE_TYPE
|
||||
|
||||
|
|
@ -4420,7 +4421,7 @@ LLMatrix4a LLViewerObject::getGLTFNodeTransformAgent(S32 node_index) const
|
|||
{
|
||||
LLMatrix4a mat;
|
||||
|
||||
if (mGLTFAsset.notNull() && node_index >= 0 && node_index < mGLTFAsset->mNodes.size())
|
||||
if (mGLTFAsset && node_index >= 0 && node_index < mGLTFAsset->mNodes.size())
|
||||
{
|
||||
auto& node = mGLTFAsset->mNodes[node_index];
|
||||
|
||||
|
|
@ -4474,7 +4475,7 @@ void decomposeMatrix(const LLMatrix4a& mat, LLVector3& position, LLQuaternion& r
|
|||
|
||||
void LLViewerObject::setGLTFNodeRotationAgent(S32 node_index, const LLQuaternion& rotation)
|
||||
{
|
||||
if (mGLTFAsset.notNull() && node_index >= 0 && node_index < mGLTFAsset->mNodes.size())
|
||||
if (mGLTFAsset && node_index >= 0 && node_index < mGLTFAsset->mNodes.size())
|
||||
{
|
||||
auto& node = mGLTFAsset->mNodes[node_index];
|
||||
|
||||
|
|
@ -4506,7 +4507,7 @@ void LLViewerObject::setGLTFNodeRotationAgent(S32 node_index, const LLQuaternion
|
|||
|
||||
void LLViewerObject::moveGLTFNode(S32 node_index, const LLVector3& offset)
|
||||
{
|
||||
if (mGLTFAsset.notNull() && node_index >= 0 && node_index < mGLTFAsset->mNodes.size())
|
||||
if (mGLTFAsset && node_index >= 0 && node_index < mGLTFAsset->mNodes.size())
|
||||
{
|
||||
auto& node = mGLTFAsset->mNodes[node_index];
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,14 @@
|
|||
#include "llbbox.h"
|
||||
#include "llrigginginfo.h"
|
||||
#include "llreflectionmap.h"
|
||||
#include "gltf/asset.h"
|
||||
|
||||
namespace LL
|
||||
{
|
||||
namespace GLTF
|
||||
{
|
||||
class Asset;
|
||||
}
|
||||
}
|
||||
|
||||
class LLAgent; // TODO: Get rid of this.
|
||||
class LLAudioSource;
|
||||
|
|
@ -736,7 +743,7 @@ public:
|
|||
F32 mPhysicsRestitution;
|
||||
|
||||
// Associated GLTF Asset
|
||||
LLPointer<LL::GLTF::Asset> mGLTFAsset;
|
||||
std::shared_ptr<LL::GLTF::Asset> mGLTFAsset;
|
||||
|
||||
// Pipeline classes
|
||||
LLPointer<LLDrawable> mDrawable;
|
||||
|
|
|
|||
Loading…
Reference in New Issue