]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/patch.cpp
Fixed map not starting after compile in Enemy-Territory.
[xonotic/netradiant.git] / radiant / patch.cpp
index a9e452d91655ae90d677eb1bba04354272e36c87..5b2622bb201c78de903a782c344df5f77e99058e 100644 (file)
@@ -776,7 +776,15 @@ void Patch::InsertPoints(EMatrixMajor mt, bool bFirst)
   std::size_t pos = 0;
   {
     PatchControl* p1 = m_ctrl.data();
-    for(std::size_t w = 0; w != width; ++w, p1 += col_stride)
+       /*
+         if(GlobalSelectionSystem().countSelected() != 0) 
+         {  
+                 scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
+                 PatchInstance* patch = Instance_getPatch(instance);
+                 patch->m_selectable.isSelected();
+         }
+       */
+       for(std::size_t w = 0; w != width; ++w, p1 += col_stride)
     {
       {
         PatchControl* p2 = p1;
@@ -831,7 +839,15 @@ void Patch::InsertPoints(EMatrixMajor mt, bool bFirst)
     ERROR_MESSAGE("neither row-major nor column-major");
     return;
   }
-
+    if(bFirst)
+    {
+               pos = height - 1;
+    }
+    else
+    {
+               pos = 2;
+    }
+       
   if(pos >= height)
   {
     if(bFirst)
@@ -978,7 +994,14 @@ void Patch::RemovePoints(EMatrixMajor mt, bool bFirst)
     ERROR_MESSAGE("neither row-major nor column-major");
     return;
   }
-
+    if(bFirst)
+    {
+               pos=height-3;
+    }
+    else
+    {
+               pos=2;
+    }
   if(pos >= height)
   {
     if(bFirst)
@@ -1377,6 +1400,90 @@ void Patch::ConstructPrefab(const AABB& aabb, EPatchPrefab eType, int axis, std:
       return;
     }
   }
+  else if (eType == eXactCylinder)
+  {
+       int n = (width - 1) / 2; // n = number of segments
+       setDims(width, height);
+
+       // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents);
+       // vPos[1] = aabb.origin;
+       // vPos[2] = vector3_added(aabb.origin, aabb.extents);
+
+       int i, j;
+       float f = 1 / cos(M_PI / n);
+       for(i = 0; i < width; ++i)
+       {
+               float angle = (M_PI * i) / n; // 0 to 2pi
+               float x = vPos[1][0] + (vPos[2][0] - vPos[1][0]) * cos(angle) * ((i&1) ? f : 1.0f);
+               float y = vPos[1][1] + (vPos[2][1] - vPos[1][1]) * sin(angle) * ((i&1) ? f : 1.0f);
+               for(j = 0; j < height; ++j)
+               {
+                       float z = vPos[0][2] + (vPos[2][2] - vPos[0][2]) * (j / (float)(height - 1));
+                       PatchControl *v;
+                       v = &m_ctrl.data()[j*width+i];
+                       v->m_vertex[0] = x;
+                       v->m_vertex[1] = y;
+                       v->m_vertex[2] = z;
+               }
+       }
+  }
+  else if (eType == eXactCone)
+  {
+       int n = (width - 1) / 2; // n = number of segments
+       setDims(width, height);
+
+       // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents);
+       // vPos[1] = aabb.origin;
+       // vPos[2] = vector3_added(aabb.origin, aabb.extents);
+
+       int i, j;
+       float f = 1 / cos(M_PI / n);
+       for(i = 0; i < width; ++i)
+       {
+               float angle = (M_PI * i) / n;
+               for(j = 0; j < height; ++j)
+               {
+                       float x = vPos[1][0] + (1.0f - (j / (float)(height - 1))) * (vPos[2][0] - vPos[1][0]) * cos(angle) * ((i&1) ? f : 1.0f);
+                       float y = vPos[1][1] + (1.0f - (j / (float)(height - 1))) * (vPos[2][1] - vPos[1][1]) * sin(angle) * ((i&1) ? f : 1.0f);
+                       float z = vPos[0][2] + (vPos[2][2] - vPos[0][2]) * (j / (float)(height - 1));
+                       PatchControl *v;
+                       v = &m_ctrl.data()[j*width+i];
+                       v->m_vertex[0] = x;
+                       v->m_vertex[1] = y;
+                       v->m_vertex[2] = z;
+               }
+       }
+  }
+  else if (eType == eXactSphere)
+  {
+       int n = (width - 1) / 2; // n = number of segments (yaw)
+       int m = (height - 1) / 2; // m = number of segments (pitch)
+       setDims(width, height);
+
+       // vPos[0] = vector3_subtracted(aabb.origin, aabb.extents);
+       // vPos[1] = aabb.origin;
+       // vPos[2] = vector3_added(aabb.origin, aabb.extents);
+
+       int i, j;
+       float f = 1 / cos(M_PI / n);
+       float g = 1 / cos(M_PI / (2*m));
+       for(i = 0; i < width; ++i)
+       {
+               float angle = (M_PI * i) / n;
+               for(j = 0; j < height; ++j)
+               {
+                       float angle2 = (M_PI * j) / (2*m);
+                       float x = vPos[1][0] + (vPos[2][0] - vPos[1][0]) *  sin(angle2) * ((j&1) ? g : 1.0f) * cos(angle) * ((i&1) ? f : 1.0f);
+                       float y = vPos[1][1] + (vPos[2][1] - vPos[1][1]) *  sin(angle2) * ((j&1) ? g : 1.0f) * sin(angle) * ((i&1) ? f : 1.0f);
+                       float z = vPos[1][2] + (vPos[2][2] - vPos[1][2]) * -cos(angle2) * ((j&1) ? g : 1.0f);
+                       PatchControl *v;
+                       v = &m_ctrl.data()[j*width+i];
+                       v->m_vertex[0] = x;
+                       v->m_vertex[1] = y;
+                       v->m_vertex[2] = z;
+               }
+       }
+  }
   else if  (eType == eBevel)
   {
     unsigned char *pIndex;