-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathRenderable.h
More file actions
92 lines (71 loc) · 2.54 KB
/
Copy pathRenderable.h
File metadata and controls
92 lines (71 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// Created by Engin Manap on 3.03.2016.
//
#ifndef LIMONENGINE_RENDERABLE_H
#define LIMONENGINE_RENDERABLE_H
#include "GameObjects/GameObject.h"
#include "limonAPI/Graphics/GraphicsInterface.h"
#include "limonAPI/Graphics/GraphicsProgram.h"
#include "Transformation.h"
#include "HasTransform.h"
#include <btBulletDynamicsCommon.h>
#include <glm/gtx/matrix_decompose.hpp>
class Renderable : public virtual HasTransform {
protected:
Transformation transformation;
std::vector<uint32_t> bufferObjects;
std::vector<bool> inLightFrustum;
uint32_t vao = 0, ebo = 0;
GraphicsInterface* graphicsWrapper;
bool isInCameraFrustum = true;
bool dirtyForFrustum = true;//is this object require a frustum recalculate
bool customAnimation = false;
explicit Renderable(GraphicsInterface* graphicsWrapper) :
graphicsWrapper(graphicsWrapper) {
OptionsUtil::Options::Option<long> maxPointLightOption = graphicsWrapper->getOptions()->getOption<long>(HASH("performance_maximumLights"));
this->inLightFrustum.resize(maxPointLightOption.getOrDefault(4));
}
public:
virtual void renderWithProgram(std::shared_ptr<GraphicsProgram> renderProgram, uint32_t lodLevel) = 0;
virtual void setupForTime(uint32_t time) = 0;
virtual ~Renderable() {
for (unsigned int i = 0; i < bufferObjects.size(); ++i) {
graphicsWrapper->freeBuffer(bufferObjects[i]);
}
graphicsWrapper->freeBuffer(ebo);
graphicsWrapper->freeVAO(vao);
}
bool isIsInFrustum() const {
return isInCameraFrustum;
}
void setIsInFrustum(bool isInFrustum) {
Renderable::isInCameraFrustum = isInFrustum;
}
bool isInLightFrustum(uint32_t lightIndex) const {
assert(lightIndex < 4);
return Renderable::inLightFrustum[lightIndex];
}
void setIsInLightFrustum(uint32_t lightIndex, bool isInFrustum) {
assert(lightIndex < 4);
Renderable::inLightFrustum[lightIndex] = isInFrustum;
}
bool isDirtyForFrustum() {
return this->dirtyForFrustum;
}
void setCleanForFrustum() {
this->dirtyForFrustum = false;
}
Transformation* getTransformation() override {
return &transformation;
}
Transformation const * getTransformation() const override {
return &transformation;
}
void setCustomAnimation(bool customAnimation) {
this->customAnimation = customAnimation;
}
bool getCustomAnimation() const {
return customAnimation;
}
};
#endif //LIMONENGINE_RENDERABLE_H