fix poly clip and fix poly_remove_duplicate
This commit is contained in:
@@ -862,7 +862,7 @@ Here's a list of what's available in this release.
|
|||||||
<icon icon="picture_go" width="20"/>
|
<icon icon="picture_go" width="20"/>
|
||||||
<text text="Export JPG" grow="1" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
<text text="Export JPG" grow="1" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom id="file-share" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="file-share" os="osx,ios" text="Menu" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="picture_go" width="20"/>
|
<icon icon="picture_go" width="20"/>
|
||||||
<text text="Share" grow="1" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
<text text="Share" grow="1" margin="0 0 0 5" font-face="arial" font-size="11"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
@@ -1088,9 +1088,11 @@ Here's a list of what's available in this release.
|
|||||||
<image path="data/ui/layers.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
<image path="data/ui/layers.png" width="100%" height="100%" align="center" justify="flex-end"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
|
||||||
|
<!--
|
||||||
<button-custom id="btn-grids-panel" width="50" height="50" margin="0 0 5 0" thickness="1" border-color=".1" pad="2">
|
<button-custom id="btn-grids-panel" width="50" height="50" margin="0 0 5 0" thickness="1" border-color=".1" pad="2">
|
||||||
<image path="data/ui/grid.png" width="100%" height="100%" align="center" justify="flex-end" mips="true"/>
|
<image path="data/ui/grid.png" width="100%" height="100%" align="center" justify="flex-end" mips="true"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
|
-->
|
||||||
|
|
||||||
</border>
|
</border>
|
||||||
<!-- side bar -->
|
<!-- side bar -->
|
||||||
|
|||||||
@@ -878,7 +878,7 @@ void CanvasModeTransform::enter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto center = zw(canvas->m_box) * 0.5f;
|
auto center = zw(canvas->m_box) * 0.5f;
|
||||||
glm::vec2 bb_sz = glm::vec2(aspect, 1.f) * 100.f;
|
glm::vec2 bb_sz = glm::vec2(aspect, 1.f) * 100.f * App::I.zoom;
|
||||||
glm::vec2 bb_min = center - bb_sz * 0.5f;
|
glm::vec2 bb_min = center - bb_sz * 0.5f;
|
||||||
glm::vec2 bb_max = center + bb_sz * 0.5f;
|
glm::vec2 bb_max = center + bb_sz * 0.5f;
|
||||||
glm::vec2 midpoint = (bb_min + bb_max) * 0.5f;
|
glm::vec2 midpoint = (bb_min + bb_max) * 0.5f;
|
||||||
@@ -1141,48 +1141,17 @@ void CanvasModeTransform::leave()
|
|||||||
poly_cam.reserve(m_points_face[j].size());
|
poly_cam.reserve(m_points_face[j].size());
|
||||||
for (auto p : m_points_face[j])
|
for (auto p : m_points_face[j])
|
||||||
poly_cam.push_back(mv * p.pos);
|
poly_cam.push_back(mv * p.pos);
|
||||||
poly_cam = poly_clip_near(poly_cam, 0.01f);
|
|
||||||
|
auto poly_clipped = poly_clip_near(poly_cam, 0.01f);
|
||||||
|
|
||||||
for (int pi = 0; pi < poly_cam.size(); pi++)
|
for (auto p : poly_clipped)
|
||||||
{
|
{
|
||||||
auto p = poly_cam[pi];
|
|
||||||
|
|
||||||
auto p_clip = proj * glm::vec4(p, 1);
|
auto p_clip = proj * glm::vec4(p, 1);
|
||||||
auto p_norm = p_clip / p_clip.w;
|
|
||||||
|
|
||||||
/*
|
|
||||||
// compute the next point
|
|
||||||
auto p_next = m_points_face[j][(pi + 1) % m_points_face[j].size()];
|
|
||||||
auto p_next_clip = mvp * p_next.pos;
|
|
||||||
auto p_next_norm = p_next_clip / p_next_clip.z;
|
|
||||||
// now test if there's a collision with on of the face edge
|
|
||||||
static glm::vec2 face_corners[4]{ {-1,1}, {1,1}, {1,-1}, {-1,-1} };
|
|
||||||
glm::vec2 poly_seg[2] = { xy(p_norm), xy(p_next_norm) };
|
|
||||||
bool edge_intersection = false;
|
|
||||||
for (int edge_i = 0; edge_i < 4; edge_i++)
|
|
||||||
{
|
|
||||||
glm::vec2 edge[2]{ face_corners[edge_i], face_corners[(edge_i + 1) % 4] };
|
|
||||||
glm::vec2 unused_pt, unused_uv;
|
|
||||||
if (segments_intersect(edge[0], edge[1], poly_seg[0], poly_seg[1], unused_pt, unused_uv))
|
|
||||||
{
|
|
||||||
edge_intersection = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_clip.w < 0 || glm::any(glm::greaterThan(glm::abs(xy(p_norm)), { 1, 1 })))
|
|
||||||
{
|
|
||||||
// now the point is outside, but will its edge cross the face?
|
|
||||||
if (!edge_intersection)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (p_clip.w < 0)
|
if (p_clip.w < 0)
|
||||||
continue;
|
continue;
|
||||||
|
auto p_norm = p_clip / p_clip.w;
|
||||||
poly2d.push_back(p_norm);
|
poly2d.push_back(p_norm);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto clipped = poly_intersect(poly2d, face_corners);
|
auto clipped = poly_intersect(poly2d, face_corners);
|
||||||
|
|||||||
@@ -268,7 +268,9 @@ void NodeCanvas::draw()
|
|||||||
mode->on_Draw(ortho_proj, proj, camera);
|
mode->on_Draw(ortho_proj, proj, camera);
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
if (m_canvas->m_smask_active || m_canvas->m_state == Canvas::kCanvasMode::Transform)
|
auto transform_mode = static_cast<CanvasModeTransform*>(Canvas::modes[(int)Canvas::kCanvasMode::Transform][0]);
|
||||||
|
bool importing = transform_mode->m_action == CanvasModeTransform::ActionType::Import;
|
||||||
|
if (m_canvas->m_smask_active || m_canvas->m_state == Canvas::kCanvasMode::Transform && !importing)
|
||||||
{
|
{
|
||||||
m_canvas->modes[(int)Canvas::kCanvasMode::MaskFree][0]->on_Draw(ortho_proj, proj, camera);
|
m_canvas->modes[(int)Canvas::kCanvasMode::MaskFree][0]->on_Draw(ortho_proj, proj, camera);
|
||||||
m_canvas->modes[(int)Canvas::kCanvasMode::MaskLine][0]->on_Draw(ortho_proj, proj, camera);
|
m_canvas->modes[(int)Canvas::kCanvasMode::MaskLine][0]->on_Draw(ortho_proj, proj, camera);
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ std::vector<T> poly_remove_duplicate(const std::vector<T>& v, const float toller
|
|||||||
std::vector<T> ret;
|
std::vector<T> ret;
|
||||||
for (size_t i = 0; i < v.size(); i++)
|
for (size_t i = 0; i < v.size(); i++)
|
||||||
{
|
{
|
||||||
if (glm::distance2(v[i], v[(i + 1) % v.size()]) > tollerance)
|
//if (glm::distance2(v[i], v[(i + 1) % v.size()]) > tollerance)
|
||||||
|
if (v[i] != v[(i + 1) % v.size()])
|
||||||
ret.push_back(v[i]);
|
ret.push_back(v[i]);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ HCTX WacomTablet::TabletInit(HWND hWnd)
|
|||||||
CHAR* TabletName = new CHAR[wWTInfoRetVal];
|
CHAR* TabletName = new CHAR[wWTInfoRetVal];
|
||||||
wWTInfoRetVal = gpWTInfoA(WTI_DEVICES, DVC_NAME, TabletName);
|
wWTInfoRetVal = gpWTInfoA(WTI_DEVICES, DVC_NAME, TabletName);
|
||||||
LOG("Tablet: %s", TabletName);
|
LOG("Tablet: %s", TabletName);
|
||||||
delete TabletName;
|
delete[] TabletName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user