ShowStrokeLen .Reset( false , "ShowStrokeLen" );
TranspStorke .Reset( false , "TranspStorke" );
- CircleClip = Cursor3DCircleClip::None;
+ SphereClip = SphereClipType::None;
HoleRangeRatio = 0.25f;
CloseFaceMBuf = NULL;
if (!ShowCursor)
return false;
- return CircleClip == Cursor3DCircleClip::Hole;
+ return SphereClip == SphereClipType::Hole;
}
bool Cursor3D::IsHoleRevActive(void) const
if (!ShowCursor)
return false;
- return CircleClip == Cursor3DCircleClip::ShowAround;
+ return SphereClip == SphereClipType::ShowAround;
}
bool Cursor3D::IsCircleClipActive(void) const
if (!ShowCursor)
return false;
- return CircleClip != Cursor3DCircleClip::None;
+ return SphereClip != SphereClipType::None;
}
void Cursor3D::PushStroke(void)
{
Strokes.clear();
}
+
+float Cursor3D::GetSphereClipLen(const lm::range3f& bbox) const
+{
+ return bbox.max_length() * HoleRangeRatio;
+}
}
-enum class Cursor3DCircleClip
+enum class SphereClipType
{
None,
Hole,
void CutStroke(void);
void ClearStroke(void);
+ float GetSphereClipLen(const lm::range3f& bbox) const;
+
public:
NamedValue<bool> ShowCursor;
NamedValue<bool> CursorDepth;
NamedValue<bool> ShowStrokeLen;
NamedValue<bool> TranspStorke;
- Cursor3DCircleClip CircleClip;
+ SphereClipType SphereClip;
float HoleRangeRatio;
lm::vec3f CursorPos;
virtual ~LazyDisp(void)
{
- if(m_State == BeginList)
- {
+ if (m_State == BeginList)
m_Disp->EndList();
- }
}
State CallOrBeginList(void)
{
assert(m_State == None);
- if(m_State != None)
- {
+ if (m_State != None)
throw std::exception("LazyDisp::CallOrBeginList must not call twice");
- }
- if(m_Disp->IsEnable())
+ if (m_Disp->IsEnable())
{
m_Disp->CallList();
return kf;
}
+
+float SceneMain::GetCursorSphereClipLen(void) const
+{
+ return GetCursorSphereClipLen(GetSceneBBox());
+}
+
+float SceneMain::GetCursorSphereClipLen(const lm::range3f& scene_bb) const
+{
+ return m_Cursor3d.GetSphereClipLen(scene_bb);
+}
+
+bool SceneMain::IsOutOfSphereClip(const lm::vec3f& v) const
+{
+ return IsOutOfSphereClip(GetSceneBBox(), v);
+}
+
+bool SceneMain::IsOutOfSphereClip(const lm::range3f& scene_bb, const lm::vec3f& v) const
+{
+ float l = GetCursorSphereClipLen(scene_bb);
+ float lsq = l * l;
+ float dsq = (v - m_Cursor3d.CursorPos).square_length();
+
+ if (m_Cursor3d.SphereClip == SphereClipType::Hole)
+ return (lsq > dsq);
+ if (m_Cursor3d.SphereClip == SphereClipType::ShowAround)
+ return (lsq < dsq);
+
+ return false;
+}
int GetKeyframeMax(void) const;
+ float GetCursorSphereClipLen(void) const;
+ float GetCursorSphereClipLen(const lm::range3f& scene_bb) const;
+ bool IsOutOfSphereClip(const lm::vec3f& v) const;
+ bool IsOutOfSphereClip(const lm::range3f& scene_bb, const lm::vec3f& v) const;
+
private:
void AddObjMeshsToSceneEachObject(const std::string& filename, lib_geo::ObjMesh& obj_mesh, std::vector<lib_geo::BaseMesh>& mesh_ary);
void AddObjMeshsToSceneEachGroup(const std::string& filename, lib_geo::ObjMesh& obj_mesh, std::vector<lib_geo::BaseMesh>& mesh_ary);
ui.checkShowOnlyAroundCursor->setChecked(false);
if (checked)
- m_Scene.m_Cursor3d.CircleClip = Cursor3DCircleClip::Hole;
+ m_Scene.m_Cursor3d.SphereClip = SphereClipType::Hole;
else
- m_Scene.m_Cursor3d.CircleClip = Cursor3DCircleClip::None;
+ m_Scene.m_Cursor3d.SphereClip = SphereClipType::None;
updateView_All();
}
ui.checkHoleAroundCursor->setChecked(false);
if (checked)
- m_Scene.m_Cursor3d.CircleClip = Cursor3DCircleClip::ShowAround;
+ m_Scene.m_Cursor3d.SphereClip = SphereClipType::ShowAround;
else
- m_Scene.m_Cursor3d.CircleClip = Cursor3DCircleClip::None;
+ m_Scene.m_Cursor3d.SphereClip = SphereClipType::None;
updateView_All();
}
-GeometryRender::GeometryRender(MeshBuf* mbuf)
+GeometryRender::GeometryRender(MeshBuf* mbuf) :
+ m_Mesh(mbuf),
+ m_Config(NULL),
+ m_SphereClipType(SphereClipType::None),
+ m_SphereClipDst(0.0f),
+ m_CursorPos(0, 0, 0)
{
- m_Mesh = mbuf;
- m_Config = NULL;
}
GeometryRender::~GeometryRender(void)
}
-void GeometryRender::InitializeRender(View3DConfig* config, ShaderLibrary* shaders)
+void GeometryRender::InitializeGeoRender(View3DConfig* config, ShaderLibrary* shaders, SceneMain* scene)
{
m_Config = config;
m_Shaders = shaders;
+ m_Scene = scene;
m_LastConfig = *config;
}
disp_list.EndList();
}
+bool GeometryRender::CheckSphereClipUpdated(void)
+{
+ Cursor3D& cursor = m_Scene->m_Cursor3d;
+ if (m_SphereClipType != cursor.SphereClip)
+ return true;
+ if (m_SphereClipDst != m_Scene->GetCursorSphereClipLen())
+ return true;
+ if (m_CursorPos != cursor.CursorPos)
+ return true;
+ return false;
+}
+
+void GeometryRender::UpdateSphereClipCache(void)
+{
+ Cursor3D& cursor = m_Scene->m_Cursor3d;
+ m_SphereClipType = cursor.SphereClip;
+ m_SphereClipDst = m_Scene->GetCursorSphereClipLen();
+ m_CursorPos = cursor.CursorPos;
+}
+
void GeometryRender::DrawVert(const lib_geo::BaseMesh& mesh)
{
glPointSize((float)m_Config->m_PointSize);
- glColor3d(0,1,1);
+ glColor3d(0, 1, 1);
+
+ if (CheckSphereClipUpdated())
+ {
+ UpdateSphereClipCache();
+ m_DispList_Vert.ReleaseList();
+ m_DispList_Vid.ReleaseList();
+ }
DrawVertPoint(mesh);
void GeometryRender::DrawVertPoint(const lib_geo::BaseMesh& mesh)
{
LazyDisp ld(m_DispList_Vert);
- if (ld.CallOrBeginList() != LazyDisp::Called)
+ if (ld.CallOrBeginList() == LazyDisp::Called)
+ return;
+
+ lm::range3f scene_bb;
+ if (m_Scene->m_Cursor3d.IsCircleClipActive())
+ scene_bb = m_Scene->GetSceneBBox();
+
+ glBegin(GL_POINTS);
+ for (const lm::vec3f& v : mesh.m_Verts)
{
- glBegin(GL_POINTS);
- for (const lm::vec3f& v : mesh.m_Verts)
+ if (m_Scene->m_Cursor3d.IsCircleClipActive())
{
- glVertex3fv(v.v());
+ if (m_Scene->IsOutOfSphereClip(scene_bb, v))
+ continue;
}
- glEnd();
+
+ glVertex3fv(v.v());
}
+ glEnd();
}
void GeometryRender::DrawVertVid(MeshBuf& mbuf)
if (ld.CallOrBeginList() == LazyDisp::Called)
return;
+ lm::range3f scene_bb;
+ if (m_Scene->m_Cursor3d.IsCircleClipActive())
+ scene_bb = m_Scene->GetSceneBBox();
+
for (size_t i = 0; i < m.m_Verts.size(); ++i)
{
const lm::vec3f& v0 = m.m_Verts[i];
const lm::vec3f& n = m.m_VertAdj[i].m_NormalAvg;
const lm::vec3f& v1 = v0 + n * m_Config->m_IndexLineLen;
+ if (m_Scene->m_Cursor3d.IsCircleClipActive())
+ {
+ if (m_Scene->IsOutOfSphereClip(scene_bb, v0))
+ continue;
+ }
+
std::ostringstream s;
s << " " << i;
GeometryRender(MeshBuf* mbuf);
virtual ~GeometryRender(void);
- void InitializeRender(View3DConfig* config, ShaderLibrary* shaders);
+ void InitializeGeoRender(View3DConfig* config, ShaderLibrary* shaders, SceneMain* scene);
void ReleaseAccBuffer(void);
GeometryRender(const GeometryRender&) {}
void operator=(const GeometryRender&) {}
+ bool CheckSphereClipUpdated(void);
+ void UpdateSphereClipCache(void);
+
private:
+ SceneMain* m_Scene;
MeshBuf* m_Mesh;
View3DConfig* m_Config;
ShaderLibrary* m_Shaders;
lib_gl::GlDisplayList m_DispList_Fid;
std::map<int, GeometryVBO> m_FaceGroupVBO;
+
+ SphereClipType m_SphereClipType;
+ float m_SphereClipDst;
+ lm::vec3f m_CursorPos;
};
glUniform1i(m_EnableHoleRev, cursor.IsHoleRevActive());
if (cursor.IsCircleClipActive())
{
- float hole_range = scene->GetSceneBBox().max_length() * cursor.HoleRangeRatio;
+ float hole_range = scene->GetCursorSphereClipLen();
lm::vec3f cp = cursor.CursorPos;
glUniform3f(m_HolePos, cp.x, cp.y, cp.z);
glUniform1f(m_HoleRange, hole_range);
const MeshBuf* cm = const_cast<const MeshBuf*>(mbuf);
rm.insert(cm, new_render);
- new_render->InitializeRender(&m_Config, &m_ShaderLib);
+ new_render->InitializeGeoRender(&m_Config, &m_ShaderLib, m_Scene);
return *new_render;
}