|
|
@@ -270,66 +270,44 @@ void DebugDrawer::drawGrid()
|
|
|
//==============================================================================
|
|
|
void DebugDrawer::drawSphere(F32 radius, I complexity)
|
|
|
{
|
|
|
-#if 0
|
|
|
- Vector<Vec3>* sphereLines;
|
|
|
+#if 1
|
|
|
+ Mat4 oldMMat = m_mMat;
|
|
|
+ Mat4 oldVpMat = m_vpMat;
|
|
|
+
|
|
|
+ setModelMatrix(m_mMat * Mat4(Vec4(0.0, 0.0, 0.0, 1.0),
|
|
|
+ Mat3::getIdentity(), radius));
|
|
|
+
|
|
|
+ begin(GL_LINES);
|
|
|
|
|
|
// Pre-calculate the sphere points5
|
|
|
- //
|
|
|
- std::unordered_map<U32, Vector<Vec3>>::iterator it =
|
|
|
- m_complexityToPreCalculatedSphere.find(complexity);
|
|
|
+ F32 fi = getPi<F32>() / complexity;
|
|
|
|
|
|
- if(it != m_complexityToPreCalculatedSphere.end()) // Found
|
|
|
- {
|
|
|
- sphereLines = &(it->second);
|
|
|
- }
|
|
|
- else // Not found
|
|
|
+ Vec3 prev(1.0, 0.0, 0.0);
|
|
|
+ for(F32 th = fi; th < getPi<F32>() * 2.0 + fi; th += fi)
|
|
|
{
|
|
|
- m_complexityToPreCalculatedSphere[complexity] = Vector<Vec3>();
|
|
|
- sphereLines = &m_complexityToPreCalculatedSphere[complexity];
|
|
|
+ Vec3 p = Mat3(Euler(0.0, th, 0.0)) * Vec3(1.0, 0.0, 0.0);
|
|
|
|
|
|
- F32 fi = getPi<F32>() / complexity;
|
|
|
-
|
|
|
- Vec3 prev(1.0, 0.0, 0.0);
|
|
|
- for(F32 th = fi; th < getPi<F32>() * 2.0 + fi; th += fi)
|
|
|
+ for(F32 th2 = 0.0; th2 < getPi<F32>(); th2 += fi)
|
|
|
{
|
|
|
- Vec3 p = Mat3(Euler(0.0, th, 0.0)) * Vec3(1.0, 0.0, 0.0);
|
|
|
-
|
|
|
- for(F32 th2 = 0.0; th2 < getPi<F32>(); th2 += fi)
|
|
|
- {
|
|
|
- Mat3 rot(Euler(th2, 0.0, 0.0));
|
|
|
+ Mat3 rot(Euler(th2, 0.0, 0.0));
|
|
|
|
|
|
- Vec3 rotPrev = rot * prev;
|
|
|
- Vec3 rotP = rot * p;
|
|
|
+ Vec3 rotPrev = rot * prev;
|
|
|
+ Vec3 rotP = rot * p;
|
|
|
|
|
|
- sphereLines->push_back(rotPrev);
|
|
|
- sphereLines->push_back(rotP);
|
|
|
+ pushBackVertex(rotPrev);
|
|
|
+ pushBackVertex(rotP);
|
|
|
|
|
|
- Mat3 rot2(Euler(0.0, 0.0, getPi<F32>() / 2));
|
|
|
+ Mat3 rot2(Euler(0.0, 0.0, getPi<F32>() / 2));
|
|
|
|
|
|
- sphereLines->push_back(rot2 * rotPrev);
|
|
|
- sphereLines->push_back(rot2 * rotP);
|
|
|
- }
|
|
|
-
|
|
|
- prev = p;
|
|
|
+ pushBackVertex(rot2 * rotPrev);
|
|
|
+ pushBackVertex(rot2 * rotP);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // Render
|
|
|
- //
|
|
|
- Mat4 oldMMat = m_mMat;
|
|
|
- Mat4 oldVpMat = m_vpMat;
|
|
|
|
|
|
- setModelMatrix(m_mMat * Mat4(Vec4(0.0, 0.0, 0.0, 1.0),
|
|
|
- Mat3::getIdentity(), radius));
|
|
|
-
|
|
|
- begin(GL_LINES);
|
|
|
- for(const Vec3& p : *sphereLines)
|
|
|
- {
|
|
|
- pushBackVertex(p);
|
|
|
+ prev = p;
|
|
|
}
|
|
|
+
|
|
|
end();
|
|
|
|
|
|
- // restore
|
|
|
m_mMat = oldMMat;
|
|
|
m_vpMat = oldVpMat;
|
|
|
#endif
|