LCOV - code coverage report
Current view: top level - xenolith/core - XLCoreMesh.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 5 0.0 %
Date: 2024-05-12 00:16:13 Functions: 0 5 0.0 %

          Line data    Source code
       1             : /**
       2             :  Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
       3             : 
       4             :  Permission is hereby granted, free of charge, to any person obtaining a copy
       5             :  of this software and associated documentation files (the "Software"), to deal
       6             :  in the Software without restriction, including without limitation the rights
       7             :  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       8             :  copies of the Software, and to permit persons to whom the Software is
       9             :  furnished to do so, subject to the following conditions:
      10             : 
      11             :  The above copyright notice and this permission notice shall be included in
      12             :  all copies or substantial portions of the Software.
      13             : 
      14             :  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      15             :  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      16             :  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      17             :  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      18             :  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      19             :  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      20             :  THE SOFTWARE.
      21             :  **/
      22             : 
      23             : #ifndef XENOLITH_CORE_XLCOREMESH_H_
      24             : #define XENOLITH_CORE_XLCOREMESH_H_
      25             : 
      26             : #include "XLCoreResource.h"
      27             : #include "XLCoreAttachment.h"
      28             : 
      29             : namespace STAPPLER_VERSIONIZED stappler::xenolith::core {
      30             : 
      31             : class MeshAttachment;
      32             : class MeshIndex;
      33             : 
      34             : struct MeshInputData : AttachmentInputData {
      35             :         const MeshAttachment *attachment;
      36             :         Vector<Rc<MeshIndex>> meshesToAdd;
      37             :         Vector<Rc<MeshIndex>> meshesToRemove;
      38             : };
      39             : 
      40             : class MeshSet final : public Ref {
      41             : public:
      42             :         struct Index {
      43             :                 uint64_t indexOffset;
      44             :                 uint64_t vertexOffset;
      45             :                 Rc<MeshIndex> index;
      46             :         };
      47             : 
      48             :         virtual ~MeshSet();
      49             : 
      50             :         bool init(Vector<Index> &&, BufferObject *index, BufferObject *vertex);
      51             : 
      52           0 :         const Vector<Index> &getIndexes() const { return _indexes; }
      53             : 
      54           0 :         const Rc<BufferObject> &getVertexBuffer() const { return _vertexBuffer; }
      55           0 :         const Rc<BufferObject> &getIndexBuffer() const { return _indexBuffer; }
      56             : 
      57             :         void clear();
      58             : 
      59             : protected:
      60             :         Vector<Index> _indexes;
      61             :         Rc<BufferObject> _vertexBuffer;
      62             :         Rc<BufferObject> _indexBuffer;
      63             : };
      64             : 
      65             : class MeshIndex final : public Resource {
      66             : public:
      67             :         using DataCallback = memory::callback<void(BytesView)>;
      68             :         using BufferCallback = memory::function<void(uint8_t *, uint64_t, const DataCallback &)>;
      69             : 
      70             :         struct MeshBufferInfo {
      71             :                 uint64_t indexBufferSize;
      72             :                 BufferCallback indexBufferCallback;
      73             : 
      74             :                 uint64_t vertexBufferSize;
      75             :                 BufferCallback vertexBufferCallback;
      76             :         };
      77             : 
      78             :         virtual ~MeshIndex();
      79             : 
      80             :         bool init(StringView, Rc<DataAtlas> &&, MeshBufferInfo &&);
      81             : 
      82           0 :         const BufferData *getVertexBufferData() const { return _vertexBuffer; }
      83           0 :         const BufferData *getIndexBufferData() const { return _indexBuffer; }
      84             : 
      85             :         const Rc<DataAtlas> &getAtlas() const { return _atlas; }
      86             : 
      87             : protected:
      88             :         Rc<DataAtlas> _atlas;
      89             :         const BufferData *_vertexBuffer = nullptr;
      90             :         const BufferData *_indexBuffer = nullptr;
      91             : };
      92             : 
      93             : // this attachment should provide material data buffer for rendering
      94             : class MeshAttachment : public BufferAttachment {
      95             : public:
      96             :         virtual ~MeshAttachment();
      97             : 
      98             :         virtual bool init(AttachmentBuilder &, const BufferInfo &info, Vector<Rc<MeshIndex>> &&initials);
      99             : 
     100             :         const Rc<MeshSet> &getMeshes() const;
     101             :         void setMeshes(const Rc<MeshSet> &) const;
     102             : 
     103             : protected:
     104             :         using BufferAttachment::init;
     105             : 
     106             :         mutable Rc<MeshSet> _data;
     107             :         Vector<Rc<MeshIndex>> _initials;
     108             : };
     109             : 
     110             : }
     111             : 
     112             : #endif /* XENOLITH_CORE_XLCOREMESH_H_ */

Generated by: LCOV version 1.14