refactored plugin api; refactored callback library; added signals library
[xonotic/netradiant.git] / radiant / brushmodule.cpp
index ae9d812..e289f3c 100644 (file)
@@ -157,6 +157,21 @@ void Brush_clipperColourChanged()
   BrushClipPlane::constructStatic();
 }
 
+void BrushFaceData_fromFace(const BrushFaceDataCallback& callback, Face& face)
+{
+  _QERFaceData faceData;
+  faceData.m_p0 = face.getPlane().planePoints()[0];
+  faceData.m_p1 = face.getPlane().planePoints()[1];
+  faceData.m_p2 = face.getPlane().planePoints()[2];
+  faceData.m_shader = face.GetShader();
+  faceData.m_texdef = face.getTexdef().m_projection.m_texdef;
+  faceData.contents = face.getShader().m_flags.m_contentFlags;
+  faceData.flags = face.getShader().m_flags.m_surfaceFlags;
+  faceData.value = face.getShader().m_flags.m_value;
+  callback(faceData);
+}
+typedef ConstReferenceCaller1<BrushFaceDataCallback, Face&, BrushFaceData_fromFace> BrushFaceDataFromFaceCaller;
+typedef Callback1<Face&> FaceCallback;
 
 class Quake3BrushCreator : public BrushCreator
 {
@@ -169,6 +184,14 @@ public:
   {
     return g_useAlternativeTextureProjection.m_value;
   }
+  void forEachBrushFace(scene::Node& brush, const BrushFaceDataCallback& callback)
+  {
+    Brush_forEachFace(*Node_getBrush(brush), FaceCallback(BrushFaceDataFromFaceCaller(callback)));
+  }
+  bool addBrushFace(scene::Node& brush, const _QERFaceData& faceData)
+  {
+    return Node_getBrush(brush)->addPlane(faceData.m_p0, faceData.m_p1, faceData.m_p2, faceData.m_shader, TextureProjection(faceData.m_texdef, brushprimit_texdef_t(), Vector3(0, 0, 0), Vector3(0, 0, 0))) != 0;
+  }
 };
 
 Quake3BrushCreator g_Quake3BrushCreator;