fixing stroke direction

This commit is contained in:
2019-11-25 00:47:20 +01:00
parent b26a814208
commit 423df3b92d
2 changed files with 181 additions and 4 deletions

View File

@@ -146,15 +146,33 @@ public:
glm::vec3 pos = { 0, 0, 0 };
float pressure = 0;
float dist = 0;
glm::vec2 dir = { 0, 0 };
};
struct Camera
{
glm::mat4 rot;
float fov = 0;
};
struct SamplesInterpolator
{
Keypoint last;
std::vector<Keypoint> keypoints;
bool ready_first;
bool first;
float spacing;
float dist;
SamplesInterpolator() noexcept;
SamplesInterpolator(float sp) noexcept;
void add(const Keypoint& p) noexcept;
bool ready() const noexcept;
void reset(bool clear_keypoints) noexcept;
std::vector<Keypoint> compute() noexcept;
};
int m_layer = 0;
int m_dir_kp = 0;
bool m_dir_valid = false;
std::vector<Keypoint> m_dirs_cache;
int m_dir_i = 0;
glm::vec2 m_dir_ref = { 1, 0 };
float m_dir_ref_angle = 0;
float m_dir_dist = 0;
@@ -183,7 +201,10 @@ public:
void reset(bool clear_keypoints = false);
bool has_sample();
std::vector<StrokeSample> compute_samples();
std::vector<StrokeSample> compute_samples_old();
StrokeSample randomize_sample(const glm::vec3& pos, float pressure, float curve_angle);
SamplesInterpolator m_interp_main;
SamplesInterpolator m_interp_dir;
void randomize_prng();
float rnd_nor() { return float((double)prng() / (double)prng.max()); }; // normalized [0, +1]