1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#include "RenderAPI/BsVertexData.h"
4#include "Managers/BsHardwareBufferManager.h"
5#include "RenderAPI/BsVertexBuffer.h"
6#include "Math/BsVector3.h"
7#include "Error/BsException.h"
8#include "RenderAPI/BsRenderAPI.h"
9
10namespace bs { namespace ct
11{
12 void VertexData::setBuffer(UINT32 index, SPtr<VertexBuffer> buffer)
13 {
14 mVertexBuffers[index] = buffer;
15
16 recalculateMaxIndex();
17 }
18
19 SPtr<VertexBuffer> VertexData::getBuffer(UINT32 index) const
20 {
21 auto iterFind = mVertexBuffers.find(index);
22 if(iterFind != mVertexBuffers.end())
23 {
24 return iterFind->second;
25 }
26
27 return nullptr;
28 }
29
30 bool VertexData::isBufferBound(UINT32 index) const
31 {
32 auto iterFind = mVertexBuffers.find(index);
33 if(iterFind != mVertexBuffers.end())
34 {
35 if(iterFind->second != nullptr)
36 return true;
37 }
38
39 return false;
40 }
41
42 void VertexData::recalculateMaxIndex()
43 {
44 mMaxBufferIdx = 0;
45 for (auto& bufferData : mVertexBuffers)
46 mMaxBufferIdx = std::max(bufferData.first, mMaxBufferIdx);
47 }
48}}
49