BsMeshBase.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #include "BsMeshBase.h"
  5. #include "BsMeshBaseRTTI.h"
  6. #include "BsCoreThread.h"
  7. #include "BsDebug.h"
  8. namespace BansheeEngine
  9. {
  10. MeshBase::MeshBase(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp)
  11. :mNumIndices(numIndices), mNumVertices(numVertices), mCoreDirtyFlags(0xFFFFFF)
  12. {
  13. mSubMeshes.push_back(SubMesh(0, numIndices, drawOp));
  14. mActiveProxies.resize(mSubMeshes.size());
  15. }
  16. MeshBase::MeshBase(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes)
  17. : mNumIndices(numIndices), mNumVertices(numVertices), mCoreDirtyFlags(0xFFFFFF)
  18. {
  19. mSubMeshes = subMeshes;
  20. mActiveProxies.resize(mSubMeshes.size());
  21. }
  22. MeshBase::MeshBase()
  23. {
  24. mSubMeshes.reserve(10);
  25. }
  26. MeshBase::~MeshBase()
  27. {
  28. }
  29. const SubMesh& MeshBase::getSubMesh(UINT32 subMeshIdx) const
  30. {
  31. if(subMeshIdx < 0 || subMeshIdx >= mSubMeshes.size())
  32. {
  33. BS_EXCEPT(InvalidParametersException, "Invalid sub-mesh index ("
  34. + toString(subMeshIdx) + "). Number of sub-meshes available: " + toString((int)mSubMeshes.size()));
  35. }
  36. return mSubMeshes[subMeshIdx];
  37. }
  38. UINT32 MeshBase::getNumSubMeshes() const
  39. {
  40. return (UINT32)mSubMeshes.size();
  41. }
  42. /************************************************************************/
  43. /* SERIALIZATION */
  44. /************************************************************************/
  45. RTTITypeBase* MeshBase::getRTTIStatic()
  46. {
  47. return MeshBaseRTTI::instance();
  48. }
  49. RTTITypeBase* MeshBase::getRTTI() const
  50. {
  51. return MeshBase::getRTTIStatic();
  52. }
  53. }