mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
some changes and bugfixes
This commit is contained in:
+5
-3
@@ -35,6 +35,7 @@ namespace vb01{
|
||||
mat4 proj = perspective(radians(fov), width / height, nearPlane, farPlane);
|
||||
|
||||
for(Line &l : lines){
|
||||
if(l.visible){
|
||||
shader->use();
|
||||
shader->setVec3(l.color, "color");
|
||||
shader->setMat4(proj, "proj");
|
||||
@@ -46,6 +47,7 @@ namespace vb01{
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LineRenderer::addLine(Vector3 start, Vector3 end, Vector3 color){
|
||||
Line line;
|
||||
@@ -81,9 +83,9 @@ namespace vb01{
|
||||
}
|
||||
|
||||
void LineRenderer::removeLine(int id){
|
||||
for(Line &l : lines)
|
||||
if(l.id == id){
|
||||
lines.erase(lines.begin() + id);
|
||||
for(int i = 0; i < lines.size(); ++i)
|
||||
if(lines[i].id == id){
|
||||
lines.erase(lines.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -11,15 +11,17 @@ namespace vb01{
|
||||
|
||||
class LineRenderer{
|
||||
public:
|
||||
struct Line{int id; Vector3 start; Vector3 end; Vector3 color;};
|
||||
struct Line{int id; Vector3 start; Vector3 end; Vector3 color; bool visible = true;};
|
||||
enum VectorFieldType{START, END, COLOR};
|
||||
|
||||
static LineRenderer* getSingleton();
|
||||
void drawLines();
|
||||
void addLine(Vector3 start, Vector3 end, Vector3 color);
|
||||
void changeLineField(int, Vector3, VectorFieldType);
|
||||
void toggleVisibility(int i, bool v){getLine(i).visible = v;}
|
||||
void removeLine(int);
|
||||
Line& getLine(int);
|
||||
inline std::vector<Line>& getLines(){return lines;}
|
||||
private:
|
||||
LineRenderer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user