mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Split CVertexBuffer from CMeshBuffer
This commit is contained in:
parent
538b8b9b34
commit
5d6e15bc49
10 changed files with 246 additions and 78 deletions
122
irr/include/CVertexBuffer.h
Normal file
122
irr/include/CVertexBuffer.h
Normal file
|
@ -0,0 +1,122 @@
|
|||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "IVertexBuffer.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene
|
||||
{
|
||||
//! Template implementation of the IVertexBuffer interface
|
||||
template <class T>
|
||||
class CVertexBuffer : public IVertexBuffer
|
||||
{
|
||||
public:
|
||||
//! Default constructor for empty buffer
|
||||
CVertexBuffer()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CVertexBuffer");
|
||||
#endif
|
||||
}
|
||||
|
||||
const void *getData() const override
|
||||
{
|
||||
return Data.data();
|
||||
}
|
||||
|
||||
void *getData() override
|
||||
{
|
||||
return Data.data();
|
||||
}
|
||||
|
||||
u32 getCount() const override
|
||||
{
|
||||
return static_cast<u32>(Data.size());
|
||||
}
|
||||
|
||||
video::E_VERTEX_TYPE getType() const override
|
||||
{
|
||||
return T::getType();
|
||||
}
|
||||
|
||||
const core::vector3df &getPosition(u32 i) const override
|
||||
{
|
||||
return Data[i].Pos;
|
||||
}
|
||||
|
||||
core::vector3df &getPosition(u32 i) override
|
||||
{
|
||||
return Data[i].Pos;
|
||||
}
|
||||
|
||||
const core::vector3df &getNormal(u32 i) const override
|
||||
{
|
||||
return Data[i].Normal;
|
||||
}
|
||||
|
||||
core::vector3df &getNormal(u32 i) override
|
||||
{
|
||||
return Data[i].Normal;
|
||||
}
|
||||
|
||||
const core::vector2df &getTCoords(u32 i) const override
|
||||
{
|
||||
return Data[i].TCoords;
|
||||
}
|
||||
|
||||
core::vector2df &getTCoords(u32 i) override
|
||||
{
|
||||
return Data[i].TCoords;
|
||||
}
|
||||
|
||||
E_HARDWARE_MAPPING getHardwareMappingHint() const override
|
||||
{
|
||||
return MappingHint;
|
||||
}
|
||||
|
||||
void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint) override
|
||||
{
|
||||
MappingHint = NewMappingHint;
|
||||
}
|
||||
|
||||
void setDirty() override
|
||||
{
|
||||
++ChangedID;
|
||||
}
|
||||
|
||||
u32 getChangedID() const override { return ChangedID; }
|
||||
|
||||
void setHWBuffer(void *ptr) const override
|
||||
{
|
||||
HWBuffer = ptr;
|
||||
}
|
||||
|
||||
void *getHWBuffer() const override
|
||||
{
|
||||
return HWBuffer;
|
||||
}
|
||||
|
||||
u32 ChangedID = 1;
|
||||
|
||||
//! hardware mapping hint
|
||||
E_HARDWARE_MAPPING MappingHint = EHM_NEVER;
|
||||
mutable void *HWBuffer = nullptr;
|
||||
|
||||
//! Vertices of this buffer
|
||||
std::vector<T> Data;
|
||||
};
|
||||
|
||||
//! Standard buffer
|
||||
typedef CVertexBuffer<video::S3DVertex> SVertexBuffer;
|
||||
//! Buffer with two texture coords per vertex, e.g. for lightmaps
|
||||
typedef CVertexBuffer<video::S3DVertex2TCoords> SVertexBufferLightMap;
|
||||
//! Buffer with vertices having tangents stored, e.g. for normal mapping
|
||||
typedef CVertexBuffer<video::S3DVertexTangents> SVertexBufferTangents;
|
||||
|
||||
} // end namespace scene
|
||||
} // end namespace irr
|
Loading…
Add table
Add a link
Reference in a new issue