BsMeshBase.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "BsMeshBase.h"
  2. #include "BsMeshBaseRTTI.h"
  3. #include "BsCoreThread.h"
  4. #include "BsDebug.h"
  5. namespace BansheeEngine
  6. {
  7. MeshBase::MeshBase(UINT32 numVertices, UINT32 numIndices, DrawOperationType drawOp)
  8. :mNumIndices(numIndices), mNumVertices(numVertices), mCoreDirtyFlags(0xFFFFFF)
  9. {
  10. mSubMeshes.push_back(SubMesh(0, numIndices, drawOp));
  11. }
  12. MeshBase::MeshBase(UINT32 numVertices, UINT32 numIndices, const Vector<SubMesh>& subMeshes)
  13. : mNumIndices(numIndices), mNumVertices(numVertices), mCoreDirtyFlags(0xFFFFFF)
  14. {
  15. mSubMeshes = subMeshes;
  16. }
  17. MeshBase::MeshBase()
  18. {
  19. mSubMeshes.reserve(10);
  20. }
  21. MeshBase::~MeshBase()
  22. {
  23. }
  24. const SubMesh& MeshBase::getSubMesh(UINT32 subMeshIdx) const
  25. {
  26. if(subMeshIdx < 0 || subMeshIdx >= mSubMeshes.size())
  27. {
  28. BS_EXCEPT(InvalidParametersException, "Invalid sub-mesh index ("
  29. + toString(subMeshIdx) + "). Number of sub-meshes available: " + toString((int)mSubMeshes.size()));
  30. }
  31. return mSubMeshes[subMeshIdx];
  32. }
  33. UINT32 MeshBase::getNumSubMeshes() const
  34. {
  35. return (UINT32)mSubMeshes.size();
  36. }
  37. /************************************************************************/
  38. /* SERIALIZATION */
  39. /************************************************************************/
  40. RTTITypeBase* MeshBase::getRTTIStatic()
  41. {
  42. return MeshBaseRTTI::instance();
  43. }
  44. RTTITypeBase* MeshBase::getRTTI() const
  45. {
  46. return MeshBase::getRTTIStatic();
  47. }
  48. }