mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
update ModelBatch semantics
This commit is contained in:
parent
ea0add3017
commit
94fe5eeb5b
7 changed files with 97 additions and 35 deletions
|
|
@ -11,12 +11,13 @@ class Chunks;
|
|||
class Assets;
|
||||
|
||||
namespace model {
|
||||
struct Mesh;
|
||||
struct Model;
|
||||
}
|
||||
|
||||
class ModelBatch {
|
||||
std::unique_ptr<float[]> buffer;
|
||||
size_t capacity;
|
||||
std::unique_ptr<float[]> const buffer;
|
||||
size_t const capacity;
|
||||
size_t index;
|
||||
|
||||
std::unique_ptr<Mesh> mesh;
|
||||
|
|
@ -28,6 +29,7 @@ class ModelBatch {
|
|||
|
||||
Assets* assets;
|
||||
Chunks* chunks;
|
||||
Texture* texture = nullptr;
|
||||
|
||||
static inline glm::vec3 SUN_VECTOR {0.411934f, 0.863868f, -0.279161f};
|
||||
|
||||
|
|
@ -35,7 +37,6 @@ class ModelBatch {
|
|||
glm::vec3 pos, glm::vec2 uv, glm::vec4 light
|
||||
) {
|
||||
float* buffer = this->buffer.get();
|
||||
pos = combined * glm::vec4(pos, 1.0f);
|
||||
buffer[index++] = pos.x;
|
||||
buffer[index++] = pos.y;
|
||||
buffer[index++] = pos.z;
|
||||
|
|
@ -70,6 +71,18 @@ class ModelBatch {
|
|||
vertex(pos+right+up, {1,1}, color);
|
||||
vertex(pos-right+up, {0,1}, color);
|
||||
}
|
||||
|
||||
void draw(const model::Mesh& mesh, const glm::mat4& matrix, const glm::mat3& rotation);
|
||||
void box(glm::vec3 pos, glm::vec3 size, glm::vec4 lights);
|
||||
void setTexture(Texture* texture);
|
||||
void flush();
|
||||
|
||||
struct DrawEntry {
|
||||
glm::mat4 matrix;
|
||||
glm::mat3 rotation;
|
||||
const model::Mesh* mesh;
|
||||
};
|
||||
std::vector<DrawEntry> entries;
|
||||
public:
|
||||
ModelBatch(size_t capacity, Assets* assets, Chunks* chunks);
|
||||
~ModelBatch();
|
||||
|
|
@ -80,12 +93,9 @@ public:
|
|||
|
||||
void pushMatrix(glm::mat4 matrix);
|
||||
void popMatrix();
|
||||
|
||||
void box(glm::vec3 pos, glm::vec3 size, glm::vec4 lights);
|
||||
|
||||
void draw(const model::Model* model);
|
||||
|
||||
void flush();
|
||||
void render();
|
||||
};
|
||||
|
||||
#endif // GRAPHICS_RENDER_MODEL_BATCH_HPP_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue