123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /**
- * @file llgltfprimitive.h
- * @brief LL GLTF Implementation
- *
- * $LicenseInfo:firstyear=2024&license=viewergpl$
- *
- * Copyright (c) 2024, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #ifndef LL_LLGLTFPRIMITIVE_H
- #define LL_LLGLTFPRIMITIVE_H
- #include "hbfastmap.h"
- #include "llmemory.h" // For LL_ALIGNED16_NEW_DELETE
- #include "llvertexbuffer.h"
- #include "llvolumeoctree.h"
- // Saves from including "tinygltf/tiny_gltf.h" here. HB
- namespace tinygltf
- {
- struct Primitive;
- }
- namespace LLGLTF
- {
- class Asset;
- constexpr U32 ATTRIBUTE_MASK = LLVertexBuffer::MAP_VERTEX |
- LLVertexBuffer::MAP_NORMAL |
- LLVertexBuffer::MAP_TEXCOORD0 |
- LLVertexBuffer::MAP_TANGENT |
- LLVertexBuffer::MAP_COLOR;
- // Note 16-byte aligned because we use vectors of LLVector4a. HB
- class alignas(16) Primitive
- {
- protected:
- LOG_CLASS(LLGLTF::Primitive);
- public:
- LL_ALIGNED16_NEW_DELETE
- Primitive();
- ~Primitive();
- // Creates an octree based on vertex buffer; must be called before
- // buffer is unmapped and after buffer is populated with valid data.
- void createOctree();
- // Gets the LLVolumeTriangle that intersects with the given line
- // segment at the point closest to start. Moves end to the point of
- // intersection. Returns NULL if no intersection.
- // Line segment must be in the same coordinate frame as this Primitive.
- const LLVolumeTriangle* lineSegmentIntersect(const LLVector4a& start,
- const LLVector4a& end,
- LLVector4a* interp = NULL,
- LLVector2* tcoordp = NULL,
- LLVector4a* normp = NULL,
- LLVector4a* tgtp = NULL);
-
- const Primitive& operator=(const tinygltf::Primitive& src);
- // Returns true on success, or false on failure. HB
- bool allocateGLResources(Asset& asset);
- public:
- // Aligned members first...
- // CPU copy of mesh data
- std::vector<LLVector4a> mNormals;
- std::vector<LLVector4a> mTangents;
- std::vector<LLVector4a> mPositions;
- std::vector<LLVector4a> mJoints;
- std::vector<LLVector4a> mWeights;
- // ... then the rest.
- std::vector<LLVector2> mTexCoords;
- std::vector<LLColor4U> mColors;
- std::vector<U32> mIndexArray;
- // Raycast acceleration structure
- std::vector<LLVolumeTriangle> mOctreeTriangles;
- LLPointer<LLVolumeOctree> mOctree;
- // GPU copy of mesh data
- LLPointer<LLVertexBuffer> mVertexBuffer;
- fast_hmap<std::string, S32> mAttributes;
- S32 mMaterial;
- U32 mMode;
- U32 mGLMode;
- S32 mIndices;
- };
- }
- #endif // LL_LLGLTFPRIMITIVE_H
|