Diego Borghetti 2007-06-19 00:55:41 +00:00
parent e5cad02e45
commit 31d60b2c8f
10 changed files with 113 additions and 78 deletions

View File

@ -144,6 +144,7 @@ IF(UNIX)
/opt/local/include/freetype2
/opt/csw/include/freetype2
/opt/include/freetype2
NO_DEFAULT_PATH
)
SET(FREETYPE_LIB freetype)

View File

@ -58,30 +58,82 @@ BOP_BSPNode::~BOP_BSPNode()
/**
* Adds a new face to this BSP tree.
* @param p1 first face point.
* @param p2 second face point.
* @param p3 third face point.
* @param pts vector containing face points
* @param plane face plane.
*/
unsigned int BOP_BSPNode::addFace(const MT_Point3& p1,
const MT_Point3& p2,
const MT_Point3& p3,
const MT_Plane3& plane)
unsigned int BOP_BSPNode::addFace(BOP_BSPPoints pts,
const MT_Plane3& plane )
{
unsigned int newDeep = 0;
BOP_TAG tag = BOP_createTAG(testPoint(p1), testPoint(p2), testPoint(p3));
if ((tag & IN_IN_IN) != 0) {
BOP_TAG tag = ON;
// find out if any points on the "face" lie in either half-space
BOP_IT_BSPPoints ptsEnd = pts.end();
for(BOP_IT_BSPPoints itp=pts.begin();itp!=ptsEnd;itp++){
tag = (BOP_TAG) ((int) tag | (int)testPoint(*itp));
}
if (tag == ON) { } // face lies on hyperplane: do nothing
else if ((tag & IN) != 0 && (tag & OUT) == 0) { // face is entirely on inside
if (m_inChild != NULL)
newDeep = m_inChild->addFace(p1, p2, p3, plane) + 1;
newDeep = m_inChild->addFace(pts, plane) + 1;
else {
m_inChild = new BOP_BSPNode(plane);
newDeep = 2;
}
}
if ((tag & OUT_OUT_OUT) != 0){
} else if ((tag & OUT) != 0 && (tag & IN) == 0) { // face is entirely on outside
if (m_outChild != NULL)
newDeep = MT_max(newDeep, m_outChild->addFace(p1, p2, p3, plane) + 1);
newDeep = m_outChild->addFace(pts, plane) + 1;
else {
m_outChild = new BOP_BSPNode(plane);
newDeep = 2;
}
} else { // face lies in both half-spaces: split it
BOP_BSPPoints inside, outside;
MT_Point3 lpoint= pts[pts.size()-1];
BOP_TAG ltag = testPoint(lpoint);
BOP_TAG tstate = ltag;
// classify each line segment, looking for endpoints which lie on different
// sides of the hyperplane.
BOP_IT_BSPPoints ptsEnd = pts.end();
for(BOP_IT_BSPPoints itp=pts.begin();itp!=ptsEnd;itp++){
MT_Point3 npoint= *itp;
BOP_TAG ntag = testPoint(npoint);
if(ltag != ON) { // last point not on hyperplane
if(tstate == IN) {
if (m_inChild != NULL) inside.push_back(lpoint);
} else {
if (m_outChild != NULL) outside.push_back(lpoint);
}
if(ntag != ON && ntag != tstate) { // last, self in different half-spaces
MT_Point3 mpoint = BOP_intersectPlane( m_plane, lpoint, npoint );
if (m_inChild != NULL) inside.push_back(mpoint);
if (m_outChild != NULL) outside.push_back(mpoint);
tstate = ntag;
}
} else { // last point on hyperplane, so we're switching
// half-spaces
// boundary point belong to both faces
if (m_inChild != NULL) inside.push_back(lpoint);
if (m_outChild != NULL) outside.push_back(lpoint);
tstate = ntag; // state changes to new point tag
}
lpoint = npoint; // save point, tag for next iteration
ltag = ntag;
}
if (m_inChild != NULL)
newDeep = m_inChild->addFace(inside, plane) + 1;
else {
m_inChild = new BOP_BSPNode(plane);
newDeep = 2;
}
if (m_outChild != NULL)
newDeep = MT_max(newDeep, m_outChild->addFace(outside, plane) + 1);
else {
m_outChild = new BOP_BSPNode(plane);
newDeep = MT_max(newDeep,(unsigned int)2);
@ -653,19 +705,13 @@ int BOP_BSPNode::splitTriangle(MT_Point3* res,
*/
void BOP_BSPNode::print(unsigned int deep)
{
for (unsigned int i = 0; i < deep; ++i)
cout << " ";
cout << m_plane.x() << ", ";
cout << m_plane.y() << ", ";
cout << m_plane.z() << ", ";
cout << m_plane.w() << endl;
if (m_inChild != NULL) {
cout << "IN:";
cout << "(" << deep << "," << m_plane << ")," << endl;
if (m_inChild != NULL)
m_inChild->print(deep + 1);
}
if (m_outChild != NULL) {
cout << "OUT:";
else
cout << "(" << deep+1 << ",None)," << endl;
if (m_outChild != NULL)
m_outChild->print(deep + 1);
}
else
cout << "(" << deep+1 << ",None)," << endl;
}

View File

@ -35,6 +35,9 @@
#include "BOP_Tag.h"
#include "BOP_Face.h"
typedef vector<MT_Point3> BOP_BSPPoints;
typedef vector<MT_Point3>::iterator BOP_IT_BSPPoints;
class BOP_BSPNode
{
protected:
@ -47,9 +50,7 @@ public:
// Construction methods
BOP_BSPNode(const MT_Plane3& plane);
~BOP_BSPNode();
unsigned int addFace(const MT_Point3& p1,
const MT_Point3& p2,
const MT_Point3& p3,
unsigned int addFace(BOP_BSPPoints pts,
const MT_Plane3& plane);
BOP_TAG classifyFace(const MT_Point3& p1,
const MT_Point3& p2,

View File

@ -69,6 +69,7 @@ void BOP_BSPTree::addMesh(BOP_Mesh* mesh, BOP_Faces& facesList)
* @param mesh Input data for BSP tree.
* @param face index to mesh face.
*/
void BOP_BSPTree::addFace(BOP_Mesh* mesh, BOP_Face* face)
{
addFace(mesh->getVertex(face->getVertex(0))->getPoint(),
@ -91,8 +92,15 @@ void BOP_BSPTree::addFace(const MT_Point3& p1,
{
if (m_root == NULL)
m_root = new BOP_BSPNode(plane);
else
m_root->addFace(p1,p2,p3,plane);
else {
BOP_BSPPoints pts;
pts.push_back(p1);
pts.push_back(p2);
pts.push_back(p3);
m_root->addFace(pts,plane);
}
// update bounding box
m_bbox.add(p1);
@ -170,37 +178,6 @@ unsigned int BOP_BSPTree::getDeep() const
return 0;
}
/**
* Computes the bounding BSP data.
*/
void BOP_BSPTree::computeBox()
{
if ( m_root != NULL ) {
MT_Point3 p1(m_bbox.m_minX,m_bbox.m_minY,m_bbox.m_minZ);
MT_Point3 p2(m_bbox.m_maxX,m_bbox.m_minY,m_bbox.m_minZ);
MT_Point3 p3(m_bbox.m_maxX,m_bbox.m_maxY,m_bbox.m_minZ);
MT_Point3 p4(m_bbox.m_minX,m_bbox.m_maxY,m_bbox.m_minZ);
MT_Point3 p5(m_bbox.m_minX,m_bbox.m_minY,m_bbox.m_maxZ);
MT_Point3 p6(m_bbox.m_maxX,m_bbox.m_minY,m_bbox.m_maxZ);
MT_Point3 p7(m_bbox.m_maxX,m_bbox.m_maxY,m_bbox.m_maxZ);
MT_Point3 p8(m_bbox.m_minX,m_bbox.m_maxY,m_bbox.m_maxZ);
MT_Plane3 plane1(p3,p2,p1);
MT_Plane3 plane2(p5,p6,p7);
MT_Plane3 plane3(p1,p2,p6);
MT_Plane3 plane4(p8,p7,p3);
MT_Plane3 plane5(p2,p3,p7);
MT_Plane3 plane6(p1,p5,p8);
BOP_BSPNode bsp(plane1);
bsp.addFace(p5,p6,p7,plane2);
bsp.addFace(p1,p2,p6,plane3);
bsp.addFace(p8,p7,p3,plane4);
bsp.addFace(p2,p3,p7,plane5);
bsp.addFace(p1,p5,p8,plane6);
}
}
/**
* Prints debug information.
*/

View File

@ -65,7 +65,6 @@ public:
const MT_Point3& p3,
const MT_Plane3& plane) const;
unsigned int getDeep() const;
void computeBox();
void print();
inline void setRoot(BOP_BSPNode* root) {m_root=root;};
inline BOP_BSPNode* getRoot() const {return m_root;};

View File

@ -152,12 +152,10 @@ BoolOpState BOP_intersectionBoolOp(BOP_Mesh* meshC,
// Create BSPs trees for mesh A & B
BOP_BSPTree bspA;
bspA.addMesh(meshC, *facesA);
bspA.computeBox();
BOP_BSPTree bspB;
bspB.addMesh(meshC, *facesB);
bspB.computeBox();
#ifdef DEBUG
c = chrono.stamp(); t += c;
cout << "Create BSP " << c << endl;

View File

@ -100,7 +100,18 @@ int setup_armature_weakrefs()
main_module = PyImport_AddModule( "__main__");
if(main_module){
PyObject *weakreflink;
maindict= PyModule_GetDict(main_module);
/* check if there is already a dict entry for the armature weakrefs,
* and delete if so before making another one */
weakreflink= PyDict_GetItemString(maindict,list_name);
if( weakreflink != NULL ) {
PyDict_DelItemString(maindict,list_name);
Py_XDECREF( weakreflink );
}
if (PyDict_SetItemString(maindict,
list_name,
PyList_New(0)) == -1){

View File

@ -2467,7 +2467,7 @@ static void lamp_panel_spot(Object *ob, Lamp *la)
}
uiBlockEndAlign(block);
uiDefButBitS(block, TOG, LA_ONLYSHADOW, B_NOP,"OnlyShadow", 10,110,80,19,&la->mode, 0, 0, 0, 0, "Causes light to cast shadows only without illuminating objects");
uiDefButBitS(block, TOG, LA_ONLYSHADOW, B_LAMPPRV,"OnlyShadow", 10,110,80,19,&la->mode, 0, 0, 0, 0, "Causes light to cast shadows only without illuminating objects");
if(la->type==LA_SPOT) {
uiBlockBeginAlign(block);

View File

@ -1991,14 +1991,14 @@ static void draw_mesh_fancy(Base *base, int dt, int flag)
else totface = 0;
}
else {
totvert = me->totvert;
totedge = me->totedge;
totface = me->totface;
totvert = dm->getNumVerts(dm);
totedge = dm->getNumEdges(dm);
totface = dm->getNumFaces(dm);
}
#else
totvert = me->totvert;
totedge = me->totedge;
totface = me->totface;
totvert = dm->getNumVerts(dm);
totedge = dm->getNumEdges(dm);
totface = dm->getNumFaces(dm);
#endif
/* vertexpaint, faceselect wants this, but it doesnt work for shaded? */

View File

@ -343,15 +343,15 @@ void draw_oops(Oops *oops)
if(oops->id== (ID *)((G.scene->basact) ? (G.scene->basact->object) : 0)) line= 1;
else if(oops->id== (ID *)G.scene) line= 1;
if (!oops->id) return;
if(oops->id->us) {
cpack(body);
glRectf(x1, y1, x2, y2);
}
/* it has never happened that an oops was missing an ID at
this point but has occured elseware so lets be safe */
if(oops->id && oops->id->lib) {
if(oops->id->lib) {
if(oops->id->flag & LIB_INDIRECT) cpack(0x1144FF);
else cpack(0x11AAFF);
@ -360,6 +360,7 @@ void draw_oops(Oops *oops)
v1[0]= x1;
v1[1]= (y1+y2)/2 -0.3;
if(oops->type==ID_LI) {
sprintf(str, " %s", ((Library *)oops->id)->name);
}
@ -428,6 +429,8 @@ void drawoopsspace(ScrArea *sa, void *spacedata)
float col[3];
BIF_GetThemeColor3fv(TH_BACK, col);
if(soops==0) return;
/* darker background for oops */
if(soops->type!=SO_OUTLINER) {
@ -436,7 +439,6 @@ void drawoopsspace(ScrArea *sa, void *spacedata)
glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);
if(soops==0) return;
if(soops->type==SO_OUTLINER) draw_outliner(sa, soops);
else {