Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/bsp')
-rwxr-xr-xintern/bsp/extern/CSG_BooleanOps.h73
-rw-r--r--intern/bsp/intern/BSP_CSGHelper.cpp443
-rw-r--r--intern/bsp/intern/BSP_CSGHelper.h99
-rwxr-xr-xintern/bsp/intern/BSP_CSGISplitter.h117
-rwxr-xr-xintern/bsp/intern/BSP_CSGMesh.cpp248
-rwxr-xr-xintern/bsp/intern/BSP_CSGMesh.h95
-rwxr-xr-xintern/bsp/intern/BSP_CSGMeshBuilder.cpp156
-rwxr-xr-xintern/bsp/intern/BSP_CSGMeshBuilder.h74
-rwxr-xr-xintern/bsp/intern/BSP_CSGMeshSplitter.cpp719
-rwxr-xr-xintern/bsp/intern/BSP_CSGMeshSplitter.h205
-rwxr-xr-xintern/bsp/intern/BSP_CSGMesh_CFIterator.h74
-rwxr-xr-xintern/bsp/intern/BSP_CSGNCMeshSplitter.cpp245
-rwxr-xr-xintern/bsp/intern/BSP_CSGNCMeshSplitter.h138
-rwxr-xr-xintern/bsp/intern/BSP_CSGUserData.cpp137
-rwxr-xr-xintern/bsp/intern/BSP_CSGUserData.h136
-rwxr-xr-xintern/bsp/intern/BSP_FragNode.cpp317
-rwxr-xr-xintern/bsp/intern/BSP_FragNode.h125
-rwxr-xr-xintern/bsp/intern/BSP_FragTree.cpp317
-rwxr-xr-xintern/bsp/intern/BSP_FragTree.h141
-rwxr-xr-xintern/bsp/intern/BSP_MeshFragment.cpp281
-rwxr-xr-xintern/bsp/intern/BSP_MeshFragment.h152
-rwxr-xr-xintern/bsp/intern/BSP_MeshPrimitives.cpp8
-rw-r--r--intern/bsp/intern/BSP_MeshPrimitives.h12
-rwxr-xr-xintern/bsp/intern/BSP_Triangulate.cpp254
-rwxr-xr-xintern/bsp/intern/BSP_Triangulate.h130
-rwxr-xr-xintern/bsp/intern/CSG_BooleanOps.cpp56
26 files changed, 28 insertions, 4724 deletions
diff --git a/intern/bsp/extern/CSG_BooleanOps.h b/intern/bsp/extern/CSG_BooleanOps.h
index 418b81a62b3..1e862568cda 100755
--- a/intern/bsp/extern/CSG_BooleanOps.h
+++ b/intern/bsp/extern/CSG_BooleanOps.h
@@ -62,9 +62,7 @@ extern "C" {
typedef struct {
int vertex_index[4];
int vertex_number;
-
- void *user_face_vertex_data[4];
- void *user_face_data;
+ int orig_face;
} CSG_IFace;
/**
@@ -82,22 +80,6 @@ typedef struct {
*/
/**
- * Descibes the data stored in a mesh available through the
- * CSG_IFace interface.
- * user_data_size is the number of bytes of user_data associated with each CSG_IFace
- * user_face_vertex_data size is the number of bytes of user data associated with
- * every face vertex tuple.
- * .
- */
-
-typedef struct CSG_MeshPropertyDescriptor{
- unsigned int user_face_vertex_data_size;
- unsigned int user_data_size;
-} CSG_MeshPropertyDescriptor;
-
-
-
-/**
* @section Iterator abstraction.
*
* The CSG module asks blender to fill in an instance of the above
@@ -180,22 +162,6 @@ typedef struct CSG_VertexIteratorDescriptor {
* // deal with low memory exception
* }
*
- * // Describe each mesh operand to the module.
- * // NOTE: example properties!
- * CSG_MeshPropertyDescriptor propA,propB;
- * propA.user_data_size = 0;
- * propA.user_face_vertex_data = 0;
- * propB.user_face_vertex_data = 0;
- * propB.user_data_size = 0;
- *
- * // Get the output properties of the mesh.
- * CSG_MeshPropertyDescriptor output_properties;
- * output_properties = CSG_DescibeOperands(
- * operation,
- * propA,
- * propB
- * );
- *
* // Report to the user if they will loose any data!
* ...
*
@@ -304,40 +270,6 @@ CSG_NewBooleanFunction(
);
/**
- * Describe the operands of a boolean function to the module.
- * The description takes the form of a pair of CSG_MeshPropertyDescriptors
- * one for each input mesh. The operands do not have to have the same
- * properties, for example operandA may have vertex colours but operandB none.
- * In this case the CSG module will choose the lowest common denominator in
- * mesh properies. The function returns a description of
- * the output mesh. You can use this to warn the user that certain properties
- * will be lost. Of course it also describes what fields in the output mesh
- * will contain valid data.
- */
- CSG_MeshPropertyDescriptor
-CSG_DescibeOperands(
- CSG_BooleanOperation * operation,
- CSG_MeshPropertyDescriptor operandA_desciption,
- CSG_MeshPropertyDescriptor operandB_desciption
-);
-
-/**
- * The user data is handled by the BSP modules through
- * the following function which is called whenever the
- * module needs new face vertex properties (when a face is split).
- * d1,d2 are pointers to existing vertex face data. dnew is
- * a pointer to an allocated but unfilled area of user data of
- * size user_face_vertex_data_size in the CSG_MeshPropertyDescriptor
- * returned by a call to the above function. Epsilon is the relative
- * distance (between [0,1]) of the new vertex and the vertex associated
- * with d1. Use epsilon to interpolate the face vertex data in d1 and d2
- * and fill dnew
- */
-
-typedef int (*CSG_InterpolateUserFaceVertexDataFunc)(void *d1, void * d2, void *dnew, float epsilon);
-
-
-/**
* Attempt to perform a boolean operation between the 2 objects of the
* desired type. This may fail due to an internal error or lack of memory.
* In this case 0 is returned, otehrwise 1 is returned indicating success.
@@ -359,8 +291,7 @@ CSG_PerformBooleanOperation(
CSG_FaceIteratorDescriptor obAFaces,
CSG_VertexIteratorDescriptor obAVertices,
CSG_FaceIteratorDescriptor obBFaces,
- CSG_VertexIteratorDescriptor obBVertices,
- CSG_InterpolateUserFaceVertexDataFunc interp_func
+ CSG_VertexIteratorDescriptor obBVertices
);
/**
diff --git a/intern/bsp/intern/BSP_CSGHelper.cpp b/intern/bsp/intern/BSP_CSGHelper.cpp
deleted file mode 100644
index 9c686828a23..00000000000
--- a/intern/bsp/intern/BSP_CSGHelper.cpp
+++ /dev/null
@@ -1,443 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BSP_CSGHelper.h"
-
-#include "BSP_CSGMesh.h"
-#include "BSP_MeshFragment.h"
-#include "BSP_FragTree.h"
-#include "BSP_CSGMeshSplitter.h"
-#include "BSP_CSGNCMeshSplitter.h"
-#include "BSP_Triangulate.h"
-
-#include "MEM_SmartPtr.h"
-
-
-#include "stdio.h"
-
-
-using namespace std;
-
-BSP_CSGHelper::
-BSP_CSGHelper(
-)
-{
- // nothing to do
-}
-
- bool
-BSP_CSGHelper::
-ComputeOp(
- BSP_CSGMesh * obA,
- BSP_CSGMesh * obB,
- BSP_OperationType op_type,
- BSP_CSGMesh & output,
- CSG_InterpolateUserFaceVertexDataFunc fv_func
-){
-
-
- printf( "*** ComputeOp ***\n" );
-
-
- // First work out which parts of polygons we want to keep as we pass stuff
- // down the tree.
-
- BSP_Classification e_ATreeB,e_BTreeA;
- bool invertA(false),invertB(false);
-
- switch (op_type) {
- case e_intern_csg_union :
- e_ATreeB = e_classified_out;
- e_BTreeA = e_classified_out;
- break;
- case e_intern_csg_intersection :
- e_ATreeB = e_classified_in;
- e_BTreeA = e_classified_in;
- break;
- case e_intern_csg_difference :
- invertA = true;
- e_ATreeB = e_classified_in;
- e_BTreeA = e_classified_in;
- break;
- default :
- return false;
- }
-
- if (invertA) {
- obA->Invert();
- }
-
- if (invertB) {
- obB->Invert();
- }
-
- MEM_SmartPtr<BSP_CSGMesh> obA_copy = obA->NewCopy();
- MEM_SmartPtr<BSP_CSGMesh> obB_copy = obB->NewCopy();
-
- // ok we need yet another copy...
-
- MEM_SmartPtr<BSP_CSGMesh> obA_copy2 = obA->NewCopy();
- MEM_SmartPtr<BSP_CSGMesh> obB_copy2 = obB->NewCopy();
-
- obA_copy->BuildEdges();
- obB_copy->BuildEdges();
-
- // Create a splitter to help chop up the mesh and preserrve.
- // mesh connectivity
-
- MEM_SmartPtr<BSP_CSGMeshSplitter> splitter = new BSP_CSGMeshSplitter(fv_func);
- if (splitter == NULL) return false;
-
- // Create a splitter to help chop the mesh for tree building.
- MEM_SmartPtr<BSP_CSGNCMeshSplitter> nc_splitter = new BSP_CSGNCMeshSplitter();
-
- if (splitter == NULL || nc_splitter == NULL) return false;
-
- // Create a tree for both meshes.
-
- MEM_SmartPtr<BSP_FragTree> treeA = treeA->New(obA,nc_splitter.Ref());
- MEM_SmartPtr<BSP_FragTree> treeB = treeB->New(obB,nc_splitter.Ref());
-
- if (treeA == NULL || treeB == NULL) {
- return false;
- }
-
- // Classify each object wrt the other tree.
-
- MEM_SmartPtr<BSP_MeshFragment> AinB = new BSP_MeshFragment(obA_copy2,e_classified_in);
- MEM_SmartPtr<BSP_MeshFragment> AoutB = new BSP_MeshFragment(obA_copy2,e_classified_out);
- MEM_SmartPtr<BSP_MeshFragment> AonB = new BSP_MeshFragment(obA_copy2,e_classified_on);
-
- treeB->Classify(obA_copy2,AinB,AoutB,AonB,nc_splitter.Ref());
-
- MEM_SmartPtr<BSP_MeshFragment> BinA = new BSP_MeshFragment(obB_copy2,e_classified_in);
- MEM_SmartPtr<BSP_MeshFragment> BoutA = new BSP_MeshFragment(obB_copy2,e_classified_out);
- MEM_SmartPtr<BSP_MeshFragment> BonA = new BSP_MeshFragment(obB_copy2,e_classified_on);
-
- treeA->Classify(obB_copy2,BinA,BoutA,BonA,nc_splitter.Ref());
-
- // Now we need to work what were the spanning polygons from the original mesh.
- // Build a spanning fragment from them and pass split those mothers.
-
- MEM_SmartPtr<BSP_MeshFragment> frag_BTreeA2 = new BSP_MeshFragment(obA_copy,e_BTreeA);
- MEM_SmartPtr<BSP_MeshFragment> AspanningB = new BSP_MeshFragment(obA_copy,e_classified_spanning);
-
- TranslateSplitFragments(AinB.Ref(),AoutB.Ref(),AonB.Ref(),e_BTreeA,AspanningB.Ref(),frag_BTreeA2.Ref());
-
- MEM_SmartPtr<BSP_MeshFragment> frag_ATreeB2 = new BSP_MeshFragment(obB_copy,e_ATreeB);
- MEM_SmartPtr<BSP_MeshFragment> BspanningA = new BSP_MeshFragment(obB_copy,e_classified_spanning);
-
- TranslateSplitFragments(BinA.Ref(),BoutA.Ref(),BonA.Ref(),e_ATreeB,BspanningA.Ref(),frag_ATreeB2.Ref());
-
-
- MEM_SmartPtr<BSP_MeshFragment> frag_ATreeB = new BSP_MeshFragment(obB_copy,e_ATreeB);
- MEM_SmartPtr<BSP_MeshFragment> frag_BTreeA = new BSP_MeshFragment(obA_copy,e_BTreeA);
-
- if (frag_ATreeB == NULL || frag_BTreeA == NULL) return false;
-
- // Pass the spanning polygons of copyB through the tree of copyA.
- treeA->Push(BspanningA,frag_ATreeB,e_ATreeB,e_classified_spanning,true,splitter.Ref());
-
- // Add the result of the push to the fragments we are interested in.
- MergeFrags(frag_ATreeB2.Ref(),frag_ATreeB.Ref());
-
- // Pass the spanning polygons of copyA through the tree of copyB
- treeB->Push(AspanningB,frag_BTreeA,e_BTreeA,e_classified_spanning,false,splitter.Ref());
- MergeFrags(frag_BTreeA2.Ref(),frag_BTreeA.Ref());
-
- // Copy the fragments into a new mesh.
- DuplicateMesh(frag_ATreeB.Ref(),output);
- DuplicateMesh(frag_BTreeA.Ref(),output);
-
- return true;
-
-};
-
- void
-BSP_CSGHelper::
-TranslateSplitFragments(
- const BSP_MeshFragment & in_frag,
- const BSP_MeshFragment & out_frag,
- const BSP_MeshFragment & on_frag,
- BSP_Classification keep,
- BSP_MeshFragment & spanning_frag,
- BSP_MeshFragment & output
-){
-
- // iterate through the 3 input fragments
- // tag the polygons in the output fragments according to
- // the classification of the input frags.
-
- const BSP_CSGMesh *i_mesh = in_frag.Mesh();
- BSP_CSGMesh *o_mesh = output.Mesh();
-
- const vector<BSP_MFace> &i_faces = i_mesh->FaceSet();
- vector<BSP_MFace> &o_faces = o_mesh->FaceSet();
-
- vector<BSP_FaceInd>::const_iterator if_it = in_frag.FaceSet().begin();
- vector<BSP_FaceInd>::const_iterator if_end = in_frag.FaceSet().end();
-
- for (;if_it != if_end; ++if_it) {
- int original_index = i_faces[*if_it].OpenTag();
- if (original_index == -1) {
- // then this face was never split and the original_index is
- // the actual face index.
- original_index = *if_it;
- }
- // tag the output faces with the in flag.
- if (o_faces[original_index].OpenTag() == -1) {
- o_faces[original_index].SetOpenTag(0);
- }
- o_faces[original_index].SetOpenTag(
- o_faces[original_index].OpenTag() | e_classified_in
- );
- }
-
- // same for out fragments.
- if_it = out_frag.FaceSet().begin();
- if_end = out_frag.FaceSet().end();
-
- for (;if_it != if_end; ++if_it) {
- int original_index = i_faces[*if_it].OpenTag();
- if (original_index == -1) {
- // then this face was never split and the original_index is
- // the actual face index.
- original_index = *if_it;
- }
- // tag the output faces with the in flag.
- if (o_faces[original_index].OpenTag() == -1) {
- o_faces[original_index].SetOpenTag(0);
- }
- o_faces[original_index].SetOpenTag(
- o_faces[original_index].OpenTag() | e_classified_out
- );
- }
-
- // on fragments just get set as spanning for now.
-
- if_it = on_frag.FaceSet().begin();
- if_end = on_frag.FaceSet().end();
-
- for (;if_it != if_end; ++if_it) {
- int original_index = i_faces[*if_it].OpenTag();
- if (original_index == -1) {
- // then this face was never split and the original_index is
- // the actual face index.
- original_index = *if_it;
- }
- // tag the output faces with the in flag.
- if (o_faces[original_index].OpenTag() == -1) {
- o_faces[original_index].SetOpenTag(0);
- }
- o_faces[original_index].SetOpenTag(
- o_faces[original_index].OpenTag() | e_classified_spanning
- );
- }
- // now run through the output faces.
- // collect the ones we are interested in into output
- // and collect the spanning faces.
-
- int of_it = 0;
- int of_size = o_faces.size();
-
- for (;of_it < of_size; ++of_it) {
-
- int p_class = o_faces[of_it].OpenTag();
-
- if (p_class == int(keep)) {
- output.FaceSet().push_back(BSP_FaceInd(of_it));
- } else
- if (
- (p_class == (e_classified_in | e_classified_out)) ||
- p_class == e_classified_spanning
- ) {
- spanning_frag.FaceSet().push_back(BSP_FaceInd(of_it));
- }
- }
-}
-
-
- void
-BSP_CSGHelper::
-MergeFrags(
- const BSP_MeshFragment & in,
- BSP_MeshFragment & out
-){
-
- // Add the 2 frags together.
-
- out.FaceSet().insert(
- out.FaceSet().end(),
- in.FaceSet().begin(),
- in.FaceSet().end()
- );
-}
-
-
-
-BSP_CSGHelper::
-~BSP_CSGHelper(
-){
- // nothing to do
-}
-
- void
-BSP_CSGHelper::
-DuplicateMesh(
- const BSP_MeshFragment & frag,
- BSP_CSGMesh & output
-){
-
- // This stuff is a real waste of time.
- // much better to create an output iterator based upon
- // the 2 mesh fragments alone.
-
- vector<BSP_MVertex> & o_verts = output.VertexSet();
- BSP_CSGUserData & o_fv_data = output.FaceVertexData();
- BSP_CSGUserData & o_f_data = output.FaceData();
-
- // A temporary buffer containing the triangulated
- // vertex indices.
-
- vector<int> triangle_indices;
-
- BSP_CSGMesh * i_mesh = frag.Mesh();
-
- if (i_mesh == NULL) return;
-
- vector<BSP_MVertex> & i_verts = i_mesh->VertexSet();
- const vector<BSP_MFace> & i_faces = i_mesh->FaceSet();
- BSP_CSGUserData & i_fv_data = i_mesh->FaceVertexData();
- BSP_CSGUserData & i_f_data = i_mesh->FaceData();
-
- // iterate through the fragment's face set
- const vector<BSP_FaceInd> & frag_faces = frag.FaceSet();
-
- vector<BSP_FaceInd>::const_iterator f_faces_it = frag_faces.begin();
- vector<BSP_FaceInd>::const_iterator f_faces_end = frag_faces.end();
-
- // We need to keep track of which vertices we are selecting.
- vector<int> selected_vi;
-
- BSP_Triangulate triangulator;
-
- for (; f_faces_it != f_faces_end; ++f_faces_it) {
-
- BSP_FaceInd fi = *f_faces_it;
- const BSP_MFace &face = i_faces[fi];
-
- // duplicate the face
- BSP_MFace dup_face(face);
-
- // iterate through the face's vertex indices.
- vector<BSP_VertexInd>::iterator dup_f_verts_it = dup_face.m_verts.begin();
- vector<BSP_VertexInd>::const_iterator dup_f_verts_end = dup_face.m_verts.end();
-
- for (; dup_f_verts_it != dup_f_verts_end; ++dup_f_verts_it) {
-
- if (i_verts[*dup_f_verts_it].SelectTag() == false) {
- // copy this vertex onto the output mesh vertex array.
-
- BSP_VertexInd new_vi(o_verts.size());
- o_verts.push_back(i_verts[*dup_f_verts_it]);
-
- // should kill the old vertices edge ptrs.
- o_verts[new_vi].m_edges.clear();
-
- // set the open tag in the old vert to the new one.
- i_verts[*dup_f_verts_it].SetOpenTag(new_vi);
-
- // select the old vertex
- i_verts[*dup_f_verts_it].SetSelectTag(true);
- selected_vi.push_back(*dup_f_verts_it);
- }
-
- // we have been to this vertex before and there should be
- // a corresponding vertex in the new mesh vertex set.
- *dup_f_verts_it = i_verts[*dup_f_verts_it].OpenTag();
- }
-
- // duplicate the face vertex data for this polygon.
-
- vector<BSP_UserFVInd>::iterator dup_fv_it = dup_face.m_fv_data.begin();
- vector<BSP_UserFVInd>::const_iterator dup_fv_end = dup_face.m_fv_data.end();
-
- for (;dup_fv_it != dup_fv_end; ++dup_fv_it) {
- *dup_fv_it = o_fv_data.Duplicate(i_fv_data[int(*dup_fv_it)]);
- }
-
- triangle_indices.clear();
-
- // Now triangulate the polygon.
- if (!triangulator.Process(
- o_verts,
- dup_face.m_verts,
- dup_face.m_plane,
- triangle_indices
- )) {
- // Sometimes the triangulator can fail for very small
- // polygons or very thing polygons. This should be
- // handled more elegantly but for now we just leave out the
- // polygon from the mesh.
- continue;
- }
-
- // Run through the result and add in the triangle faces.
-
- unsigned int i;
- for (i = 0; i < triangle_indices.size(); i+=3) {
- // duplicate the face data for this face.
- o_f_data.Duplicate(i_f_data[*f_faces_it]);
-
- output.AddSubTriangle(dup_face,&triangle_indices[i]);
- }
- }
-
- // of course we have to deselect the vertices again.
-
- vector<int>::const_iterator selected_vi_it = selected_vi.begin();
- vector<int>::const_iterator selected_vi_end = selected_vi.end();
-
- for (; selected_vi_it != selected_vi_end; ++selected_vi_it) {
- i_verts[*selected_vi_it].SetSelectTag(false);
- }
-}
-
-
-
-
-
-
-
diff --git a/intern/bsp/intern/BSP_CSGHelper.h b/intern/bsp/intern/BSP_CSGHelper.h
deleted file mode 100644
index b6b88422358..00000000000
--- a/intern/bsp/intern/BSP_CSGHelper.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSP_CSGHELPER_H
-#define BSP_CSGHELPER_H
-
-class BSP_CSGMesh;
-class BSP_MeshFragment;
-
-#include "../extern/CSG_BooleanOps.h"
-#include "BSP_MeshPrimitives.h"
-
-enum BSP_OperationType{
- e_intern_csg_union,
- e_intern_csg_intersection,
- e_intern_csg_difference
-};
-
-class BSP_CSGHelper {
-public :
-
- BSP_CSGHelper(
- );
-
- bool
- ComputeOp(
- BSP_CSGMesh * obA,
- BSP_CSGMesh * obB,
- BSP_OperationType op_type,
- BSP_CSGMesh & output,
- CSG_InterpolateUserFaceVertexDataFunc fv_func
- );
-
-
- ~BSP_CSGHelper(
- );
-
-private:
-
- // Iterate through the fragment,
- // add new vertices to output,
- // map polygons to new vertices.
-
- void
- DuplicateMesh(
- const BSP_MeshFragment & frag,
- BSP_CSGMesh & output
- );
-
- void
- TranslateSplitFragments(
- const BSP_MeshFragment & in_frag,
- const BSP_MeshFragment & out_frag,
- const BSP_MeshFragment & on_frag,
- BSP_Classification keep,
- BSP_MeshFragment & spanning_frag,
- BSP_MeshFragment & output
- );
-
- void
- MergeFrags(
- const BSP_MeshFragment & in,
- BSP_MeshFragment & out
- );
-
-
-
-};
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_CSGISplitter.h b/intern/bsp/intern/BSP_CSGISplitter.h
deleted file mode 100755
index 17392fd07be..00000000000
--- a/intern/bsp/intern/BSP_CSGISplitter.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSP_CSGISplitter_h
-#define BSP_CSGISplitter_h
-
-class BSP_MeshFragment;
-class BSP_CSGMesh;
-
-class MT_Plane3;
-
-/**
- * This class defines a mesh splitter interface.
- * It embodies the action of splitting a mesh by a plane.
- * Depending on the context of the operation subclasses
- * may wish to define different implementations. For example
- * with building a BSP tree from a mesh, the mesh does not
- * need to be kept consistent, it doesn't matter if the edges
- * are maintained etc. However when pushing polygons through
- * a BSP tree (say for CSG operations)it is important to
- * try and maintain mesh connectivity and thus a different
- * splitter implementation may be needed.
- *
- * This is an abstract interface class.
- */
-
-class BSP_CSGISplitter
-{
-
-public:
-
- /**
- * Split the incoming mesh fragment (frag)
- * by the plane, put the output into (in,out and on)
- * Subclasses should clear the contents of the
- * in_coming fragment.
- */
-
- virtual
- void
- Split(
- const MT_Plane3& plane,
- BSP_MeshFragment *frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
- )= 0;
-
- /**
- * Split the entire mesh with respect to the plane.
- * and place ouput into (in,out and on).
- * Subclasses should clear the contents of the
- * in_coming fragment.
- */
- virtual
- void
- Split(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
- )=0;
-
- virtual
- ~BSP_CSGISplitter(
- ){
- };
-
-protected :
-
- BSP_CSGISplitter(
- ) {
- //nothing to do
- }
-
- BSP_CSGISplitter(
- const BSP_CSGISplitter &
- ) {
- //nothing to do
- }
-};
-
-
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_CSGMesh.cpp b/intern/bsp/intern/BSP_CSGMesh.cpp
index 36f00868240..5da39c8d551 100755
--- a/intern/bsp/intern/BSP_CSGMesh.cpp
+++ b/intern/bsp/intern/BSP_CSGMesh.cpp
@@ -33,7 +33,6 @@
#include "BSP_CSGMesh.h"
#include "MT_assert.h"
#include "CTR_TaggedSetOps.h"
-#include "BSP_MeshFragment.h"
#include "MT_Plane3.h"
#include "BSP_CSGException.h"
@@ -50,8 +49,6 @@ BSP_CSGMesh(
m_verts = NULL;
m_faces = NULL;
m_edges = NULL;
- m_fv_data = NULL;
- m_face_data = NULL;
}
BSP_CSGMesh *
@@ -94,20 +91,6 @@ NewCopy(
return NULL;
}
}
- if (m_fv_data != NULL) {
- mesh->m_fv_data = new BSP_CSGUserData(*m_fv_data);
- if (mesh->m_fv_data == NULL) {
- delete mesh;
- return NULL;
- }
- }
- if (m_face_data != NULL) {
- mesh->m_face_data = new BSP_CSGUserData(*m_face_data);
- if (mesh->m_face_data == NULL) {
- delete mesh;
- return NULL;
- }
- }
return mesh;
}
@@ -145,23 +128,6 @@ SetVertices(
return true;
}
- void
-BSP_CSGMesh::
-SetFaceVertexData(
- BSP_CSGUserData *fv_data
-){
- m_fv_data = fv_data;
-}
-
- void
-BSP_CSGMesh::
-SetFaceData(
- BSP_CSGUserData *f_data
-) {
- m_face_data = f_data;
-}
-
-
void
BSP_CSGMesh::
AddPolygon(
@@ -188,51 +154,6 @@ AddPolygon(
face.m_plane = face_plane;
};
- void
-BSP_CSGMesh::
-AddPolygon(
- const int * verts,
- const int * fv_indices,
- int num_verts
-){
- // This creates a new polygon on the end of the face list.
- AddPolygon(verts,num_verts);
-
- BSP_MFace & face = m_faces->back();
- // now we just fill in the fv indices
-
- if (fv_indices) {
- insert_iterator<vector<BSP_UserFVInd> > insert_point(face.m_fv_data,face.m_fv_data.end());
- copy(fv_indices,fv_indices + num_verts,insert_point);
- } else {
- face.m_fv_data.insert(face.m_fv_data.end(),num_verts,BSP_UserFVInd::Empty());
- }
-}
-
-
- void
-BSP_CSGMesh::
-AddSubTriangle(
- const BSP_MFace &iface,
- const int * index_info
-){
- // This creates a new polygon on the end of the face list.
-
- m_faces->push_back(BSP_MFace());
- BSP_MFace & face = m_faces->back();
-
- face.m_verts.push_back(iface.m_verts[index_info[0]]);
- face.m_verts.push_back(iface.m_verts[index_info[1]]);
- face.m_verts.push_back(iface.m_verts[index_info[2]]);
-
- face.m_fv_data.push_back(iface.m_fv_data[index_info[0]]);
- face.m_fv_data.push_back(iface.m_fv_data[index_info[1]]);
- face.m_fv_data.push_back(iface.m_fv_data[index_info[2]]);
-
- face.m_plane = iface.m_plane;
-}
-
-
// assumes that the face already has a plane equation
void
BSP_CSGMesh::
@@ -420,29 +341,12 @@ EdgeSet(
return *m_edges;
}
- BSP_CSGUserData &
-BSP_CSGMesh::
-FaceVertexData(
-) const {
- return *m_fv_data;
-}
-
- BSP_CSGUserData &
-BSP_CSGMesh::
-FaceData(
-) const {
- return *m_face_data;
-}
-
-
BSP_CSGMesh::
~BSP_CSGMesh(
){
if ( m_verts != NULL ) delete m_verts;
if ( m_faces != NULL ) delete m_faces;
if ( m_edges != NULL ) delete m_edges;
- if ( m_fv_data != NULL ) delete m_fv_data;
- if ( m_face_data != NULL ) delete m_face_data;
}
// local geometry queries.
@@ -600,158 +504,6 @@ VertexFaces(
}
}
- void
-BSP_CSGMesh::
-InsertVertexIntoFace(
- BSP_MFace & face,
- const BSP_VertexInd & v1,
- const BSP_VertexInd & v2,
- const BSP_VertexInd & vi,
- CSG_InterpolateUserFaceVertexDataFunc fv_split_func,
- MT_Scalar epsilon
-){
- // We assume that the face vertex data indices
- // are consistent with the vertex inidex data.
-
- // look for v1
- vector<BSP_VertexInd>::iterator result =
- find(face.m_verts.begin(),face.m_verts.end(),v1);
-
- MT_assert(result != face.m_verts.end());
-
- BSP_CSGUserData & fv_data = *m_fv_data;
-
- // now we have to check on either side of the result for the
- // other vertex
-
- vector<BSP_VertexInd>::iterator prev = result - 1;
- if (prev < face.m_verts.begin()) {
- prev = face.m_verts.end() -1;
- }
- if (*prev == v2) {
-
- // so result <=> v2 and prev <=> v1
-
- // create space for new face vertex data
-
- int vf_i = fv_data.Size();
- fv_data.IncSize();
-
- int vf_i2 = prev - face.m_verts.begin();
- int vf_i1 = result - face.m_verts.begin();
-
- (*fv_split_func)(
- fv_data[int(face.m_fv_data[vf_i1])],
- fv_data[int(face.m_fv_data[vf_i2])],
- fv_data[vf_i],
- epsilon
- );
-
- // insert vertex data index.
- face.m_fv_data.insert(face.m_fv_data.begin() + vf_i1,vf_i);
- face.m_verts.insert(result,vi);
-
- return;
- }
-
- vector<BSP_VertexInd>::iterator next = result + 1;
- if (next >= face.m_verts.end()) {
- next = face.m_verts.begin();
- }
- if (*next == v2) {
-
- // so result <=> v1 and next <=> v2
-
- int vf_i = fv_data.Size();
- fv_data.IncSize();
-
- int vf_i2 = int(next - face.m_verts.begin());
- int vf_i1 = int(result - face.m_verts.begin());
-
- (*fv_split_func)(
- fv_data[int(face.m_fv_data[vf_i1])],
- fv_data[int(face.m_fv_data[vf_i2])],
- fv_data[vf_i],
- epsilon
- );
-
- // insert vertex data index.
- face.m_fv_data.insert(face.m_fv_data.begin() + vf_i2,vf_i);
- face.m_verts.insert(next,vi);
-
- return;
- }
-
- // if we get here we are in trouble.
- MT_assert(false);
- BSP_CSGException e(e_mesh_error);
- throw(e);
-}
-
- void
-BSP_CSGMesh::
-SetBBox(
- const MT_Vector3 & min,
- const MT_Vector3 & max
-){
- m_bbox_min = min;
- m_bbox_max = max;
-}
-
-
- void
-BSP_CSGMesh::
-BBox(
- MT_Vector3 &min,
- MT_Vector3 &max
-) const {
- min = m_bbox_min;
- max = m_bbox_max;
-}
-
-
-// Update the BBox
-//////////////////
-
- void
-BSP_CSGMesh::
-UpdateBBox(
-){
- // TODO
-};
-
- void
-BSP_CSGMesh::
-SC_Classification(
- BSP_FaceInd f,
- const MT_Plane3& plane
-){
- const BSP_MFace & face = FaceSet()[f];
-
- vector<BSP_VertexInd>::const_iterator f_verts_it = face.m_verts.begin();
- vector<BSP_VertexInd>::const_iterator f_verts_end = face.m_verts.end();
-
- for (;f_verts_it != f_verts_end; ++f_verts_it) {
-
- const BSP_MVertex & vert = VertexSet()[*f_verts_it];
-
- MT_Scalar dist = plane.signedDistance(
- vert.m_pos
- );
-
- if (fabs(dist) <= BSP_SPLIT_EPSILON ){
- MT_assert(BSP_Classification(vert.OpenTag()) == e_classified_on);
- } else
- if (dist > BSP_SPLIT_EPSILON) {
- MT_assert(BSP_Classification(vert.OpenTag()) == e_classified_out);
- } else
- if (dist < BSP_SPLIT_EPSILON) {
- MT_assert(BSP_Classification(vert.OpenTag()) == e_classified_in);
- }
- }
-}
-
-
bool
BSP_CSGMesh::
SC_Face(
diff --git a/intern/bsp/intern/BSP_CSGMesh.h b/intern/bsp/intern/BSP_CSGMesh.h
index 2d966ffa401..47903520157 100755
--- a/intern/bsp/intern/BSP_CSGMesh.h
+++ b/intern/bsp/intern/BSP_CSGMesh.h
@@ -36,12 +36,10 @@
#include "MEM_SmartPtr.h"
#include "MEM_RefCountPtr.h"
#include "MEM_NonCopyable.h"
-#include "BSP_CSGUserData.h"
#include "../extern/CSG_BooleanOps.h"
class MT_Plane3;
-class BSP_MeshFragment;
class BSP_CSGMesh :
public MEM_NonCopyable,
@@ -61,34 +59,11 @@ public :
);
void
- SetFaceVertexData(
- BSP_CSGUserData *fv_data
- );
-
- void
- SetFaceData(
- BSP_CSGUserData *f_data
- );
-
- void
AddPolygon(
const int * verts,
int num_verts
);
- void
- AddPolygon(
- const int * verts,
- const int * fv_indices,
- int num_verts
- );
-
- void
- AddSubTriangle(
- const BSP_MFace &iface,
- const int * index_info
- );
-
// assumes that the face already has a plane equation
void
AddPolygon(
@@ -142,14 +117,6 @@ public :
EdgeSet(
) const;
- BSP_CSGUserData &
- FaceVertexData(
- ) const;
-
- BSP_CSGUserData &
- FaceData(
- ) const;
-
~BSP_CSGMesh(
);
@@ -213,29 +180,6 @@ public :
) const;
- // Bounding box methods
- ///////////////////////
-
- void
- SetBBox(
- const MT_Vector3 & min,
- const MT_Vector3 & max
- );
-
- void
- BBox(
- MT_Vector3 &min,
- MT_Vector3 &max
- ) const ;
-
- // Update the BBox
- //////////////////
-
- void
- UpdateBBox(
- );
-
-
/**
* Sanity checkers
*/
@@ -248,16 +192,6 @@ public :
);
/**
- * Make sure the polygons vertex classification is correct
- */
-
- void
- SC_Classification(
- BSP_FaceInd f,
- const MT_Plane3&plane
- );
-
- /**
* Return the face plane equation
*/
@@ -285,23 +219,6 @@ public :
CountTriangles(
) const;
- /**
- * Insert a vertex index into a polygon
- * and call the external splitting function to
- * generate a new face vertex property.
- */
-
- void
- InsertVertexIntoFace(
- BSP_MFace & face,
- const BSP_VertexInd & v1,
- const BSP_VertexInd & v2,
- const BSP_VertexInd & vi,
- CSG_InterpolateUserFaceVertexDataFunc fv_split_func,
- MT_Scalar epsilon
- );
-
-
private :
void
@@ -322,18 +239,6 @@ private :
std::vector<BSP_MFace> *m_faces;
std::vector<BSP_MEdge> *m_edges;
- // The face_vertex user data associated with this mesh
-
- BSP_CSGUserData *m_fv_data;
-
- // The face user data associated with this mesh -
- // This is a buffer that maps directly to the face buffer.
- // An index into the faces is alos an index into m_face_data
- // for that face
-
- BSP_CSGUserData *m_face_data;
-
-
MT_Vector3 m_bbox_min;
MT_Vector3 m_bbox_max;
diff --git a/intern/bsp/intern/BSP_CSGMeshBuilder.cpp b/intern/bsp/intern/BSP_CSGMeshBuilder.cpp
deleted file mode 100755
index 7e5b7e67fe8..00000000000
--- a/intern/bsp/intern/BSP_CSGMeshBuilder.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BSP_CSGMeshBuilder.h"
-
-
-using namespace std;
-
- MEM_SmartPtr<BSP_CSGMesh>
-BSP_CSGMeshBuilder::
-NewMesh(
- CSG_MeshPropertyDescriptor &props,
- CSG_FaceIteratorDescriptor &face_it,
- CSG_VertexIteratorDescriptor &vertex_it
-) {
-
- MEM_SmartPtr<BSP_CSGMesh> mesh = BSP_CSGMesh::New();
- if (mesh == NULL) return NULL;
-
- MEM_SmartPtr<BSP_CSGUserData> fv_data = new BSP_CSGUserData(props.user_face_vertex_data_size);
- MEM_SmartPtr<BSP_CSGUserData> face_data = new BSP_CSGUserData(props.user_data_size);
-
-
- MEM_SmartPtr<vector<BSP_MVertex> > vertices(new vector<BSP_MVertex>);
- if (vertices == NULL || fv_data == NULL || face_data == NULL) return NULL;
-
- // The size of the vertex data array will be at least the number of faces.
-
- fv_data->Reserve(face_it.num_elements);
- face_data->Reserve(face_it.num_elements);
-
- vertices->reserve(vertex_it.num_elements);
-
- CSG_IVertex vertex;
-
- while (!vertex_it.Done(vertex_it.it)) {
- vertex_it.Fill(vertex_it.it,&vertex);
-
- MT_Point3 pos(vertex.position);
- vertices->push_back(BSP_MVertex(pos));
-
- vertex_it.Step(vertex_it.it);
- }
-
- // pass ownership of the vertices to the mesh.
- mesh->SetVertices(vertices);
-
- // now for the polygons.
-
- CSG_IFace face;
- // we may need to decalare some memory for user defined face properties.
-
- if (props.user_data_size) {
- face.user_face_data = new char[props.user_data_size];
- } else {
- face.user_face_data = NULL;
- }
-
- if (props.user_face_vertex_data_size) {
- char * fv_data2 = NULL;
- fv_data2 = new char[4 * props.user_face_vertex_data_size];
-
- face.user_face_vertex_data[0] = fv_data2;
- face.user_face_vertex_data[1] = fv_data2 + props.user_face_vertex_data_size;
- face.user_face_vertex_data[2] = fv_data2 + 2*props.user_face_vertex_data_size;
- face.user_face_vertex_data[3] = fv_data2 + 3*props.user_face_vertex_data_size;
- } else {
- face.user_face_vertex_data[0] = NULL;
- face.user_face_vertex_data[1] = NULL;
- face.user_face_vertex_data[2] = NULL;
- face.user_face_vertex_data[3] = NULL;
- }
-
-
- int tri_index[3];
- int fv_index[3];
-
- while (!face_it.Done(face_it.it)) {
- face_it.Fill(face_it.it,&face);
-
- // Let's not rely on quads being coplanar - especially if they
- // are coming out of that soup of code from blender...
- if (face.vertex_number == 4) {
- tri_index[0] = face.vertex_index[2];
- tri_index[1] = face.vertex_index[3];
- tri_index[2] = face.vertex_index[0];
-
- fv_index[0] = fv_data->Duplicate(face.user_face_vertex_data[2]);
- fv_index[1] = fv_data->Duplicate(face.user_face_vertex_data[3]);
- fv_index[2] = fv_data->Duplicate(face.user_face_vertex_data[0]);
-
- mesh->AddPolygon(tri_index,fv_index,3);
-
- // bit of an unspoken relationship between mesh face buffer
- // and the face data which I guess should be changed.
- face_data->Duplicate(face.user_face_data);
-
- }
-
- fv_index[0] = fv_data->Duplicate(face.user_face_vertex_data[0]);
- fv_index[1] = fv_data->Duplicate(face.user_face_vertex_data[1]);
- fv_index[2] = fv_data->Duplicate(face.user_face_vertex_data[2]);
-
- mesh->AddPolygon(face.vertex_index,fv_index,3);
- // bit of an unspoken relationship between mesh face buffer
- // and the face data which I guess should be changed.
- face_data->Duplicate(face.user_face_data);
-
-
- face_it.Step(face_it.it);
- }
-
- // give the user face vertex data over to the mesh.
-
- mesh->SetFaceVertexData(fv_data);
- mesh->SetFaceData(face_data);
-
- // that's it
-
- delete[] static_cast<char *>(face.user_face_data);
- delete[] static_cast<char *>(face.user_face_vertex_data[0]);
- return mesh;
-}
-
diff --git a/intern/bsp/intern/BSP_CSGMeshBuilder.h b/intern/bsp/intern/BSP_CSGMeshBuilder.h
deleted file mode 100755
index 8216f972c74..00000000000
--- a/intern/bsp/intern/BSP_CSGMeshBuilder.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSP_CSGMeshBuilder_h
-#define BSP_CSGMeshBuilder_h
-
-#include "../extern/CSG_BooleanOps.h"
-#include "BSP_CSGMesh.h"
-#include "MEM_NonCopyable.h"
-#include "MEM_SmartPtr.h"
-
-/**
- * This class helps you to build a mesh from 2 seperate vertex/face
- * iterators defined in the external interface of the bsp module.
- * This code should really become party of a generic C++ mesh interface
- * but later...
- */
-
-class BSP_CSGMeshBuilder : public MEM_NonCopyable{
-
-public :
-
- /**
- * Return a new BSP_CSGMesh with the desired props
- * built from the given face and vertex iterators.
- * The iterators are exhausted by this action.
- */
-
- static
- MEM_SmartPtr<BSP_CSGMesh>
- NewMesh(
- CSG_MeshPropertyDescriptor &props,
- CSG_FaceIteratorDescriptor &face_it,
- CSG_VertexIteratorDescriptor &vertex_it
- );
-
-private :
-
- BSP_CSGMeshBuilder(
- );
-
-};
-
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_CSGMeshSplitter.cpp b/intern/bsp/intern/BSP_CSGMeshSplitter.cpp
deleted file mode 100755
index ba3a3150dba..00000000000
--- a/intern/bsp/intern/BSP_CSGMeshSplitter.cpp
+++ /dev/null
@@ -1,719 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BSP_CSGMeshSplitter.h"
-
-#include "BSP_CSGMesh.h"
-#include "BSP_MeshFragment.h"
-#include "BSP_CSGException.h"
-#include "MT_MinMax.h"
-#include "MT_assert.h"
-
-using namespace std;
-
-
-BSP_CSGMeshSplitter::
-BSP_CSGMeshSplitter(
- CSG_InterpolateUserFaceVertexDataFunc fv_split_func
-) : m_fv_func(fv_split_func)
-{
- // nothing to do
-};
-
- void
-BSP_CSGMeshSplitter::
-Split(
- const MT_Plane3& plane,
- BSP_MeshFragment *frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
-){
- // First classify the vertices and the polygons of the
- // incoming fragment.
- frag->Classify(plane,in_frag,out_frag,on_frag,m_spanning_faces,m_tagged_verts);
-
- SplitImp(*(frag->Mesh()),plane,m_spanning_faces,in_frag,out_frag,on_frag,m_tagged_verts);
-
- m_spanning_faces.clear();
- m_tagged_verts.clear();
-
-}
-
- void
-BSP_CSGMeshSplitter::
-Split(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
-){
- BSP_MeshFragment::Classify(mesh, plane,in_frag,out_frag,on_frag,m_spanning_faces,m_tagged_verts);
-
- SplitImp(mesh,plane,m_spanning_faces,in_frag,out_frag,on_frag,m_tagged_verts);
- m_spanning_faces.clear();
- m_tagged_verts.clear();
-}
-
-BSP_CSGMeshSplitter::
-~BSP_CSGMeshSplitter(
-){
- // nothing to do
-}
-
- void
-BSP_CSGMeshSplitter::
-SplitImp(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- const std::vector<BSP_FaceInd> & spanning_faces,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- std::vector<BSP_VertexInd> & classified_verts
-){
- // Assumes you have already classified the vertices.
- // and generated a set of spanning faces.
-
- vector<BSP_MEdge> & edge_set = mesh.EdgeSet();
- vector<BSP_MVertex> & vertex_set = mesh.VertexSet();
- vector<BSP_MFace> & face_set = mesh.FaceSet();
-
- // Now identify the spanning edges.
- // These can be computed in many ways but probably the most
- // efficient is to select all edges from the vertices of the
- // spanning polygons that cross the plane.
-
- vector<BSP_FaceInd>::const_iterator sface_end = m_spanning_faces.end();
- vector<BSP_FaceInd>::const_iterator sface_it = m_spanning_faces.begin();
-
- for (;sface_it != sface_end; ++sface_it) {
-
- BSP_MFace & sface = face_set[*sface_it];
-
- vector<BSP_VertexInd>::const_iterator sf_vert_end = sface.m_verts.end();
- vector<BSP_VertexInd>::iterator sf_vert_it = sface.m_verts.begin();
-
- for (;sf_vert_it != sf_vert_end; ++sf_vert_it) {
- BSP_MVertex & vert = vertex_set[*sf_vert_it];
-
- if (!vert.SelectTag()) {
- // what classification does this vertex have?
-
- BSP_Classification root_vert_class = BSP_Classification(vert.OpenTag());
-
- // we are only interested in edges whose vertices are in and out.
- if (root_vert_class != e_classified_on) {
-
- BSP_Classification opp_class = e_classified_out;
- if (root_vert_class == e_classified_out) {
- opp_class = e_classified_in;
- }
- // we haven't visited this vertex before so lets
- // analyse it's edges.
-
- vector<BSP_EdgeInd>::const_iterator v_edge_end = vert.m_edges.end();
- vector<BSP_EdgeInd>::iterator v_edge_it = vert.m_edges.begin();
-
- for (; v_edge_it != v_edge_end; ++v_edge_it) {
- BSP_MEdge & edge = edge_set[*v_edge_it];
-
- if (!edge.SelectTag()) {
- // we haven't visited this edge before so check it's
- // end points
-
- // we know that a spanning polygon can have at most
- // 2 on vertices (even at this point where we haven't
- // yet split the edge!) We are interested in edges whose
- // vertices are in and out the plane.
-
- BSP_VertexInd opp_vi = edge.OpVertex(*sf_vert_it);
- if (vertex_set[opp_vi].OpenTag() == opp_class) {
- // we have found an edge !!!!
- m_spanning_edges.push_back(*v_edge_it);
- }
- edge.SetSelectTag(true);
- m_visited_edges.push_back(*v_edge_it);
- }
- }
- }
-
- vert.SetSelectTag(true);
- m_visited_verts.push_back(*sf_vert_it);
- }
- }
- }
-
- // clear the tags we used in the above
-
- unsigned int i;
-
- for (i = 0; i < m_visited_edges.size(); ++i) {
- edge_set[m_visited_edges[i]].SetSelectTag(false);
- }
- for (i=0;i < m_visited_verts.size(); ++i) {
- vertex_set[m_visited_verts[i]].SetSelectTag(false);
- }
- for (i=0; i < m_spanning_faces.size(); ++i) {
- face_set[m_spanning_faces[i]].SetSelectTag(false);
- }
-
- // The spanning edge set constains unique edges. Next we run
- // through the edge set and compute the intersection with the
- // plane --- the edge is guarenteed not to be parallel to the plane!
- // we then split the edge with the new vertex.
-
- // We identify the polygons affected by the split
-
- vector<BSP_EdgeInd>::const_iterator s_edge_end = m_spanning_edges.end();
- vector<BSP_EdgeInd>::iterator s_edge_it = m_spanning_edges.begin();
-
- for (;s_edge_it != s_edge_end; ++s_edge_it) {
-
- const BSP_MEdge & edge = edge_set[*s_edge_it];
-
- const BSP_MVertex &v1 = vertex_set[edge.m_verts[0]];
- const BSP_MVertex &v2 = vertex_set[edge.m_verts[1]];
-
- const MT_Vector3 & ptA = v1.m_pos;
- const MT_Vector3 & ptB = v2.m_pos;
-
- // compute the intersection point of plane and ptA->ptB
- MT_Vector3 v = ptB - ptA;
- MT_Scalar sideA = plane.signedDistance(ptA);
-
- MT_Scalar epsilon = -sideA/plane.Normal().dot(v);
- MT_Vector3 new_p = ptA + (v * epsilon);
-
- // so new_p is the intersection of the plane and the edge.
- // split the edge at new_p
-
- BSP_MVertex new_vert;
- new_vert.m_pos = new_p;
-
- BSP_VertexInd new_vi = SplitEdge(mesh,*s_edge_it,new_vert,epsilon);
-
- // tag the new vertex as 'on' the plane - we use this information
- // to split the affected polygons below.
- vertex_set[new_vi].SetOpenTag(e_classified_on);
-
- // We add it to the tagged verts so we can remove the tag later.
- classified_verts.push_back(new_vi);
- }
-
- // We start with the spanning polygons...
- // not forgetting to add the new polygon fragments to the correct fragment bins.
-
- sface_end = m_spanning_faces.end();
- sface_it = m_spanning_faces.begin();
-
- for (;sface_it != sface_end; ++sface_it) {
-
- BSP_FaceInd f_in,f_out;
-
- SplitPolygon(mesh,*sface_it,f_in,f_out);
- in_frag->FaceSet().push_back(f_in);
- out_frag->FaceSet().push_back(f_out);
- }
-
- // Finally we have to clean up the vertex tags we set on all the vertices
- // There will be some overlap between the vertex sets, so this operation
- // is a tiny bit inefficient.
-
- vector<BSP_VertexInd>::const_iterator v_end = classified_verts.end();
- vector<BSP_VertexInd>::const_iterator v_it = classified_verts.begin();
-
- for (; v_it != v_end; ++v_it) {
- vertex_set[*v_it].SetOpenTag(e_unclassified);
- }
-
- // tidy up the cached arrays.
-
- m_spanning_edges.clear();
- m_visited_edges.clear();
- m_visited_verts.clear();
-
-
- // le fin.
-
-}
-
-
- BSP_VertexInd
-BSP_CSGMeshSplitter::
-SplitEdge(
- BSP_CSGMesh & mesh,
- BSP_EdgeInd ei,
- BSP_MVertex &vertex,
- MT_Scalar epsilon
-){
- vector<BSP_MEdge> & edge_set = mesh.EdgeSet();
- vector<BSP_MVertex> & vertex_set = mesh.VertexSet();
- vector<BSP_MFace> & face_set = mesh.FaceSet();
-
- MT_assert(edge_set.size() > (unsigned int)(ei));
-
- if (edge_set.size() <= (unsigned int)(ei)) {
- BSP_CSGException e(e_param_error);
- throw(e);
- }
-
- // push the vertex onto the vertex array
- BSP_VertexInd new_vi = vertex_set.size();
- vertex_set.push_back(vertex);
- BSP_MVertex & new_v = vertex_set[new_vi];
-
- // copy the edge because the new edge will have
- // exactly the same face set.
-
- BSP_EdgeInd new_ei = edge_set.size();
-
- // Note never use set.push_back(set[i])
- // coz push_back excepts a reference which may become
- // invalid if the set is resized
-
- edge_set.push_back(BSP_MEdge());
- edge_set[new_ei] = edge_set[ei];
- BSP_MEdge & new_e = edge_set[new_ei];
-
- BSP_MEdge &e = edge_set[ei];
-
- // get the edge vertices.
- BSP_MVertex & e_v2 = vertex_set[e.m_verts[1]];
-
- // Remove the split edge from vertex 2.
- // Let's hope that the vertex isn't using this edge for
- // its' open tag!!
-
- BSP_Classification v2_class = BSP_Classification(e_v2.OpenTag());
-
- e_v2.RemoveEdge(ei);
-
- // add the split edge to the new vertex.
- new_v.AddEdge(ei);
-
- // add the new edge to the new vertex.
- new_v.AddEdge(new_ei);
-
- // add the new edge to vertex 2
- e_v2.AddEdge(new_ei);
-
- // Reset the tags for modified vertex.
-
- e_v2.SetOpenTag(v2_class);
-
-
- // Replace the old vertex indices in the new edge.
- new_e.m_verts[0] = new_vi;
- e.m_verts[1] = new_vi;
-
- // Finally add the vertex in the correct position to the
- // neighbouring polygons.
-
- vector<BSP_FaceInd>::iterator neighbour_face_it = e.m_faces.begin();
- vector<BSP_FaceInd>::const_iterator neighbour_face_end = e.m_faces.end();
-
- for (; neighbour_face_it != neighbour_face_end; ++neighbour_face_it) {
-
- mesh.InsertVertexIntoFace(
- face_set[*neighbour_face_it],
- new_e.m_verts[1],
- e.m_verts[0],
- new_vi,
- m_fv_func,
- epsilon
- );
- }
-
- // That should be it (cough)
- return new_vi;
-
-}
-
- void
-BSP_CSGMeshSplitter::
-SplitPolygon(
- BSP_CSGMesh & mesh,
- BSP_FaceInd fi,
- BSP_FaceInd &fin,
- BSP_FaceInd &fout
-){
- vector<BSP_MEdge> & edge_set = mesh.EdgeSet();
- vector<BSP_MVertex> & vertex_set = mesh.VertexSet();
- vector<BSP_MFace> & face_set = mesh.FaceSet();
-
- MT_assert(face_set.size() > (unsigned int)(fi));
- if (face_set.size() <= (unsigned int)(fi)) {
- BSP_CSGException e(e_param_error);
- throw(e);
- }
-
- BSP_MFace & face = face_set[fi];
-
- // Walk throught the vertices of this polygon.
- // generate inside and outside loops.
-
- vector<BSP_VertexInd>::const_iterator f_verts_end = face.m_verts.end();
- vector<BSP_VertexInd>::iterator f_verts_it = face.m_verts.begin();
-
- vector<BSP_UserFVInd>::const_iterator f_fv_data_it = face.m_fv_data.begin();
-
- // NOTE we don't actually duplicate fv data for this face
- // we just duplicate the indices, so both on vertices
- // will share the fv data.
-
- for (;f_verts_it != f_verts_end; ++f_verts_it, ++f_fv_data_it) {
-
- BSP_MVertex & vert = vertex_set[*f_verts_it];
- BSP_Classification v_class = BSP_Classification(vert.OpenTag());
-
- if (v_class == e_classified_in) {
- m_in_loop.push_back(*f_verts_it);
- m_fv_in_loop.push_back(*f_fv_data_it);
- } else
- if (v_class == e_classified_out) {
- m_out_loop.push_back(*f_verts_it);
- m_fv_out_loop.push_back(*f_fv_data_it);
-
- } else
- if (v_class == e_classified_on) {
- m_in_loop.push_back(*f_verts_it);
- m_out_loop.push_back(*f_verts_it);
- m_on_loop.push_back(*f_verts_it);
- m_fv_in_loop.push_back(*f_fv_data_it);
- m_fv_out_loop.push_back(*f_fv_data_it);
- } else {
- // The vertex is unclassified this is an error!
- MT_assert(false);
- BSP_CSGException e(e_split_error);
- throw(e);
- }
- }
-
- if ((m_in_loop.size() == 1) || (m_out_loop.size() == 1)) {
- // Then there was only 1 tagged vertex I guess this is fine
- // but should be reviewed!
-
- // NOT fine - we only ever split spanning polygons.
- MT_assert(false);
- BSP_CSGException e(e_split_error);
- throw(e);
- }
-
- MT_assert(m_in_loop.size() >=3 && m_out_loop.size() >=3 && m_on_loop.size() == 2);
-
- if (m_in_loop.size() <3 || m_out_loop.size() <3 || m_on_loop.size() !=2) {
- BSP_CSGException e(e_split_error);
- throw(e);
- }
- // Now we have 2 seperate vertex loops representing the polygon
- // halves.
-
- // create a new polygon for the out_loop of vertices.
- ////////////////////////////////////////////////////
-
- // Duplicate face data.
-
- mesh.FaceData().Duplicate(fi);
-
- BSP_FaceInd new_fi = face_set.size();
- face_set.push_back(BSP_MFace());
- BSP_MFace & new_f = face_set[new_fi];
-
- // assign plane equation for new face - this is the same as the
- // original of course.
-
- new_f.m_plane = face_set[fi].m_plane;
-
- // note that face may have become invalid because we just been adding
- // more polygons to the array. We can't assign a new reference to the old
- // invlaid one! It will call try and call the assignment operator on
- // the original face!!!! The joys of references! We just use face_set[fi]
- // from now on to be safe
-
- // We need to insert an edge between m_on_loop[0] and m_on_loop[1]
-
- // Make sure the edge does not already exist between these 2 vertices!
- // This can happen if the original mesh has duplicate polygons.
- // We still wire up the new polygons to this edge, which will
- // lead to duplicate polygons in the output -- but algorithm
- // should still work.
- BSP_EdgeInd new_ei = mesh.FindEdge(m_on_loop[0],m_on_loop[1]);
-
- if (new_ei.IsEmpty()) {
-
- // create a new edge.
-
- new_ei = edge_set.size();
- edge_set.push_back(BSP_MEdge());
- BSP_MEdge & new_e = edge_set[new_ei];
-
- new_e.m_verts[0] = m_on_loop[0];
- new_e.m_verts[1] = m_on_loop[1];
-
- // Now tie the edge to it's vertices.
-
- vertex_set[m_on_loop[0]].AddEdge(new_ei);
- vertex_set[m_on_loop[1]].AddEdge(new_ei);
- }
-
- edge_set[new_ei].m_faces.push_back(fi);
- // This next line is a trick we are going to replace it in a moment
- // with new_fi. It means that all the edges of the new polygon have
- // pointers to the old polygon which we can replace.
- edge_set[new_ei].m_faces.push_back(fi);
-
-
- // Replace the old polygons vertex loop with the in_loop of vertices.
-
- face_set[fi].m_verts = m_in_loop;
- new_f.m_verts = m_out_loop;
-
- // Replace the olf fv loops.
- face_set[fi].m_fv_data = m_fv_in_loop;
- new_f.m_fv_data = m_fv_out_loop;
-
-
- // That should be it for the old polygon;
- // For the new polygon we just need to iterate around it's
- // edges and replace pointers to the old polygon with pointers
- // to the new one.
-
- f_verts_end = new_f.m_verts.end();
- f_verts_it = new_f.m_verts.begin();
-
- BSP_VertexInd prev = new_f.m_verts.back();
-
- for (;f_verts_it != f_verts_end; ++f_verts_it) {
- BSP_EdgeInd new_f_ei = mesh.FindEdge(prev,*f_verts_it);
-
- MT_assert(!new_f_ei.IsEmpty());
-
- if (new_f_ei.IsEmpty()) {
- BSP_CSGException e(e_split_error);
- throw(e);
- }
-
- edge_set[new_f_ei].SwapFace(fi,new_fi);
- prev = *f_verts_it;
-
- }
-
- // That should be everything.
-
- fin = fi;
- fout = new_fi;
-
- // clear up cached helpers.
- m_in_loop.clear();
- m_on_loop.clear();
- m_out_loop.clear();
-
- m_fv_in_loop.clear();
- m_fv_out_loop.clear();
-
-}
-
- BSP_FaceInd
-BSP_CSGMeshSplitter::
-TriangulateConvexQuad(
- BSP_CSGMesh & mesh,
- const BSP_FaceInd fi
-){
-
- // we assume that the fi points to a face with
- // exactly 4 vertices.
-
-
- // We are definately going to create a new face
- // so lets make space for it in the face array.
-
- vector<BSP_MFace> & face_set = mesh.FaceSet();
- vector<BSP_MVertex> & vertex_set = mesh.VertexSet();
- vector<BSP_MEdge> & edge_set = mesh.EdgeSet();
-
- if (face_set[fi].m_verts.size() == 3) {
- return BSP_FaceInd::Empty();
- }
-
- // duplicate face data
- mesh.FaceData().Duplicate(fi);
-
- const BSP_FaceInd new_fi = face_set.size();
- face_set.push_back(BSP_MFace());
- BSP_MFace & new_face = face_set[new_fi];
- BSP_MFace & face = face_set[fi];
-
- new_face.m_plane = face.m_plane;
-
- // The internal edges are [0,2] and [1,3]
- // these split the quad into the triangles
- // [0,1,2],[2,3,0] and [0,1,3],[1,2,3] respectively
-
- const MT_Point3 & p0 = vertex_set[face.m_verts[0]].m_pos;
- const MT_Point3 & p1 = vertex_set[face.m_verts[1]].m_pos;
- const MT_Point3 & p2 = vertex_set[face.m_verts[2]].m_pos;
- const MT_Point3 & p3 = vertex_set[face.m_verts[3]].m_pos;
-
- MT_Vector3 e0 = p1 - p0;
- MT_Vector3 e1 = p2 - p1;
- MT_Vector3 e2 = p3 - p2;
- MT_Vector3 e3 = p0 - p3;
-
- MT_Scalar A = (e0.cross(e1)).length2();
- MT_Scalar B = (e2.cross(e3)).length2();
- MT_Scalar C = (e3.cross(e0)).length2();
- MT_Scalar D = (e1.cross(e2)).length2();
-
- MT_Scalar minab = MT_min(A,B);
- MT_Scalar maxab = MT_max(A,B);
-
- MT_Scalar mincd = MT_min(C,D);
- MT_Scalar maxcd = MT_max(C,D);
-
- MT_Scalar ratioab = minab/maxab;
- MT_Scalar ratiocd = mincd/maxcd;
-
- ratioab = MT_abs(1-ratioab);
- ratiocd = MT_abs(1-ratiocd);
-
- vector<BSP_VertexInd> loop1(3),loop2(3);
- vector<BSP_UserFVInd> fv_loop1(3),fv_loop2(3);
-
- if (ratioab < ratiocd) {
- // then use [0,2] as splitting edge.
- loop1[0] = face.m_verts[1];
- loop1[1] = face.m_verts[2];
- loop1[2] = face.m_verts[0];
-
- loop2[0] = face.m_verts[2];
- loop2[1] = face.m_verts[3];
- loop2[2] = face.m_verts[0];
-
- // same for fv indices.
- fv_loop1[0] = face.m_fv_data[1];
- fv_loop1[1] = face.m_fv_data[2];
- fv_loop1[2] = face.m_fv_data[0];
-
- fv_loop2[0] = face.m_fv_data[2];
- fv_loop2[1] = face.m_fv_data[3];
- fv_loop2[2] = face.m_fv_data[0];
-
-
- } else {
- // use [1,3] as splitting edge
- loop1[0] = face.m_verts[0];
- loop1[1] = face.m_verts[1];
- loop1[2] = face.m_verts[3];
-
- loop2[0] = face.m_verts[1];
- loop2[1] = face.m_verts[2];
- loop2[2] = face.m_verts[3];
-
- // same for fv indices.
- fv_loop1[0] = face.m_fv_data[0];
- fv_loop1[1] = face.m_fv_data[1];
- fv_loop1[2] = face.m_fv_data[3];
-
- fv_loop2[0] = face.m_fv_data[1];
- fv_loop2[1] = face.m_fv_data[2];
- fv_loop2[2] = face.m_fv_data[3];
-
- }
-
- // TODO factor out commmon code between here and SplitPolygon.
-
- BSP_EdgeInd new_ei = mesh.FindEdge(loop1[1],loop1[2]);
-
- if (new_ei.IsEmpty()) {
-
- // create a new edge.
-
- new_ei = edge_set.size();
- edge_set.push_back(BSP_MEdge());
- BSP_MEdge & new_e = edge_set[new_ei];
-
- new_e.m_verts[0] = loop1[1];
- new_e.m_verts[1] = loop1[2];
-
- // Now tie the edge to it's vertices.
-
- vertex_set[loop1[1]].AddEdge(new_ei);
- vertex_set[loop1[2]].AddEdge(new_ei);
- }
-
- edge_set[new_ei].m_faces.push_back(fi);
- // This next line is a trick we are going to replace it in a moment
- // with new_fi. It means that all the edges of the new polygon have
- // pointers to the old polygon which we can replace.
- edge_set[new_ei].m_faces.push_back(fi);
-
-
- // Replace the old polygons vertex loop with the in_loop of vertices.
-
- face.m_verts = loop1;
- face.m_fv_data = fv_loop1;
- new_face.m_verts = loop2;
- new_face.m_fv_data = fv_loop2;
-
- // That should be it for the old polygon;
- // For the new polygon we just need to iterate around it's
- // edges and replace pointers to the old polygon with pointers
- // to the new one.
-
- vector<BSP_VertexInd>::const_iterator f_verts_end = new_face.m_verts.end();
- vector<BSP_VertexInd>::const_iterator f_verts_it = new_face.m_verts.begin();
-
- BSP_VertexInd prev = new_face.m_verts.back();
-
- for (;f_verts_it != f_verts_end; ++f_verts_it) {
- BSP_EdgeInd new_f_ei = mesh.FindEdge(prev,*f_verts_it);
-
- MT_assert(!new_f_ei.IsEmpty());
-
- if (new_f_ei.IsEmpty()) {
- BSP_CSGException e(e_split_error);
- throw(e);
- }
-
- edge_set[new_f_ei].SwapFace(fi,new_fi);
- prev = *f_verts_it;
-
- }
- return new_fi;
-}
diff --git a/intern/bsp/intern/BSP_CSGMeshSplitter.h b/intern/bsp/intern/BSP_CSGMeshSplitter.h
deleted file mode 100755
index 44aa4ad949a..00000000000
--- a/intern/bsp/intern/BSP_CSGMeshSplitter.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSP_CSGMeshSplitter_h
-#define BSP_CSGMeshSplitter_h
-
-class BSP_MeshFragment;
-class MT_Plane3;
-class BSP_CSGMesh;
-
-#include "BSP_MeshPrimitives.h"
-#include "../extern/CSG_BooleanOps.h"
-#include "BSP_CSGISplitter.h"
-
-
-/**
- * This class contains splitting functions for a CSGMesh.
- * The atomic operation of a bsp CSG algorithm is to split
- * a mesh fragment (connected collection of polygons contained
- * in a convex cell) by a plane. It is vital to leave the
- * CSGMesh in a valid state after each such operation
- * this class insures this (or tries it's best!).
- */
-
-
-class BSP_CSGMeshSplitter : public BSP_CSGISplitter
-{
-public :
-
- /// construction
-
- BSP_CSGMeshSplitter(
- CSG_InterpolateUserFaceVertexDataFunc fv_split_func
- );
-
- BSP_CSGMeshSplitter(
- const BSP_CSGMeshSplitter & other
- );
-
- /**
- * @section BSP specific mesh operations.
- * Inherited from BSP_CSGISplitter
- */
-
- /**
- * Split a mesh fragment wrt plane. Generates 3 mesh fragments,
- * in, out and on. Makes sure the mesh is coherent after the
- * operation. The contents of frag are consumed by this oepration.
- */
-
- void
- Split(
- const MT_Plane3& plane,
- BSP_MeshFragment *frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
- );
-
- /// Split the entire mesh with respect to the plane.
-
- void
- Split(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
- );
-
- ~BSP_CSGMeshSplitter(
- );
-
-private :
-
- void
- SplitImp(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- const std::vector<BSP_FaceInd> & spanning_faces,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- std::vector<BSP_VertexInd> & classified_verts
- );
-
-
- /**
- * @section Atomic mesh operations.
- */
-
- /**
- * Add a vertex to the mesh, along
- * a given edge. Leaves the mesh in a valid state.
- * The vertex gets copied onto the back of the
- * current vertex array. It's upto you to insure
- * that the vertex actually lies on the edge and leaves
- * the neighbouring faces convex. Returns the vertex index
- * of the new vertex.
- *
- * epsilon is the relative distance [0,1] of the new
- * vertex from the first vertex of the edge. This is
- * used to intepolate face properties.
- */
-
- BSP_VertexInd
- SplitEdge(
- BSP_CSGMesh & mesh,
- BSP_EdgeInd ei,
- BSP_MVertex &vertex,
- MT_Scalar epsilon
- );
-
- /**
- * Split a polygon along an edge connecting the
- * two tagged (on) vertices of the polygon. It assumes
- * that you have already introduced two new vertex indices
- * into the polygon that point to vertices tagged with
- * {in,out,on} information. It creates a new edge from the
- * 2 on vertices that must be present. It then splits up
- * the polygon into 2 fragments on the inside and outside.
- * It returns 2 indices into the face list. 1 for the inside
- * polygon and 1 for the outside polygon.
- */
-
- void
- SplitPolygon(
- BSP_CSGMesh & mesh,
- BSP_FaceInd fi,
- BSP_FaceInd &fin,
- BSP_FaceInd &fout
- );
-
- /**
- * Triangulate a convex quad (the maximum size polygon
- * resulting from splitting a triangle). This can create up
- * to one new face - which is added to the mesh. Note
- * that this method does not preserve references. It uses
- * the edge which divides the quad into roughly equal triangular
- * areas as the splitting edge. - This should avoid creating
- * degenerate triangles.
- */
-
- BSP_FaceInd
- TriangulateConvexQuad(
- BSP_CSGMesh & mesh,
- const BSP_FaceInd fi
- );
-
-private :
-
- // The function pointer used to split face vertex properties.
-
- CSG_InterpolateUserFaceVertexDataFunc m_fv_func;
-
- /// Cached helpers
-
- /// Split function responsibe for:
- std::vector<BSP_FaceInd> m_spanning_faces;
- std::vector<BSP_VertexInd> m_tagged_verts;
-
- /// SplitImp responsible for:
- std::vector<BSP_EdgeInd> m_spanning_edges;
- // The list of faces affected by splitting the spanning edge set.
- std::vector<BSP_EdgeInd> m_visited_edges;
- std::vector<BSP_VertexInd> m_visited_verts;
-
- /// SplitPolygon responsible for:
- std::vector<BSP_FaceInd> m_in_loop,m_out_loop,m_on_loop;
- std::vector<BSP_UserFVInd> m_fv_in_loop,m_fv_out_loop;
-
-};
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_CSGMesh_CFIterator.h b/intern/bsp/intern/BSP_CSGMesh_CFIterator.h
index f10458655d9..6863bf38cfc 100755
--- a/intern/bsp/intern/BSP_CSGMesh_CFIterator.h
+++ b/intern/bsp/intern/BSP_CSGMesh_CFIterator.h
@@ -46,7 +46,7 @@ struct BSP_CSGMesh_VertexIt {
};
-static
+inline
void
BSP_CSGMesh_VertexIt_Destruct(
CSG_VertexIteratorDescriptor * iterator
@@ -61,7 +61,7 @@ BSP_CSGMesh_VertexIt_Destruct(
};
-static
+inline
int
BSP_CSGMesh_VertexIt_Done(
CSG_IteratorPtr it
@@ -76,7 +76,7 @@ BSP_CSGMesh_VertexIt_Done(
return 1;
};
-static
+inline
void
BSP_CSGMesh_VertexIt_Fill(
CSG_IteratorPtr it,
@@ -88,7 +88,7 @@ BSP_CSGMesh_VertexIt_Fill(
vertex_it->pos->m_pos.getValue(vert->position);
};
-static
+inline
void
BSP_CSGMesh_VertexIt_Step(
CSG_IteratorPtr it
@@ -99,7 +99,7 @@ BSP_CSGMesh_VertexIt_Step(
++(vertex_it->pos);
};
-static
+inline
void
BSP_CSGMesh_VertexIt_Reset(
CSG_IteratorPtr it
@@ -109,7 +109,7 @@ BSP_CSGMesh_VertexIt_Reset(
vertex_it->pos = &vertex_it->mesh->VertexSet()[0];
};
-static
+inline
void
BSP_CSGMeshVertexIt_Construct(
BSP_CSGMesh *mesh,
@@ -141,7 +141,7 @@ struct BSP_CSGMesh_FaceIt {
};
-static
+inline
void
BSP_CSGMesh_FaceIt_Destruct(
CSG_FaceIteratorDescriptor *iterator
@@ -156,7 +156,7 @@ BSP_CSGMesh_FaceIt_Destruct(
};
-static
+inline
int
BSP_CSGMesh_FaceIt_Done(
CSG_IteratorPtr it
@@ -168,15 +168,14 @@ BSP_CSGMesh_FaceIt_Done(
/* also check that vector is not empty */
if (face_it->mesh->FaceSet().size() &&
face_it->pos <= &(*(face_it->mesh->FaceSet().end() -1))) {
- if (face_it->face_triangle + 3 <= face_it->pos->m_verts.size()) {
-
+ if (face_it->face_triangle + 3 <= (int)face_it->pos->m_verts.size()) {
return 0;
}
}
return 1;
};
-static
+inline
void
BSP_CSGMesh_FaceIt_Fill(
CSG_IteratorPtr it,
@@ -193,31 +192,8 @@ BSP_CSGMesh_FaceIt_Fill(
face->vertex_index[2] = int(face_it->pos->m_verts[2]);
face->vertex_index[3] = int(face_it->pos->m_verts[3]);
- // Copy the user face data across - this does nothing
- // if there was no mesh user data.
+ face->orig_face = face_it->pos->m_orig_face;
- // time to change the iterator type to an integer...
- face_it->mesh->FaceData().Copy(
- face->user_face_data,
- int(face_it->pos - &face_it->mesh->FaceSet()[0]));
-
- // Copy face vertex data across...
- face_it->mesh->FaceVertexData().Copy(
- face->user_face_vertex_data[0],
- face_it->pos->m_fv_data[0]);
-
- face_it->mesh->FaceVertexData().Copy(
- face->user_face_vertex_data[1],
- face_it->pos->m_fv_data[1]);
-
- face_it->mesh->FaceVertexData().Copy(
- face->user_face_vertex_data[2],
- face_it->pos->m_fv_data[2]);
-
- face_it->mesh->FaceVertexData().Copy(
- face->user_face_vertex_data[3],
- face_it->pos->m_fv_data[3]);
-
face->vertex_number = 4;
}
else {
@@ -226,33 +202,13 @@ BSP_CSGMesh_FaceIt_Fill(
face->vertex_index[1] = int(face_it->pos->m_verts[1]);
face->vertex_index[2] = int(face_it->pos->m_verts[2]);
- // Copy the user face data across - this does nothing
- // if there was no mesh user data.
-
- // time to change the iterator type to an integer...
- face_it->mesh->FaceData().Copy(
- face->user_face_data,
- int(face_it->pos - &face_it->mesh->FaceSet()[0]));
-
- // Copy face vertex data across...
-
- face_it->mesh->FaceVertexData().Copy(
- face->user_face_vertex_data[0],
- face_it->pos->m_fv_data[0]);
-
- face_it->mesh->FaceVertexData().Copy(
- face->user_face_vertex_data[1],
- face_it->pos->m_fv_data[1]);
-
- face_it->mesh->FaceVertexData().Copy(
- face->user_face_vertex_data[2],
- face_it->pos->m_fv_data[2]);
+ face->orig_face = face_it->pos->m_orig_face;
face->vertex_number = 3;
}
};
-static
+inline
void
BSP_CSGMesh_FaceIt_Step(
CSG_IteratorPtr it
@@ -274,7 +230,7 @@ BSP_CSGMesh_FaceIt_Step(
}
};
-static
+inline
void
BSP_CSGMesh_FaceIt_Reset(
CSG_IteratorPtr it
@@ -285,7 +241,7 @@ BSP_CSGMesh_FaceIt_Reset(
f_it->face_triangle = 0;
};
-static
+inline
void
BSP_CSGMesh_FaceIt_Construct(
BSP_CSGMesh * mesh,
diff --git a/intern/bsp/intern/BSP_CSGNCMeshSplitter.cpp b/intern/bsp/intern/BSP_CSGNCMeshSplitter.cpp
deleted file mode 100755
index 11e8bff6810..00000000000
--- a/intern/bsp/intern/BSP_CSGNCMeshSplitter.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BSP_CSGNCMeshSplitter.h"
-
-#include "BSP_CSGMesh.h"
-#include "BSP_MeshFragment.h"
-#include "BSP_CSGException.h"
-#include "MT_MinMax.h"
-#include "MT_assert.h"
-#include <vector>
-
-using namespace std;
-
-BSP_CSGNCMeshSplitter::
-BSP_CSGNCMeshSplitter(
-){
- //nothing to do
-}
-
-BSP_CSGNCMeshSplitter::
-BSP_CSGNCMeshSplitter(
- const BSP_CSGNCMeshSplitter & other
-){
- //nothing to do
-};
-
-
- void
-BSP_CSGNCMeshSplitter::
-Split(
- const MT_Plane3& plane,
- BSP_MeshFragment *frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
-){
- // First classify the vertices and the polygons of the
- // incoming fragment.
- frag->Classify(plane,in_frag,out_frag,on_frag,m_spanning_faces,m_tagged_verts);
-
- SplitImp(*(frag->Mesh()),plane,m_spanning_faces,in_frag,out_frag,on_frag,m_tagged_verts);
-
- m_spanning_faces.clear();
- m_tagged_verts.clear();
-}
-
-/// Split the entire mesh with respect to the plane.
-
- void
-BSP_CSGNCMeshSplitter::
-Split(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
-){
- BSP_MeshFragment::Classify(mesh, plane,in_frag,out_frag,on_frag,m_spanning_faces,m_tagged_verts);
-
- SplitImp(mesh,plane,m_spanning_faces,in_frag,out_frag,on_frag,m_tagged_verts);
- m_spanning_faces.clear();
- m_tagged_verts.clear();
-}
-
-
-BSP_CSGNCMeshSplitter::
-~BSP_CSGNCMeshSplitter(
-){
- //nothing to do
-}
-
- void
-BSP_CSGNCMeshSplitter::
-SplitImp(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- const std::vector<BSP_FaceInd> & spanning_faces,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- std::vector<BSP_VertexInd> & classified_verts
-){
-
- // Just iterate through the spanning faces.
- // Identify the spanning 'edges' and create new vertices
- // and split the polygons. We make no attempt to share
- // vertices or preserve edge connectivity or maintain any
- // face properties etc.
-
- // Assumes you have already classified the vertices.
- // and generated a set of spanning faces.
-
- vector<BSP_MVertex> & vertex_set = mesh.VertexSet();
- vector<BSP_MFace> & face_set = mesh.FaceSet();
-
- vector<BSP_FaceInd>::const_iterator sface_end = m_spanning_faces.end();
- vector<BSP_FaceInd>::const_iterator sface_it = m_spanning_faces.begin();
-
- for (;sface_it != sface_end; ++sface_it) {
- BSP_FaceInd f_in,f_out;
- SplitPolygon(plane,mesh,*sface_it,f_in,f_out);
-
- // Use the open tag to store the original index of the face.
- // This is originally -1.
-
- if (face_set[*sface_it].OpenTag() == -1) {
- face_set[f_in].SetOpenTag(*sface_it);
- face_set[f_out].SetOpenTag(*sface_it);
- } else {
- face_set[f_in].SetOpenTag(face_set[*sface_it].OpenTag());
- face_set[f_out].SetOpenTag(face_set[*sface_it].OpenTag());
- }
-
- in_frag->FaceSet().push_back(f_in);
- out_frag->FaceSet().push_back(f_out);
- }
-
- vector<BSP_VertexInd>::const_iterator v_end = classified_verts.end();
- vector<BSP_VertexInd>::const_iterator v_it = classified_verts.begin();
-
- for (; v_it != v_end; ++v_it) {
- vertex_set[*v_it].SetOpenTag(e_unclassified);
- }
-}
-
- void
-BSP_CSGNCMeshSplitter::
-SplitPolygon(
- const MT_Plane3& plane,
- BSP_CSGMesh & mesh,
- BSP_FaceInd fi,
- BSP_FaceInd &fin,
- BSP_FaceInd &fout
-){
-
- vector<BSP_MVertex> & vertex_set = mesh.VertexSet();
- vector<BSP_MFace> & face_set = mesh.FaceSet();
-
- BSP_FaceInd new_fi = face_set.size();
- face_set.push_back(BSP_MFace());
-
- BSP_MFace & face = face_set[fi];
- BSP_MFace &new_face = face_set[new_fi];
-
- vector<BSP_VertexInd>::const_iterator f_verts_it = face.m_verts.begin();
- vector<BSP_VertexInd>::const_iterator f_verts_end = face.m_verts.end();
-
- MT_Point3 ptA = vertex_set[face.m_verts.back()].m_pos;
- BSP_Classification prev_class = BSP_Classification(vertex_set[face.m_verts.back()].OpenTag());
-
- for (; f_verts_it != f_verts_end;++f_verts_it) {
-
- BSP_Classification v_class = BSP_Classification(vertex_set[*f_verts_it].OpenTag());
-
- if (v_class == e_classified_on) {
- m_in_loop.push_back(*f_verts_it);
- m_out_loop.push_back(*f_verts_it);
- prev_class = e_classified_on;
- continue;
- } else
- if (v_class == e_classified_in) {
- m_in_loop.push_back(*f_verts_it);
- } else
- if (v_class == e_classified_out) {
- m_out_loop.push_back(*f_verts_it);
- }
-
- if ((prev_class != e_classified_on) &&
- (prev_class != v_class)) {
- // spanning edge
-
- const MT_Point3 & ptB = vertex_set[*f_verts_it].m_pos;
-
- // compute the intersection point of plane and ptA->ptB
- MT_Vector3 v = ptB - ptA;
- MT_Scalar sideA = plane.signedDistance(ptA);
-
- MT_Scalar epsilon = -sideA/plane.Normal().dot(v);
- MT_Point3 new_p = ptA + (v * epsilon);
-
- BSP_VertexInd new_vi(vertex_set.size());
- vertex_set.push_back(BSP_MVertex(new_p));
-
- m_in_loop.push_back(new_vi);
- m_out_loop.push_back(new_vi);
- }
-
- ptA = vertex_set[*f_verts_it].m_pos;
- prev_class = v_class;
- }
-
- // Ok should have 2 loops 1 representing the in_loop and
- // 1 for the out_loop
-
- new_face.m_verts = m_out_loop;
- face.m_verts = m_in_loop;
-
- new_face.m_plane = face.m_plane;
-
- // we don't bother maintaining any of the other
- // properties.
-
- fin = fi;
- fout = new_fi;
-
- m_in_loop.clear();
- m_out_loop.clear();
-};
-
-
diff --git a/intern/bsp/intern/BSP_CSGNCMeshSplitter.h b/intern/bsp/intern/BSP_CSGNCMeshSplitter.h
deleted file mode 100755
index 407a4c8b46f..00000000000
--- a/intern/bsp/intern/BSP_CSGNCMeshSplitter.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSP_CSGNCMeshSplitter_h
-#define BSP_CSGNCMeshSplitter_h
-
-class BSP_MeshFragment;
-class MT_Plane3;
-class BSP_CSGMesh;
-
-#include "BSP_MeshPrimitives.h"
-#include "../extern/CSG_BooleanOps.h"
-#include "BSP_CSGISplitter.h"
-
-
-/**
- * This class contains splitting functions for a CSGMesh.
- * The atomic operation of a bsp CSG algorithm is to split
- * a mesh fragment (connected collection of polygons contained
- * in a convex cell) by a plane. This class makes no attempt
- * to maintain edge connectivity in the mesh. It just rips
- * up the polygons. This is fine for tree building.
- */
-
-
-class BSP_CSGNCMeshSplitter : public BSP_CSGISplitter
-{
-public :
-
- /// construction
-
- BSP_CSGNCMeshSplitter(
- );
-
- BSP_CSGNCMeshSplitter(
- const BSP_CSGNCMeshSplitter & other
- );
-
- /**
- * @section BSP specific mesh operations.
- * Inherited from BSP_CSGISplitter
- */
-
- /**
- * Split a mesh fragment wrt plane. Generates 3 mesh fragments,
- * in, out and on. Only splits polygons - not edges, does not maintain
- * connectivity information. The contents of frag are consumed by this oepration.
- */
- void
- Split(
- const MT_Plane3& plane,
- BSP_MeshFragment *frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
- );
-
- /// Split the entire mesh with respect to the plane.
-
- void
- Split(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_MeshFragment *spanning_frag
- );
-
- ~BSP_CSGNCMeshSplitter(
- );
-
-private :
-
- void
- SplitImp(
- BSP_CSGMesh & mesh,
- const MT_Plane3& plane,
- const std::vector<BSP_FaceInd> & spanning_faces,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- std::vector<BSP_VertexInd> & classified_verts
-
- );
-
- void
- SplitPolygon(
- const MT_Plane3 &plane,
- BSP_CSGMesh & mesh,
- BSP_FaceInd fi,
- BSP_FaceInd &fin,
- BSP_FaceInd &fout
- );
-
- /// Cached helpers
-
- /// Split function responsibe for:
- std::vector<BSP_FaceInd> m_spanning_faces;
- std::vector<BSP_VertexInd> m_tagged_verts;
-
- /// SplitPolygon responsible for:
- std::vector<BSP_FaceInd> m_in_loop,m_out_loop,m_on_loop;
-
-};
-
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_CSGUserData.cpp b/intern/bsp/intern/BSP_CSGUserData.cpp
deleted file mode 100755
index fec5ff560e6..00000000000
--- a/intern/bsp/intern/BSP_CSGUserData.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BSP_CSGUserData.h"
-
-
-
-BSP_CSGUserData::
-BSP_CSGUserData(
- const int width
-):
- m_width (width)
-{
-}
-
-/**
- * Add a new uninitialized record to the end of the
- * array
- */
-
- void
-BSP_CSGUserData::
-IncSize(
-){
- m_data.insert(m_data.end(),m_width,char(0));
-}
-
- int
-BSP_CSGUserData::
-Duplicate(
- void *record
-){
- if (m_width) {
- int output = Size();
- IncSize();
-
- memcpy(&m_data[ m_data.size() - m_width ], record, m_width);
-
- return output;
- }
- return 0;
-}
-
- void
-BSP_CSGUserData::
-Duplicate(
- int record_index
-){
- if (m_width) {
- IncSize();
- memcpy(&m_data[ m_data.size() - m_width ],
- &m_data[ record_index * m_width], m_width);
- }
-}
-
-
- void
-BSP_CSGUserData::
-Copy(
- void *output,
- int pos
-){
- if (m_width) {
- memcpy(output, &m_data[m_width*pos],m_width);
- }
-}
- void
-BSP_CSGUserData::
-Reserve(
- int size
-){
- m_data.reserve(size * m_width);
-}
-
-
-/// Return the width of an individual record
-
- int
-BSP_CSGUserData::
-Width(
-) const{
- return m_width;
-}
-
-
-/// return the current number of records stored in the array.
- int
-BSP_CSGUserData::
-Size(
-) const {
- if (m_width == 0) return 0;
- return m_data.size() / m_width;
-}
-
-
-/// return a pointer to the start of the nth record in the array.
-
- void *
-BSP_CSGUserData::
-operator [] (
- const int pos
-){
- return &m_data[ m_width*pos ];
-}
-
diff --git a/intern/bsp/intern/BSP_CSGUserData.h b/intern/bsp/intern/BSP_CSGUserData.h
deleted file mode 100755
index 8b008b83845..00000000000
--- a/intern/bsp/intern/BSP_CSGUserData.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSP_CSGUserData_h
-#define BSP_CSGUserData_h
-
-#include <vector>
-
-/**
- * This data represents a continuous block of
- * data of unknown type. This holds the user
- * data during a BSP operation.
- */
-
-class BSP_CSGUserData
-{
-public :
-
- /**
- * width defines the size in bytes of a
- * single element (record) of user data
- */
-
- BSP_CSGUserData(
- const int width
- );
-
- /**
- * Reserve some space in the array
- */
- void
- Reserve(
- int size
- );
-
- /**
- * Add a new uninitialized record to the end of the
- * array
- */
-
- void
- IncSize(
- );
-
- /**
- * duplicate a recod and insert it into the end of the array
- * returns the index of the new record. Make sure that the
- * record does not belong to this buffer as this can cause errors.
- */
-
- int
- Duplicate(
- void *
- );
-
- void
- Duplicate(
- int record_index
- );
-
- /**
- * Copies the record at position pos in the array to the
- * memory pointed to by output
- */
-
- void
- Copy(
- void *output,
- int pos
- );
-
- /// Return the width of an individual record
-
- int
- Width(
- ) const;
-
-
- /// return the current number of records stored in the array.
- int
- Size(
- ) const;
-
-
- /// return a pointer to the start of the nth record in the array.
-
- void *
- operator [] (
- const int pos
- );
-
-private :
-
- /// Private - force use of public constructor only.
-
- BSP_CSGUserData(
- );
-
-
- /// The block of data.
- std::vector<char> m_data;
- /// The width of a record in this array.
- int m_width;
-};
-
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_FragNode.cpp b/intern/bsp/intern/BSP_FragNode.cpp
deleted file mode 100755
index c23b210a700..00000000000
--- a/intern/bsp/intern/BSP_FragNode.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BSP_CSGMesh.h"
-
-#include "BSP_FragNode.h"
-#include "BSP_CSGISplitter.h"
-
-
-BSP_FragNode::
-BSP_FragNode(
- const MT_Plane3 & plane,
- BSP_CSGMesh *mesh
-):
- m_plane(plane),
- m_in_tree(mesh),
- m_out_tree(mesh)
-{
-}
-
-/**
- * Public methods
- * Should only be called by BSP_FragTree
- */
-
-BSP_FragNode::
-~BSP_FragNode(
-){
- // nothing to do
-}
-
- MEM_SmartPtr<BSP_FragNode>
-BSP_FragNode::
-New(
- const MT_Plane3 & plane,
- BSP_CSGMesh *mesh
-){
- return new BSP_FragNode(plane,mesh);
-}
-
-
- void
-BSP_FragNode::
-Build(
- BSP_MeshFragment *frag,
- BSP_CSGISplitter & splitter
-){
- // we know there must be some polygons still in
- // the fragment otherwise this node would not hve been
- // constructed.
-
- BSP_CSGMesh *mesh = frag->Mesh();
-
- // split the incoming fragment by the plane
- // generating in,out,on fragments which are
- // passed down the in and out trees.
-
- BSP_MeshFragment in_frag(mesh,e_classified_in),out_frag(mesh,e_classified_out);
- MEM_SmartPtr<BSP_MeshFragment> on_frag = new BSP_MeshFragment(mesh,e_classified_on);
- splitter.Split(m_plane,frag,&in_frag,&out_frag,on_frag,NULL);
-
- // We are not interested in the on fragments.
- on_frag.Delete();
-
- m_in_tree.Build(&in_frag,splitter);
- m_out_tree.Build(&out_frag,splitter);
-}
-
- void
-BSP_FragNode::
-Push(
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *output,
- const BSP_Classification keep,
- const bool dominant,
- BSP_CSGISplitter & splitter
-){
- BSP_CSGMesh *mesh = in_frag->Mesh();
-
-
- MEM_SmartPtr<BSP_MeshFragment> inside_frag = new BSP_MeshFragment(mesh,e_classified_in);
- MEM_SmartPtr<BSP_MeshFragment> outside_frag = new BSP_MeshFragment(mesh,e_classified_out);
- MEM_SmartPtr<BSP_MeshFragment> on_frag = new BSP_MeshFragment(mesh,e_classified_on);
-
- // deal with memory exceptions here.
-
- splitter.Split(m_plane,in_frag,inside_frag,outside_frag,on_frag,NULL);
-
- // deal with the on_fragments.
-
- if (on_frag->FaceSet().size()) {
-
- // The on fragment contains polygons that are outside both subtrees and polygons
- // that are inside one or more sub trees. If we are taking the union then we can
- // immediately add that first set of polygons to the ouput. We must then decide what
- // to do with potenially overlapping polygons from both objects. If we assume both
- // objects are closed then we can identify the conflict zones as
- // polygons outside B- and inside B+
- // polygons outside B+ and inside B-
-
- // In these conflict zones we must choose a dominant object this is indicated
- // by the bool parameter to this function. If the object is not dominant then
- // we do nothing inside these conflict zones.
- // The first set should correspond with on polygons from object B with the same
- // orientation as this node. The second corresponding with polygons with opposite
- // orientation.
- // We don't want to replace polygons from A with polygons of opposite orientation
- // from B. So we split up the on polygons of A into 2 sets according to their orientation.
- // We add to output (A- out B-) in B+ and (A+ out B+) in B-
-
-
-#if 1
-
- if (keep == e_classified_out) {
- // we are doing a union operation.
- // Make sure that this is not a leaf node.
- if(m_in_tree.m_node != NULL || m_out_tree.m_node != NULL) {
- BSP_MeshFragment frag_outBneg_outBpos(mesh,e_classified_on);
- BSP_MeshFragment temp1(on_frag.Ref());
- m_in_tree.Push(
- &temp1,&frag_outBneg_outBpos,
- e_classified_out,e_classified_on,
- false,splitter
- );
-
- m_out_tree.Push(
- &frag_outBneg_outBpos,output,e_classified_out,e_classified_on,
- false,splitter
- );
- }
-#if 1
- if (dominant) {
-
- // Here we compute the intersection zones.
- BSP_MeshFragment frag_on_pos(mesh,e_classified_on),frag_on_neg(mesh,e_classified_on);
- on_frag->ClassifyOnFragments(m_plane,&frag_on_pos,&frag_on_neg);
-
- BSP_MeshFragment temp1(mesh,e_classified_in);
-
- // push -ve fragments down inside tree, push result down outside
- m_in_tree.Push(&frag_on_neg,&temp1,e_classified_out,e_classified_on,false,splitter);
- m_out_tree.Push(&temp1,output,e_classified_in,e_classified_on,false,splitter);
- temp1.FaceSet().clear();
-
- // push +ve fragments down outside tree, push result down inside.
- m_out_tree.Push(&frag_on_pos,&temp1,e_classified_out,e_classified_on,false,splitter);
- m_in_tree.Push(&temp1,output,e_classified_in,e_classified_on,false,splitter);
- }
-#endif
- } else if (keep == e_classified_in) {
-
- // we are doing an intersection
-
- // A = on_frag in X+ out X-
- // B = on_frag in X- out X+
- // C = on_frag in X- in X+
-
- // If X+ is NULL then A = F out X-, B = 0, C = F in X-
- // If X- is NULLL then A = 0, B = F out X+ , C = F in X+
- // If both NULL then A = C = 0, B = F
-
- // Conflicts only happen in A and B.
- // negative fragments only in A, positive fragments only in B, anything in C.
- // First compute F in C an add to ouput.
-
- BSP_MeshFragment frag_on_pos(mesh,e_classified_on),frag_on_neg(mesh,e_classified_on);
- on_frag->ClassifyOnFragments(m_plane,&frag_on_pos,&frag_on_neg);
-
- if (m_in_tree.m_node == NULL) {
- if (m_out_tree.m_node == NULL) {
- // pick stuff that points in the same direction as this node
- // only if priority.
- if (dominant) {
- // pass +ve frags into B = F.
- // trick just pass down in tree... just adds to output.
- m_in_tree.Push(&frag_on_pos,output,e_classified_in,e_classified_on,false,splitter);
- }
- } else {
- // A = 0, B= F out X+ , C = F in X+
- if (dominant) {
- // m_out_tree.Push(&frag_on_pos,output,e_classified_out,e_classified_on,false,splitter);
- m_out_tree.Push(on_frag,output,e_classified_in,e_classified_on,false,splitter);
- }
- }
- } else {
- if (m_out_tree.m_node == NULL) {
- // A = F out X-, B=0, C = F in X-
- if (dominant) {
- // m_in_tree.Push(&frag_on_neg,output,e_classified_out,e_classified_on,false,splitter);
- m_in_tree.Push(on_frag,output,e_classified_in,e_classified_on,false,splitter);
- }
- } else {
- // The normals case
- if (dominant) {
- BSP_MeshFragment temp1(mesh,e_classified_on);
- m_out_tree.Push(&frag_on_neg,&temp1,e_classified_in,e_classified_on,false,splitter);
- m_in_tree.Push(&temp1,output,e_classified_out,e_classified_on,false,splitter);
- temp1.FaceSet().clear();
-
- m_in_tree.Push(&frag_on_pos,&temp1,e_classified_in,e_classified_on,false,splitter);
- m_out_tree.Push(&temp1,output,e_classified_out,e_classified_on,false,splitter);
- }
- BSP_MeshFragment temp1(mesh,e_classified_on);
- m_in_tree.Push(on_frag,&temp1,e_classified_in,e_classified_on,false,splitter);
- m_out_tree.Push(&temp1,output,e_classified_in,e_classified_on,false,splitter);
- }
- }
- }
-
-
-#endif
- on_frag.Delete();
- }
-
- m_in_tree.Push(inside_frag,output,keep,e_classified_in,dominant,splitter);
- m_out_tree.Push(outside_frag,output,keep,e_classified_out,dominant,splitter);
-};
-
- void
-BSP_FragNode::
-Classify(
- BSP_MeshFragment * frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_CSGISplitter & splitter
-){
-
- BSP_CSGMesh *mesh = frag->Mesh();
-
- MEM_SmartPtr<BSP_MeshFragment> inside_frag = new BSP_MeshFragment(mesh,e_classified_in);
- MEM_SmartPtr<BSP_MeshFragment> outside_frag = new BSP_MeshFragment(mesh,e_classified_out);
- MEM_SmartPtr<BSP_MeshFragment> frag_on = new BSP_MeshFragment(mesh,e_classified_on);
-
- splitter.Split(m_plane,frag,inside_frag,outside_frag,frag_on,NULL);
-
- // copy the on fragments into the on_frag output.
-
- if (frag_on->FaceSet().size()) {
-
- on_frag->FaceSet().insert(
- on_frag->FaceSet().end(),
- frag_on->FaceSet().begin(),
- frag_on->FaceSet().end()
- );
- }
-
- frag_on.Delete();
-
- // pass everything else down the tree.
-
- m_in_tree.Classify(inside_frag,in_frag,out_frag,on_frag,e_classified_in,splitter);
- m_out_tree.Classify(outside_frag,in_frag,out_frag,on_frag,e_classified_out,splitter);
-}
-
-
-/**
- * Accessor methods
- */
-
- BSP_FragTree &
-BSP_FragNode::
-InTree(
-){
- return m_in_tree;
-}
-
- BSP_FragTree &
-BSP_FragNode::
-OutTree(
-){
- return m_out_tree;
-}
-
- MT_Plane3&
-BSP_FragNode::
-Plane(
-){
- return m_plane;
-}
-
-
-
-
-
diff --git a/intern/bsp/intern/BSP_FragNode.h b/intern/bsp/intern/BSP_FragNode.h
deleted file mode 100755
index ed4b6a9f609..00000000000
--- a/intern/bsp/intern/BSP_FragNode.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSP_FragNode_h
-#define BSP_FragNode_h
-
-#include "BSP_FragTree.h"
-#include "BSP_MeshFragment.h"
-#include "MT_Plane3.h"
-
-class BSP_CSGISplitter;
-
-class BSP_FragNode : public MEM_NonCopyable
-{
-private:
-
- /**
- * The plane defining this node.
- */
-
- MT_Plane3 m_plane;
-
- /**
- * Children of this node.
- */
-
- BSP_FragTree m_in_tree;
- BSP_FragTree m_out_tree;
-
-private :
-
- BSP_FragNode(
- const MT_Plane3 & plane,
- BSP_CSGMesh *mesh
- );
-
-public :
-
- /**
- * Public methods
- * Should only be called by BSP_FragTree
- */
-
- ~BSP_FragNode(
- );
-
- static
- MEM_SmartPtr<BSP_FragNode>
- New(
- const MT_Plane3 & plane,
- BSP_CSGMesh *mesh
- );
-
- void
- Build(
- BSP_MeshFragment *frag,
- BSP_CSGISplitter & splitter
- );
-
- void
- Push(
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *output,
- const BSP_Classification keep,
- const bool dominant,
- BSP_CSGISplitter & splitter
- );
-
- void
- Classify(
- BSP_MeshFragment * frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_CSGISplitter & splitter
- );
-
- /**
- * Accessor methods
- */
-
- BSP_FragTree &
- InTree(
- );
-
- BSP_FragTree &
- OutTree(
- );
-
- MT_Plane3&
- Plane(
- );
-
-};
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_FragTree.cpp b/intern/bsp/intern/BSP_FragTree.cpp
deleted file mode 100755
index e38bf42d4b5..00000000000
--- a/intern/bsp/intern/BSP_FragTree.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BSP_FragTree.h"
-
-#include "BSP_FragNode.h"
-#include "BSP_CSGMesh.h"
-#include "BSP_MeshFragment.h"
-#include "MT_Plane3.h"
-#include "BSP_CSGException.h"
-#include <vector>
-#include "BSP_CSGISplitter.h"
-
-using namespace std;
-
- MEM_SmartPtr<BSP_FragTree>
-BSP_FragTree::
-New(
- BSP_CSGMesh *mesh,
- BSP_CSGISplitter & splitter
-){
- if (mesh == NULL) return NULL;
- if (mesh->FaceSet().size() == 0) return NULL;
-
- // This is the external tree construction method
- // (not the internal method!)
- // We need to build a tree root with an initial
- // node based on the mesh rather than a mesh fragment.
-
- // For now we pick an arbitrary polygon for the initial
- // plane.
-
- vector<BSP_MVertex> verts = mesh->VertexSet();
- const BSP_MFace & f0 = mesh->FaceSet()[0];
-
- MT_Plane3 plane = f0.m_plane;
-
- MEM_SmartPtr<BSP_FragTree> output(new BSP_FragTree(mesh));
- MEM_SmartPtr<BSP_FragNode> node(BSP_FragNode::New(plane,mesh));
-
- if (output == NULL || node == NULL) return NULL;
-
- // Generate initial mesh fragments for this plane pass into
- // first node.
-
- BSP_MeshFragment frag_in(mesh,e_classified_in),frag_out(mesh,e_classified_out);
-
- MEM_SmartPtr<BSP_MeshFragment> on_frag = new BSP_MeshFragment(mesh,e_classified_on);
-
- splitter.Split(*mesh,plane,&frag_in,&frag_out,on_frag,NULL);
-
- // We are not interested in the on_frag.
- on_frag.Delete();
-
- // Build the in_tree of the first node(recursive)
- node->InTree().Build(&frag_in,splitter);
-
- // Build the out tree of the first node(recursive)
- node->OutTree().Build(&frag_out,splitter);
-
- output->m_node = node;
-
- return output;
-}
-
- void
-BSP_FragTree::
-Classify(
- BSP_CSGMesh *mesh,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_CSGISplitter & splitter
-){
-
- if (mesh == NULL) return;
- if (mesh->FaceSet().size() == 0) return;
- if (m_node == NULL) return;
-
- BSP_MeshFragment frag_in(mesh,e_classified_in);
- BSP_MeshFragment frag_out(mesh,e_classified_out);
- BSP_MeshFragment frag_on(mesh,e_classified_on);
- BSP_MeshFragment frag_spanning(mesh,e_classified_spanning);
-
- splitter.Split(*mesh,m_node->Plane(),&frag_in,&frag_out,&frag_on,NULL);
-
- if (frag_on.FaceSet().size()) {
-
- on_frag->FaceSet().insert(
- on_frag->FaceSet().end(),
- frag_on.FaceSet().begin(),
- frag_on.FaceSet().end()
- );
-
- frag_on.FaceSet().clear();
- }
-
- // recurse into subtrees.
- m_node->InTree().Classify(&frag_in,in_frag,out_frag,on_frag,e_classified_in,splitter);
- m_node->OutTree().Classify(&frag_out,in_frag,out_frag,on_frag,e_classified_out,splitter);
-
-}
-
-
-
-
-
-BSP_FragTree::
-~BSP_FragTree(
-){
- // nothing to do
-}
-
-BSP_FragTree::
-BSP_FragTree(
- BSP_CSGMesh * mesh
-):
- m_mesh(mesh)
-{
- //nothing to do
-}
-
-BSP_FragTree::
-BSP_FragTree(
-){
- // nothing to do
-}
-
- void
-BSP_FragTree::
-Build(
- BSP_MeshFragment * frag,
- BSP_CSGISplitter & splitter
-){
-
- // Node must be NULL because we are building the tree.
-
- MT_assert(m_node == NULL);
-
- if (frag->FaceSet().size()) {
-
- // choose a plane for the node. The first index in this
- // mesh fragment will do for now.
-
- // choose a random splitting plane
-
- MT_Plane3 plane;
- {
- int rand_index;
-#if 1
- if (frag->FaceSet().size() > 1) {
- rand_index = rand() % frag->FaceSet().size();
- } else {
- rand_index = 0;
- }
-#else
- rand_index = 0;
-#endif
-
- const BSP_MFace & f0 = m_mesh->FaceSet()[frag->FaceSet()[rand_index]];
- plane = f0.m_plane;
- }
-
- // build the node.
- m_node = BSP_FragNode::New(plane,frag->Mesh());
-
- if (m_node == NULL) {
- BSP_CSGException e(e_tree_build_error);
- throw(e);
- }
-
- m_node->Build(frag,splitter);
- }
-}
-
-
- void
-BSP_FragTree::
-Push(
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *output,
- const BSP_Classification keep,
- const BSP_Classification current,
- const bool dominant,
- BSP_CSGISplitter & splitter
-){
-
- if (in_frag->FaceSet().size()) {
-
- if (m_node == NULL) {
-
- // we have reached a leaf node.
- // if the current classification matches
- // the classification we want to keep
- // copy the polygons of the current
- // fragment onto the output
- vector<BSP_FaceInd>::const_iterator in_frag_it = in_frag->FaceSet().begin();
- vector<BSP_FaceInd>::const_iterator in_frag_end = in_frag->FaceSet().end();
-
- if (keep == current || current == e_classified_on) {
- for (;in_frag_it != in_frag_end; ++ in_frag_it) {
- output->FaceSet().push_back(*in_frag_it);
- }
-
- in_frag->FaceSet().clear();
- }
- } else {
-
- m_node->Push(in_frag,output,keep,dominant,splitter);
- }
- }
-}
-
-
- void
-BSP_FragTree::
-Classify(
- BSP_MeshFragment * frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- const BSP_Classification current,
- BSP_CSGISplitter & splitter
-){
-
- if (frag->FaceSet().size()) {
-
- if (m_node == NULL) {
-
- vector<BSP_FaceInd>::const_iterator frag_it = frag->FaceSet().begin();
- vector<BSP_FaceInd>::const_iterator frag_end = frag->FaceSet().end();
-
- BSP_MeshFragment *output;
- if (current == e_classified_in) {
- output = in_frag;
- } else {
- //must be e_classified_out
- output = out_frag;
- }
- // Copy the selected indices into the correct output fragment.
-
- for (;frag_it != frag_end; ++ frag_it) {
- output->FaceSet().push_back(*frag_it);
- }
-
- frag->FaceSet().clear();
- } else {
-
- m_node->Classify(frag,in_frag,out_frag,on_frag,splitter);
- }
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/intern/bsp/intern/BSP_FragTree.h b/intern/bsp/intern/BSP_FragTree.h
deleted file mode 100755
index caf7234d739..00000000000
--- a/intern/bsp/intern/BSP_FragTree.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSP_FragTree_h
-#define BSP_FragTree_h
-
-class BSP_FragNode;
-
-#include "MEM_SmartPtr.h"
-#include "MEM_NonCopyable.h"
-#include "BSP_MeshPrimitives.h"
-
-class BSP_CSGMesh;
-class BSP_MeshFragment;
-class BSP_CSGISplitter;
-
-class BSP_FragTree : public MEM_NonCopyable
-{
-public :
-
- /**
- * Create a new BSP_FragTree allocated
- * on the heap for mesh. Note mesh will
- * be divided up by this operation. If you
- * want to retain the original mesh make a copy
- * of it first.
- */
-
- static
- MEM_SmartPtr<BSP_FragTree>
- New(
- BSP_CSGMesh *mesh,
- BSP_CSGISplitter & splitter
- );
-
-
- /**
- * Push a mesh fragment down the tree,
- * splitting the mesh as it goes.
- * upon reaching leaves it puts polygons from fragments
- * of type keep into the output fragment.
- */
-
- void
- Push(
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *output,
- const BSP_Classification keep,
- const BSP_Classification current,
- const bool dominant,
- BSP_CSGISplitter & splitter
- );
-
- void
- Classify(
- BSP_CSGMesh *mesh,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- BSP_CSGISplitter & splitter
- );
-
-
- ~BSP_FragTree(
- );
-
-private :
-
- friend class BSP_FragNode;
-
- BSP_FragTree(
- );
-
- BSP_FragTree(
- BSP_CSGMesh *mesh
- );
-
- void
- Build(
- BSP_MeshFragment * frag,
- BSP_CSGISplitter & splitter
- );
-
-
- void
- Classify(
- BSP_MeshFragment * frag,
- BSP_MeshFragment *in_frag,
- BSP_MeshFragment *out_frag,
- BSP_MeshFragment *on_frag,
- const BSP_Classification current,
- BSP_CSGISplitter & splitter
- );
-
-private :
-
- /**
- * pointer to the mesh for this tree.
- * Tree is only valid whilst mesh is around.
- */
-
- BSP_CSGMesh *m_mesh;
-
- /**
- * The node owned by this tree.
- */
-
- MEM_SmartPtr<BSP_FragNode> m_node;
-
-};
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_MeshFragment.cpp b/intern/bsp/intern/BSP_MeshFragment.cpp
deleted file mode 100755
index cd79078f056..00000000000
--- a/intern/bsp/intern/BSP_MeshFragment.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "BSP_MeshFragment.h"
-
-#include "BSP_CSGMesh.h"
-#include "MT_Plane3.h"
-#include <math.h>
-
-using namespace std;
-
-
-BSP_MeshFragment::
-BSP_MeshFragment(
- BSP_CSGMesh *mesh,
- BSP_Classification classification
-):
- m_mesh(mesh),
- m_classification(classification)
-{
- MT_assert(m_mesh != NULL);
- //nothing to do
-}
-
-const
- vector<BSP_FaceInd> &
-BSP_MeshFragment::
-FaceSet(
-) const {
- return m_faces;
-}
-
- vector<BSP_FaceInd> &
-BSP_MeshFragment::
-FaceSet(
-) {
- return m_faces;
-}
-
- BSP_CSGMesh *
-BSP_MeshFragment::
-Mesh(
-){
- return m_mesh;
-}
-
- BSP_CSGMesh *
-BSP_MeshFragment::
-Mesh(
-) const {
- return m_mesh;
-}
-
- BSP_Classification
-BSP_MeshFragment::
-ClassifyPolygon(
- const MT_Plane3 &plane,
- const BSP_MFace & face,
- std::vector<BSP_MVertex>::const_iterator verts,
- vector<BSP_VertexInd> & visited_verts
-){
-
- vector<BSP_VertexInd>::const_iterator f_vi_end = face.m_verts.end();
- vector<BSP_VertexInd>::const_iterator f_vi_it = face.m_verts.begin();
-
- BSP_Classification p_class = e_unclassified;
-
- int on_count = 0;
-
- for (;f_vi_it != f_vi_end; ++f_vi_it) {
-
- BSP_MVertex & vert = const_cast<BSP_MVertex &>(verts[int(*f_vi_it)]);
-
- if (BSP_Classification(vert.OpenTag()) == e_unclassified)
- {
- MT_Scalar sdistance = plane.signedDistance(vert.m_pos);
- if (fabs(sdistance) <= BSP_SPLIT_EPSILON) {
- // this vertex is on
- vert.SetOpenTag(e_classified_on);
- } else
- if (sdistance > MT_Scalar(0)) {
- vert.SetOpenTag(e_classified_out);
- } else {
- vert.SetOpenTag(e_classified_in);
- }
- visited_verts.push_back(*f_vi_it);
- }
- BSP_Classification v_class = BSP_Classification(vert.OpenTag());
-
- if (v_class == e_classified_on) on_count++;
-
-
- if (p_class == e_unclassified || p_class == e_classified_on) {
- p_class = v_class;
- } else
- if (p_class == e_classified_spanning) {
- } else
- if (p_class == e_classified_in) {
- if (v_class == e_classified_out) {
- p_class = e_classified_spanning;
- }
- } else {
- if (v_class == e_classified_in) {
- p_class = e_classified_spanning;
- }
- }
- }
-
- if (on_count > 2) p_class = e_classified_on;
-
- return p_class;
-}
-
-
-// Classify this mesh fragment with respect
-// to plane. The index sets of this fragment
-// are consumed by this action. Vertices
-// are tagged with a classification enum.
-
- void
-BSP_MeshFragment::
-Classify(
- const MT_Plane3 & plane,
- BSP_MeshFragment * in_frag,
- BSP_MeshFragment * out_frag,
- BSP_MeshFragment * on_frag,
- vector<BSP_FaceInd> & spanning_faces,
- vector<BSP_VertexInd> & visited_verts
-){
-
- vector<BSP_MVertex> & vertex_set = m_mesh->VertexSet();
- vector<BSP_MFace> & face_set = m_mesh->FaceSet();
-
- // Now iterate through the polygons and classify.
-
- vector<BSP_FaceInd>::const_iterator fi_end = m_faces.end();
- vector<BSP_FaceInd>::iterator fi_it = m_faces.begin();
-
- vector<BSP_FaceInd> & face_in_set = in_frag->FaceSet();
- vector<BSP_FaceInd> & face_out_set = out_frag->FaceSet();
- vector<BSP_FaceInd> & face_on_set = on_frag->FaceSet();
-
- for (;fi_it != fi_end; ++fi_it) {
-
- BSP_Classification p_class = ClassifyPolygon(
- plane,
- face_set[*fi_it],
- vertex_set.begin(),
- visited_verts
- );
- // p_class now holds the classification for this polygon.
- // assign to the appropriate bucket.
-
- if (p_class == e_classified_in) {
- face_in_set.push_back(*fi_it);
- } else
- if (p_class == e_classified_out) {
- face_out_set.push_back(*fi_it);
- } else
- if (p_class == e_classified_on) {
- face_on_set.push_back(*fi_it);
- } else {
- spanning_faces.push_back(*fi_it);
- // This is assigned later when we split the polygons in two.
- }
- }
-
- m_faces.clear();
-
-}
-
- void
-BSP_MeshFragment::
-Classify(
- BSP_CSGMesh & mesh,
- const MT_Plane3 & plane,
- BSP_MeshFragment * in_frag,
- BSP_MeshFragment * out_frag,
- BSP_MeshFragment * on_frag,
- vector<BSP_FaceInd> & spanning_faces,
- vector<BSP_VertexInd> & visited_verts
-){
-
- vector<BSP_MVertex> & vertex_set = mesh.VertexSet();
- vector<BSP_MFace> & face_set = mesh.FaceSet();
-
- // Now iterate through the polygons and classify.
-
- int fi_end = mesh.FaceSet().size();
- int fi_it = 0;
-
- vector<BSP_FaceInd> & face_in_set = in_frag->FaceSet();
- vector<BSP_FaceInd> & face_out_set = out_frag->FaceSet();
- vector<BSP_FaceInd> & face_on_set = on_frag->FaceSet();
-
- for (;fi_it != fi_end; ++fi_it) {
-
- BSP_Classification p_class = ClassifyPolygon(
- plane,
- face_set[fi_it],
- vertex_set.begin(),
- visited_verts
- );
- // p_class now holds the classification for this polygon.
- // assign to the appropriate bucket.
-
- if (p_class == e_classified_in) {
- face_in_set.push_back(fi_it);
- } else
- if (p_class == e_classified_out) {
- face_out_set.push_back(fi_it);
- } else
- if (p_class == e_classified_on) {
- face_on_set.push_back(fi_it);
- } else {
- spanning_faces.push_back(fi_it);
- }
- }
-
-}
- void
-BSP_MeshFragment::
-ClassifyOnFragments(
- const MT_Plane3 &plane,
- BSP_MeshFragment *pos_frag,
- BSP_MeshFragment *neg_frag
-){
-
- vector<BSP_MFace> & face_set = m_mesh->FaceSet();
- vector<BSP_FaceInd>::const_iterator fi_end = m_faces.end();
- vector<BSP_FaceInd>::iterator fi_it = m_faces.begin();
-
- MT_Scalar d = plane.Scalar();
-
- for (;fi_it != fi_end; ++fi_it) {
- if (fabs(d + face_set[*fi_it].m_plane.Scalar()) > BSP_SPLIT_EPSILON) {
- pos_frag->FaceSet().push_back(*fi_it);
- } else {
- neg_frag->FaceSet().push_back(*fi_it);
- }
- }
-}
-
-BSP_MeshFragment::
-~BSP_MeshFragment(
-){
-}
-
-
diff --git a/intern/bsp/intern/BSP_MeshFragment.h b/intern/bsp/intern/BSP_MeshFragment.h
deleted file mode 100755
index 8ed3b9010e4..00000000000
--- a/intern/bsp/intern/BSP_MeshFragment.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef NAN_INCLUDED_BSP_MeshFragment_h
-#define NAN_INCLUDED_BSP_MeshFragment_h
-
-#define BSP_SPLIT_EPSILON MT_Scalar(1e-5)
-
-#include <vector>
-#include "BSP_MeshPrimitives.h"
-
-
-class BSP_CSGMesh;
-class MT_Plane3;
-/**
- * This class encodes a collection of polygons from a mesh.
- * This class only remains valid when mesh indices do not change
- * internally and of course whilst the mesh is still around.
- *
- * Polygons in the mesh point back to the unique mesh fragment
- * containing them.
- */
-
-
-class BSP_MeshFragment {
-public:
-
- BSP_MeshFragment(
- BSP_CSGMesh *mesh,
- BSP_Classification classification
- );
-
- std::vector<BSP_FaceInd> &
- FaceSet(
- ) ;
-
- const
- std::vector<BSP_FaceInd> &
- FaceSet(
- ) const ;
-
- BSP_CSGMesh *
- Mesh(
- );
-
- BSP_CSGMesh *
- Mesh(
- ) const;
-
-
- // Classify this mesh fragment with respect
- // to plane. The index sets of this fragment
- // are consumed by this action. Vertices
- // are tagged with a classification enum.
-
- void
- Classify(
- const MT_Plane3 & plane,
- BSP_MeshFragment * in_frag,
- BSP_MeshFragment * out_frag,
- BSP_MeshFragment * on_frag,
- std::vector<BSP_FaceInd> & spanning_faces,
- std::vector<BSP_VertexInd> & visited_verts
- );
-
- // Classify all the vertices and faces of mesh, generate
- // in,out and on mesh fragments.
-
- static
- void
- Classify(
- BSP_CSGMesh & mesh,
- const MT_Plane3 & plane,
- BSP_MeshFragment * in_frag,
- BSP_MeshFragment * out_frag,
- BSP_MeshFragment * on_frag,
- std::vector<BSP_FaceInd> & spanning_faces,
- std::vector<BSP_VertexInd> & visited_verts
- );
-
- // Classify the on fragment into
- // 2 sets, the +ve on frags those whose polygon
- // normals point in the same direction as the plane,
- // and the -ve frag whose normals point in the other direction.
-
- void
- ClassifyOnFragments(
- const MT_Plane3 &plane,
- BSP_MeshFragment *pos_frag,
- BSP_MeshFragment *neg_frag
- );
-
-
- ~BSP_MeshFragment(
- );
-
- /**
- * Sanity checkers.
- */
-
-
-private:
-
- // Classify the polygon wrt to the plane
- static
- BSP_Classification
- ClassifyPolygon(
- const MT_Plane3 &plane,
- const BSP_MFace & face,
- std::vector<BSP_MVertex>::const_iterator verts,
- std::vector<BSP_VertexInd> & visited_verts
- );
-
-private :
-
-
- BSP_CSGMesh * m_mesh;
- BSP_Classification m_classification;
- std::vector<BSP_FaceInd> m_faces;
-};
-
-
-#endif
-
diff --git a/intern/bsp/intern/BSP_MeshPrimitives.cpp b/intern/bsp/intern/BSP_MeshPrimitives.cpp
index c9c4873540b..54db5851be3 100755
--- a/intern/bsp/intern/BSP_MeshPrimitives.cpp
+++ b/intern/bsp/intern/BSP_MeshPrimitives.cpp
@@ -243,7 +243,8 @@ SetOpenTag(
BSP_MFace::
BSP_MFace(
):
- m_open_tag(-1)
+ m_open_tag(-1),
+ m_orig_face(0)
{
// nothing to do
}
@@ -261,11 +262,6 @@ Invert(
m_verts.end()
);
- reverse(
- m_fv_data.begin(),
- m_fv_data.end()
- );
-
// invert the normal
m_plane.Invert();
}
diff --git a/intern/bsp/intern/BSP_MeshPrimitives.h b/intern/bsp/intern/BSP_MeshPrimitives.h
index adfdb57e5f5..d245ed02524 100644
--- a/intern/bsp/intern/BSP_MeshPrimitives.h
+++ b/intern/bsp/intern/BSP_MeshPrimitives.h
@@ -36,21 +36,17 @@
#include "MT_Vector3.h"
#include "MT_Plane3.h"
-class BSP_MeshFragment;
-
#include <vector>
typedef CTR_TaggedIndex<24,0x00ffffff> BSP_VertexInd;
typedef CTR_TaggedIndex<24,0x00ffffff> BSP_EdgeInd;
typedef CTR_TaggedIndex<24,0x00ffffff> BSP_FaceInd;
typedef CTR_TaggedIndex<24,0x00ffffff> BSP_FragInd;
-typedef CTR_TaggedIndex<24,0x00ffffff> BSP_UserFVInd;
typedef std::vector<BSP_VertexInd> BSP_VertexList;
typedef std::vector<BSP_EdgeInd> BSP_EdgeList;
typedef std::vector<BSP_FaceInd> BSP_FaceList;
-typedef std::vector<BSP_UserFVInd> BSP_UserFVDataList;
/**
* Enum representing classification of primitives
@@ -227,13 +223,6 @@ public :
BSP_VertexList m_verts;
- // This is a list of face vertex data indices.
- // Each vertex index in the list has an equivalent
- // index into an array of face vertex data. This data
- // is stored externally - the mesh does not know about it's
- // contents.
-
- BSP_UserFVDataList m_fv_data;
// We also store the plane equation of this
// face. Generating on the fly during tree
// construction can lead to a lot of numerical errors.
@@ -242,6 +231,7 @@ public :
MT_Plane3 m_plane;
int m_open_tag;
+ unsigned int m_orig_face;
BSP_MFace(
);
diff --git a/intern/bsp/intern/BSP_Triangulate.cpp b/intern/bsp/intern/BSP_Triangulate.cpp
deleted file mode 100755
index fbfba62b907..00000000000
--- a/intern/bsp/intern/BSP_Triangulate.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#include <stdio.h>
-
-#include <stdlib.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "MT_Plane3.h"
-#include "BSP_Triangulate.h"
-#include "MT_assert.h"
-
-static const MT_Scalar EPSILON = MT_Scalar(1e-10);
-
-using namespace std;
-
-BSP_Triangulate::
-BSP_Triangulate(
-):
- m_xi(0),
- m_yi(1)
-{
-}
-
-BSP_Triangulate::
-~BSP_Triangulate(
-){
-}
-
-
- MT_Scalar
-BSP_Triangulate::
-Area(
- const vector<BSP_MVertex> &verts,
- const BSP_VertexList &contour
-){
-
- int n = contour.size();
-
- MT_Scalar A(0.0);
-
- for(int p=n-1,q=0; q<n; p=q++)
- {
- A+= verts[contour[p]].m_pos[m_xi]*verts[contour[q]].m_pos[m_yi] -
- verts[contour[q]].m_pos[m_xi]*verts[contour[p]].m_pos[m_yi];
- }
- return A*MT_Scalar(0.5);
-}
-
-/*
- InsideTriangle decides if a point P is Inside of the triangle
- defined by A, B, C.
- Or within an epsilon of it.
-*/
-
- bool
-BSP_Triangulate::
-InsideTriangle(
- MT_Scalar Ax, MT_Scalar Ay,
- MT_Scalar Bx, MT_Scalar By,
- MT_Scalar Cx, MT_Scalar Cy,
- MT_Scalar Px, MT_Scalar Py
-){
- MT_Scalar ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
- MT_Scalar cCROSSap, bCROSScp, aCROSSbp;
-
- ax = Cx - Bx; ay = Cy - By;
- bx = Ax - Cx; by = Ay - Cy;
- cx = Bx - Ax; cy = By - Ay;
- apx= Px - Ax; apy= Py - Ay;
- bpx= Px - Bx; bpy= Py - By;
- cpx= Px - Cx; cpy= Py - Cy;
-
- aCROSSbp = ax*bpy - ay*bpx;
- cCROSSap = cx*apy - cy*apx;
- bCROSScp = bx*cpy - by*cpx;
-
- return ((aCROSSbp >= -EPSILON) && (bCROSScp >= -EPSILON) && (cCROSSap >= -EPSILON));
-};
-
- bool
-BSP_Triangulate::
-Snip(
- const vector<BSP_MVertex> &verts,
- const BSP_VertexList &contour,
- int u,int v,
- int w,int n,
- int *V
-){
- int p;
- MT_Scalar Ax, Ay, Bx, By, Cx, Cy, Px, Py;
-
- Ax = verts[contour[V[u]]].m_pos[m_xi];
- Ay = verts[contour[V[u]]].m_pos[m_yi];
-
- Bx = verts[contour[V[v]]].m_pos[m_xi];
- By = verts[contour[V[v]]].m_pos[m_yi];
-
- Cx = verts[contour[V[w]]].m_pos[m_xi];
- Cy = verts[contour[V[w]]].m_pos[m_yi];
-
- // Snip is passes if the area of the candidate triangle is
- // greater than 2*epsilon
- // And if none of the remaining vertices are inside the polygon
- // or within an epsilon of the boundary,
-
- if ( EPSILON > (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) ) return false;
-
- for (p=0;p<n;p++)
- {
- if( (p == u) || (p == v) || (p == w) ) continue;
- Px = verts[contour[V[p]]].m_pos[m_xi];
- Py = verts[contour[V[p]]].m_pos[m_yi];
- if (InsideTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py)) return false;
- }
-
- return true;
-}
-
- bool
-BSP_Triangulate::
-Process(
- const vector<BSP_MVertex> &verts,
- const BSP_VertexList &contour,
- const MT_Plane3 &normal,
- std::vector<int> &result
-){
-
- // Choose major axis of normal and assign
- // 'projection' indices m_xi,m_yi;
-
- int maj_axis = normal.Normal().closestAxis();
-
- if (maj_axis == 0) {
- m_xi = 1; m_yi = 2;
- } else
- if (maj_axis == 1) {
- m_xi = 0; m_yi = 2;
- } else {
- m_xi = 0; m_yi = 1;
- }
-
- /* initialize list of Vertices in polygon */
-
- int n = contour.size();
- if ( n < 3 ) return false;
-
- /* we want a counter-clockwise polygon in V */
- /* to true but we also nead to preserve the winding order
- of polygons going into the routine. We keep track of what
- we did with a little bool */
- bool is_flipped = false;
-
- if ( 0.0f < Area(verts,contour) ) {
- for (int v=0; v<n; v++) m_V.push_back(v);
- } else {
- for(int v=0; v<n; v++) m_V.push_back((n-1)-v);
- is_flipped = true;
- }
-
- int nv = n;
-
- /* remove nv-2 Vertices, creating 1 triangle every time */
- int count = 2*nv; /* error detection */
-
- for(int m=0, v=nv-1; nv>2; )
- {
- /* if we loop, it is probably a non-simple polygon */
- if (0 >= (count--))
- {
-#if 0
- int deb = 0;
- for (deb= 0; deb < contour.size(); deb++) {
- cout << verts[contour[deb]].m_pos << "\n";
- }
- cout.flush();
-#endif
- //** Triangulate: ERROR - probable bad polygon!
- m_V.clear();
- return false;
- }
-
- /* three consecutive vertices in current polygon, <u,v,w> */
- int u = v ; if (nv <= u) u = 0; /* previous */
- v = u+1; if (nv <= v) v = 0; /* new v */
- int w = v+1; if (nv <= w) w = 0; /* next */
-
- /* Try and snip this triangle off from the
- current polygon.*/
-
- if ( Snip(verts,contour,u,v,w,nv, &m_V[0]) )
- {
- int a,b,c,s,t;
-
- /* true names of the vertices */
- a = m_V[u]; b = m_V[v]; c = m_V[w];
-
- /* output Triangle indices*/
- if (is_flipped) {
- result.push_back( c );
- result.push_back( b );
- result.push_back( a );
- } else {
- result.push_back( a );
- result.push_back( b );
- result.push_back( c );
- }
-
- m++;
-
- /* remove v from remaining polygon */
- for(s=v,t=v+1;t<nv;s++,t++) m_V[s] = m_V[t]; nv--;
-
- /* resest error detection counter */
- count = 2*nv;
- }
- }
-
- m_V.clear();
- return true;
-}
-
-
diff --git a/intern/bsp/intern/BSP_Triangulate.h b/intern/bsp/intern/BSP_Triangulate.h
deleted file mode 100755
index 858be88419c..00000000000
--- a/intern/bsp/intern/BSP_Triangulate.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef TRIANGULATE_H
-
-
-#define TRIANGULATE_H
-
-/*****************************************************************/
-/** Static class to triangulate any contour/polygon efficiently **/
-/** You should replace Vector2d with whatever your own Vector **/
-/** class might be. Does not support polygons with holes. **/
-/** Uses STL vectors to represent a dynamic array of vertices. **/
-/** This code snippet was submitted to FlipCode.com by **/
-/** John W. Ratcliff (jratcliff@verant.com) on July 22, 2000 **/
-/** I did not write the original code/algorithm for this **/
-/** this triangulator, in fact, I can't even remember where I **/
-/** found it in the first place. However, I did rework it into **/
-/** the following black-box static class so you can make easy **/
-/** use of it in your own code. Simply replace Vector2d with **/
-/** whatever your own Vector implementation might be. **/
-/*****************************************************************/
-
-#include <vector> // Include STL vector class.
-#include "MT_Point3.h"
-#include "BSP_MeshPrimitives.h"
-
-class MT_Plane3;
-
-class BSP_Triangulate
-{
-public:
-
- BSP_Triangulate(
- );
-
- // triangulate a contour/polygon, places results in STL vector
- // as series of triangles. IT uses the major axis of the normal
- // to turn it into a 2d problem.
-
- // Should chaange this to accept a point array and a list of
- // indices into that point array. Result should be indices of those
- // indices.
- //
- // MT_Point3 global_array
- // vector<BSP_VertexInd> polygon
- // result is vector<int> into polygon.
-
- bool
- Process(
- const std::vector<BSP_MVertex> &verts,
- const BSP_VertexList &contour,
- const MT_Plane3 &normal,
- std::vector<int> &result
- );
-
- // compute area of a contour/polygon
- MT_Scalar
- Area(
- const std::vector<BSP_MVertex> &verts,
- const BSP_VertexList &contour
- );
-
- // decide if point Px/Py is inside triangle defined by
- // (Ax,Ay) (Bx,By) (Cx,Cy)
-
- bool
- InsideTriangle(
- MT_Scalar Ax, MT_Scalar Ay,
- MT_Scalar Bx, MT_Scalar By,
- MT_Scalar Cx, MT_Scalar Cy,
- MT_Scalar Px, MT_Scalar Py
- );
-
- ~BSP_Triangulate(
- );
-
-private:
-
- bool
- Snip(
- const std::vector<BSP_MVertex> &verts,
- const BSP_VertexList &contour,
- int u,
- int v,
- int w,
- int n,
- int *V
- );
-
- int m_xi;
- int m_yi;
-
- // Temporary storage
-
- std::vector<int> m_V;
-
-};
-
-
-#endif
-
diff --git a/intern/bsp/intern/CSG_BooleanOps.cpp b/intern/bsp/intern/CSG_BooleanOps.cpp
index 1a3a149adeb..c6f4c5d34d0 100755
--- a/intern/bsp/intern/CSG_BooleanOps.cpp
+++ b/intern/bsp/intern/CSG_BooleanOps.cpp
@@ -39,9 +39,6 @@
#include "../extern/CSG_BooleanOps.h"
#include "BSP_CSGMesh_CFIterator.h"
-#include "BSP_CSGMeshBuilder.h"
-#include "BSP_CSGHelper.h"
-#include "BSP_CSGUserData.h"
#include "MEM_RefCountPtr.h"
#include "../../boolop/extern/BOP_Interface.h"
@@ -52,9 +49,6 @@ using namespace std;
struct BSP_MeshInfo {
BSP_CSGMesh *output_mesh;
- CSG_MeshPropertyDescriptor obA_descriptor;
- CSG_MeshPropertyDescriptor obB_descriptor;
- CSG_MeshPropertyDescriptor output_descriptor;
};
using namespace std;
@@ -74,45 +68,17 @@ CSG_NewBooleanFunction(
return output;
}
- CSG_MeshPropertyDescriptor
-CSG_DescibeOperands(
- CSG_BooleanOperation * operation,
- CSG_MeshPropertyDescriptor operandA_desciption,
- CSG_MeshPropertyDescriptor operandB_desciption
-){
- BSP_MeshInfo * mesh_info = static_cast<BSP_MeshInfo *>(operation->CSG_info);
-
- mesh_info->obA_descriptor = operandA_desciption;
- mesh_info->obB_descriptor = operandB_desciption;
-
- if (
- (operandA_desciption.user_data_size == operandB_desciption.user_data_size) &&
- (operandA_desciption.user_face_vertex_data_size == operandB_desciption.user_face_vertex_data_size)
- ) {
- // Then both operands have the same sets of data we can cope with this!
- mesh_info->output_descriptor.user_data_size = operandA_desciption.user_data_size;
- mesh_info->output_descriptor.user_face_vertex_data_size = operandA_desciption.user_face_vertex_data_size;
- } else {
- // There maybe some common subset of data we can seperate out but for now we just use the
- // default
- mesh_info->output_descriptor.user_data_size = 0;
- mesh_info->output_descriptor.user_face_vertex_data_size = 0;
- }
- return mesh_info->output_descriptor;
-}
-
/**
* Compute the boolean operation, UNION, INTERSECION or DIFFERENCE
*/
int
CSG_PerformBooleanOperation(
- CSG_BooleanOperation *operation,
- CSG_OperationType op_type,
- CSG_FaceIteratorDescriptor obAFaces,
- CSG_VertexIteratorDescriptor obAVertices,
- CSG_FaceIteratorDescriptor obBFaces,
- CSG_VertexIteratorDescriptor obBVertices,
- CSG_InterpolateUserFaceVertexDataFunc interp_func
+ CSG_BooleanOperation *operation,
+ CSG_OperationType op_type,
+ CSG_FaceIteratorDescriptor obAFaces,
+ CSG_VertexIteratorDescriptor obAVertices,
+ CSG_FaceIteratorDescriptor obBFaces,
+ CSG_VertexIteratorDescriptor obBVertices
){
if (operation == NULL) return 0;
BSP_MeshInfo * mesh_info = static_cast<BSP_MeshInfo *>(operation->CSG_info);
@@ -140,15 +106,8 @@ CSG_PerformBooleanOperation(
BoolOpState boolOpResult;
try {
boolOpResult = BOP_performBooleanOperation( boolType,
- mesh_info->output_descriptor,
(BSP_CSGMesh**) &(mesh_info->output_mesh),
- mesh_info->obB_descriptor,
- obBFaces,
- obBVertices,
- mesh_info->obA_descriptor,
- obAFaces,
- obAVertices,
- interp_func );
+ obAFaces, obAVertices, obBFaces, obBVertices);
}
catch(...) {
return 0;
@@ -221,3 +180,4 @@ CSG_FreeBooleanOperation(
delete(operation);
}
}
+