mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 13:21:10 +01:00
Fix all errors in CurveBase found by clangd.
This commit is contained in:
parent
4943aa9569
commit
240871c517
@ -1,106 +1,71 @@
|
|||||||
|
|
||||||
#include "curve_base.h"
|
#include "curve_base.h"
|
||||||
|
|
||||||
Vector2 CurveBase::Point::get_p() {
|
PoolRealArray CurveBase::get_points_array() {
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveBase::Point::set_p(const Vector2 &val) {
|
|
||||||
p = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
float CurveBase::Point::get_ls() const {
|
|
||||||
return ls;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveBase::Point::set_ls(const float val) {
|
|
||||||
ls = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
float CurveBase::Point::get_rs() const {
|
|
||||||
return rs;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveBase::Point::set_rs(const float val) {
|
|
||||||
rs = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurveBase::Point::Point() {
|
|
||||||
ls = 0;
|
|
||||||
rs = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurveBase::Point::Point(const float x, const float y, const float nls, const float nrs) {
|
|
||||||
p = Vector2(x, y);
|
|
||||||
ls = nls;
|
|
||||||
rs = nrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurveBase::Point::~Point() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurveBase::Point::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_p"), &CurveBase::Point::get_p);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_p", "value"), &CurveBase::Point::set_p);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "p"), "set_p", "get_p");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_ls"), &CurveBase::Point::get_ls);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_ls", "value"), &CurveBase::Point::set_ls);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ls"), "set_ls", "get_ls");
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_rs"), &CurveBase::Point::get_rs);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_rs", "value"), &CurveBase::Point::set_rs);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rs"), "set_rs", "get_rs");
|
|
||||||
}
|
|
||||||
|
|
||||||
PoolRealArray CurveBase::get_points() {
|
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveBase::set_points(const PoolRealArray &val) {
|
void CurveBase::set_points_array(const PoolRealArray &val) {
|
||||||
points = val;
|
points = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveBase::init_points_01() {
|
void CurveBase::init_points_01() {
|
||||||
if (points.size() == 0) {
|
if (points.size() == 0) {
|
||||||
points = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 ];
|
points.push_back(0.0);
|
||||||
|
points.push_back(0.0);
|
||||||
|
points.push_back(0.0);
|
||||||
|
points.push_back(1.0);
|
||||||
|
points.push_back(1.0);
|
||||||
|
points.push_back(1.0);
|
||||||
|
points.push_back(1.0);
|
||||||
|
points.push_back(0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveBase::init_points_11() {
|
void CurveBase::init_points_11() {
|
||||||
if (points.size() == 0) {
|
if (points.size() == 0) {
|
||||||
points = [ 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0 ];
|
points.push_back(0.0);
|
||||||
|
points.push_back(1.0);
|
||||||
|
points.push_back(0.0);
|
||||||
|
points.push_back(0.0);
|
||||||
|
points.push_back(1.0);
|
||||||
|
points.push_back(1.0);
|
||||||
|
points.push_back(0.0);
|
||||||
|
points.push_back(0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String CurveBase::to_string() {
|
String CurveBase::to_string() {
|
||||||
PoolStringArray rv;
|
PoolStringArray rv;
|
||||||
|
|
||||||
for (p in points) {
|
Vector<CurveBase::Point> ps = get_points();
|
||||||
rv.append("(" + str(p.x) + "," + str(p.y) + "," + str(p.ls) + "," + str(p.rs) + ")");
|
|
||||||
|
for (int i = 0; i < ps.size(); ++i) {
|
||||||
|
Point p = ps[i];
|
||||||
|
rv.append("(" + String::num(p.p.x) + "," + String::num(p.p.y) + "," + String::num(p.ls) + "," + String::num(p.rs) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv.join(",");
|
return rv.join(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveBase::clear() {
|
void CurveBase::clear() {
|
||||||
points.clear();
|
points.resize(0);
|
||||||
curve_changed();
|
curve_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveBase::add_point(const float x, const float y, const float ls, const float rs) {
|
void CurveBase::add_point(const float x, const float y, float ls, float rs) {
|
||||||
int indx = points.size() / 4;
|
int indx = points.size() / 4;
|
||||||
|
|
||||||
for (i in indx) {
|
for (int i = 0; i < indx; ++i) {
|
||||||
int ii = i * 4;
|
int ii = i * 4;
|
||||||
|
|
||||||
if (x < points[ii]) {
|
if (x < points[ii]) {
|
||||||
if (ls == INF) {
|
if (ls == Math_INF) {
|
||||||
ls == 0;
|
ls = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rs == INF) {
|
if (rs == Math_INF) {
|
||||||
rs == 0;
|
rs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
points.insert(ii, x);
|
points.insert(ii, x);
|
||||||
@ -135,39 +100,56 @@ bool CurveBase::remove_point(const int i) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PoolRealArray CurveBase::get_point_arr(const int i) {
|
||||||
|
int indx = i * 4;
|
||||||
|
|
||||||
|
PoolRealArray arr;
|
||||||
|
|
||||||
|
arr.push_back(points[indx + 0]);
|
||||||
|
arr.push_back(points[indx + 1]);
|
||||||
|
arr.push_back(points[indx + 2]);
|
||||||
|
arr.push_back(points[indx + 3]);
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
int CurveBase::get_point_count() {
|
int CurveBase::get_point_count() {
|
||||||
return points.size() / 4;
|
return points.size() / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveBase::set_point(const int i, const Point &v) {
|
void CurveBase::set_point(const int i, const Point &v) {
|
||||||
int indx = i * 4;
|
int indx = i * 4;
|
||||||
points[indx + 0] = v.p.x;
|
|
||||||
points[indx + 1] = v.p.y;
|
points.set(indx + 0, v.p.x);
|
||||||
points[indx + 2] = v.ls;
|
points.set(indx + 1, v.p.y);
|
||||||
points[indx + 3] = v.rs;
|
points.set(indx + 2, v.ls);
|
||||||
|
points.set(indx + 3, v.rs);
|
||||||
|
|
||||||
curve_changed();
|
curve_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
Point CurveBase::get_point(const int i) {
|
CurveBase::Point CurveBase::get_point(const int i) {
|
||||||
int indx = i * 4;
|
int indx = i * 4;
|
||||||
return Point.new(points[indx + 0], points[indx + 1], points[indx + 2], points[indx + 3]);
|
|
||||||
|
return Point(points[indx + 0], points[indx + 1], points[indx + 2], points[indx + 3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array CurveBase::get_points() {
|
Vector<CurveBase::Point> CurveBase::get_points() {
|
||||||
Array arr = Array();
|
Vector<CurveBase::Point> arr;
|
||||||
int c = get_point_count();
|
int c = get_point_count();
|
||||||
|
|
||||||
for (int i = 0; i < c; ++i) { //i in range(c)
|
for (int i = 0; i < c; ++i) { //i in range(c)
|
||||||
arr.append(get_point(i));
|
arr.push_back(get_point(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveBase::set_points(const Array &arr, const bool notify) {
|
void CurveBase::set_points(const Vector<CurveBase::Point> &arr, const bool notify) {
|
||||||
points.resize(0);
|
points.resize(0);
|
||||||
|
|
||||||
for (p in arr) {
|
for (int i = 0; i < arr.size(); ++i) {
|
||||||
|
Point p = arr[i];
|
||||||
points.append(p.p.x);
|
points.append(p.p.x);
|
||||||
points.append(p.p.y);
|
points.append(p.p.y);
|
||||||
points.append(p.ls);
|
points.append(p.ls);
|
||||||
@ -193,10 +175,10 @@ CurveBase::CurveBase() {
|
|||||||
CurveBase::~CurveBase() {
|
CurveBase::~CurveBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CurveBase::_bind_methods() {
|
void CurveBase::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_Variant"), &CurveBase::get_Variant);
|
ClassDB::bind_method(D_METHOD("get_points_array"), &CurveBase::get_points_array);
|
||||||
ClassDB::bind_method(D_METHOD("set_Variant", "value"), &CurveBase::set_Variant);
|
ClassDB::bind_method(D_METHOD("set_points_array", "value"), &CurveBase::set_points_array);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "Variant", PROPERTY_HINT_RESOURCE_TYPE, "Variant"), "set_Variant", "get_Variant");
|
ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "points_array"), "set_points_array", "get_points_array");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("init_points_01"), &CurveBase::init_points_01);
|
ClassDB::bind_method(D_METHOD("init_points_01"), &CurveBase::init_points_01);
|
||||||
ClassDB::bind_method(D_METHOD("init_points_11"), &CurveBase::init_points_11);
|
ClassDB::bind_method(D_METHOD("init_points_11"), &CurveBase::init_points_11);
|
||||||
@ -205,17 +187,19 @@ static void CurveBase::_bind_methods() {
|
|||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("clear"), &CurveBase::clear);
|
ClassDB::bind_method(D_METHOD("clear"), &CurveBase::clear);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("add_point", "x", "y", "ls", "rs"), &CurveBase::add_point, INF, INF);
|
ClassDB::bind_method(D_METHOD("add_point", "x", "y", "ls", "rs"), &CurveBase::add_point, Math_INF, Math_INF);
|
||||||
ClassDB::bind_method(D_METHOD("remove_point", "i"), &CurveBase::remove_point);
|
ClassDB::bind_method(D_METHOD("remove_point", "i"), &CurveBase::remove_point);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_point_arr", "i"), &CurveBase::get_point_arr);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_point_count"), &CurveBase::get_point_count);
|
ClassDB::bind_method(D_METHOD("get_point_count"), &CurveBase::get_point_count);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_point", "i", "v"), &CurveBase::set_point);
|
//ClassDB::bind_method(D_METHOD("set_point", "i", "v"), &CurveBase::set_point);
|
||||||
ClassDB::bind_method(D_METHOD("get_point", "i"), &CurveBase::get_point);
|
//ClassDB::bind_method(D_METHOD("get_point", "i"), &CurveBase::get_point);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_points"), &CurveBase::get_points);
|
ClassDB::bind_method(D_METHOD("get_points"), &CurveBase::get_points);
|
||||||
ClassDB::bind_method(D_METHOD("set_points", "arr", "notify"), &CurveBase::set_points, true);
|
ClassDB::bind_method(D_METHOD("set_points", "arr", "notify"), &CurveBase::set_points, true);
|
||||||
|
|
||||||
|
BIND_VMETHOD(MethodInfo("_curve_changed"));
|
||||||
ClassDB::bind_method(D_METHOD("curve_changed"), &CurveBase::curve_changed);
|
ClassDB::bind_method(D_METHOD("curve_changed"), &CurveBase::curve_changed);
|
||||||
ClassDB::bind_method(D_METHOD("_curve_changed"), &CurveBase::_curve_changed);
|
ClassDB::bind_method(D_METHOD("_curve_changed"), &CurveBase::_curve_changed);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#ifndef CURVE_BASE_H
|
#ifndef CURVE_BASE_H
|
||||||
#define CURVE_BASE_H
|
#define CURVE_BASE_H
|
||||||
|
|
||||||
|
#include "core/math/math_defs.h"
|
||||||
|
#include "core/math/vector2.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
|
#include "core/vector.h"
|
||||||
|
|
||||||
#include "../mm_node.h"
|
#include "../mm_node.h"
|
||||||
|
|
||||||
@ -9,32 +12,32 @@ class CurveBase : public MMNode {
|
|||||||
GDCLASS(CurveBase, MMNode);
|
GDCLASS(CurveBase, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Point {
|
struct Point {
|
||||||
public:
|
|
||||||
Vector2 get_p();
|
|
||||||
void set_p(const Vector2 &val);
|
|
||||||
|
|
||||||
float get_ls() const;
|
|
||||||
void set_ls(const float val);
|
|
||||||
|
|
||||||
float get_rs() const;
|
|
||||||
void set_rs(const float val);
|
|
||||||
|
|
||||||
Point();
|
|
||||||
Point(const float x, const float y, const float nls, const float nrs);
|
|
||||||
~Point();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
Vector2 p;
|
Vector2 p;
|
||||||
float ls;
|
float ls;
|
||||||
float rs;
|
float rs;
|
||||||
|
|
||||||
|
void set(const float x, const float y, const float nls, const float nrs) {
|
||||||
|
p = Vector2(x, y);
|
||||||
|
ls = nls;
|
||||||
|
rs = nrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point() {
|
||||||
|
ls = 0;
|
||||||
|
rs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point(const float x, const float y, const float nls, const float nrs) {
|
||||||
|
p = Vector2(x, y);
|
||||||
|
ls = nls;
|
||||||
|
rs = nrs;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PoolRealArray get_points();
|
PoolRealArray get_points_array();
|
||||||
void set_points(const PoolRealArray &val);
|
void set_points_array(const PoolRealArray &val);
|
||||||
|
|
||||||
void init_points_01();
|
void init_points_01();
|
||||||
void init_points_11();
|
void init_points_11();
|
||||||
@ -43,15 +46,17 @@ public:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void add_point(const float x, const float y, const float ls = INF, const float rs = INF);
|
void add_point(const float x, const float y, float ls = Math_INF, float rs = Math_INF);
|
||||||
bool remove_point(const int i);
|
bool remove_point(const int i);
|
||||||
|
PoolRealArray get_point_arr(const int i);
|
||||||
|
|
||||||
int get_point_count();
|
int get_point_count();
|
||||||
|
|
||||||
void set_point(const int i, const Point &v);
|
void set_point(const int i, const Point &v);
|
||||||
Point get_point(const int i);
|
Point get_point(const int i);
|
||||||
Array get_points();
|
|
||||||
void set_points(const Array &arr, const bool notify = true);
|
Vector<Point> get_points();
|
||||||
|
void set_points(const Vector<Point> &arr, const bool notify = true);
|
||||||
|
|
||||||
void curve_changed();
|
void curve_changed();
|
||||||
void _curve_changed();
|
void _curve_changed();
|
||||||
|
Loading…
Reference in New Issue
Block a user