global mouse moved to state and removed some GetMousePosition()s.
This commit is contained in:
+4
-5
@@ -8,6 +8,8 @@
|
||||
namespace VISEQ::GRAPH {
|
||||
class Connector : public BASE::Connectable, public GraphItem{
|
||||
public:
|
||||
using GraphItem::state;
|
||||
|
||||
Connector() {}
|
||||
Connector(Vec2Df center_position, float orbit) : orbit(orbit) {setPosition(center_position);}
|
||||
|
||||
@@ -16,16 +18,13 @@ namespace VISEQ::GRAPH {
|
||||
Vec2Df center_position;
|
||||
|
||||
void setPosition(Vec2Df pos) override {
|
||||
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
|
||||
center_position = pos;
|
||||
if(!partner) position = center_position - ((center_position - mp)).norm() * (radius + orbit);
|
||||
if(!partner) position = center_position - ((center_position - state->screen_mouse)).norm() * (radius + orbit);
|
||||
if(partner) position = center_position - ((center_position - partner->position)).norm() * (radius + orbit);
|
||||
}
|
||||
|
||||
void draw() override {
|
||||
Vec2Df mp = {GetMousePosition().x, GetMousePosition().y};
|
||||
|
||||
float opacity = 150.0f - Clamp(position.dist(mp), 0.0f, 150.0f);
|
||||
float opacity = 150.0f - Clamp(position.dist(state->screen_mouse), 0.0f, 150.0f);
|
||||
|
||||
if(partner){
|
||||
DrawLineV(position, partner->position, VS_COLOR_RED);
|
||||
|
||||
Reference in New Issue
Block a user