optimize ModelBatch
This commit is contained in:
@@ -29,10 +29,6 @@ class ModelBatch {
|
||||
std::unique_ptr<Mesh> mesh;
|
||||
std::unique_ptr<Texture> blank;
|
||||
|
||||
glm::mat4 combined;
|
||||
std::vector<glm::mat4> matrices;
|
||||
glm::mat3 rotation;
|
||||
|
||||
Assets* assets;
|
||||
Chunks* chunks;
|
||||
Texture* texture = nullptr;
|
||||
@@ -63,25 +59,8 @@ class ModelBatch {
|
||||
buffer[index++] = compressed.floating;
|
||||
}
|
||||
|
||||
inline void plane(glm::vec3 pos, glm::vec3 right, glm::vec3 up, glm::vec3 norm, glm::vec4 lights) {
|
||||
norm = rotation * norm;
|
||||
float d = glm::dot(norm, SUN_VECTOR);
|
||||
d = 0.8f + d * 0.2f;
|
||||
|
||||
auto color = lights * d;
|
||||
|
||||
vertex(pos-right-up, {0,0}, color);
|
||||
vertex(pos+right-up, {1,0}, color);
|
||||
vertex(pos+right+up, {1,1}, color);
|
||||
|
||||
vertex(pos-right-up, {0,0}, color);
|
||||
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, const texture_names_map* varTextures);
|
||||
void box(glm::vec3 pos, glm::vec3 size, glm::vec4 lights);
|
||||
void setTexture(const std::string& name,
|
||||
const texture_names_map* varTextures);
|
||||
void setTexture(Texture* texture);
|
||||
@@ -98,13 +77,10 @@ public:
|
||||
ModelBatch(size_t capacity, Assets* assets, Chunks* chunks);
|
||||
~ModelBatch();
|
||||
|
||||
void translate(glm::vec3 vec);
|
||||
void rotate(glm::vec3 axis, float angle);
|
||||
void scale(glm::vec3 vec);
|
||||
|
||||
void pushMatrix(glm::mat4 matrix);
|
||||
void popMatrix();
|
||||
void draw(const model::Model* model,
|
||||
void draw(glm::mat4 matrix,
|
||||
const model::Model* model,
|
||||
const texture_names_map* varTextures);
|
||||
|
||||
void render();
|
||||
|
||||
Reference in New Issue
Block a user