forked from bartvdbraak/blender
3bea663ffa
#4742 exported normals are now correct #4821 & 4956 for complex movements in/outflows can now also use the animated mesh option - new features * isosurface subdivision: directly creates a finer surface mesh from the simulation data. this increases simulation time and harddisk usage, though, so be careful - usually values of 2-4 should be enough. * fluidsim particles: extended model for particle simulation and generation. When isosurface subdivision is enabled, the particles are now included in the surface generation, giving a better impression of a single connected surface. Note - the particles are only included in the final surface mesh, so the preview surface shows none of the particle effects. * particle loading: different types of particles can now be selected for display: drops, floats and tracers. This is a bit obsolete due to the extensions mentioned above, but might still be useful. Floats are just particles floating on the fluid surface, could be used for e.g. foam. * moving objects impact factor: this is another tweaking option, as the handling of moving objects is still not conserving mass. setting this to zero simply deletes the fluid, 1 is the default, while larger values cause a stronger impact. For tweaking the simulation: if fluid disappears, try increasing this value, and if too much is appearing reduce it. You can even use negative values for some strange results :) - more code cleanup, e.g. removed config file writing in fluidsim.c, added additional safety checks for particles & fluidsim domains (these currently dont work together). I also removed the "build particles" debug message in effects.c (seemed to be unnecessary?). Some more info on the new features: Here are two test animations showing the difference between using the particle generation with isosurface subdivision. This is how it would look with the old solver version: http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_fl6manc4_1noparts.mpg and this with the new one: http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_fl6manc4_2wparts.mpg Both simulations use a resolution of 64, however, the version with particles takes significantly longer (almost twice as long). The .blend file for a similar setup can be found here: http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_testmanc4.blend (Minor Tips for this file: dont enable subdivions of characters until rendering, thus leave off for simulation, as it uses the rendering settings! For making nice pictures switch on subdivion, and OSA.) And here's a picture of old vs. new (for webpage or so): http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_manc4compare.png
126 lines
3.0 KiB
C++
126 lines
3.0 KiB
C++
/******************************************************************************
|
|
*
|
|
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
|
|
* Copyright 2003-2006 Nils Thuerey
|
|
*
|
|
* Tree container for fast triangle intersects
|
|
*
|
|
*****************************************************************************/
|
|
#ifndef NTL_TREE_H
|
|
#define NTL_TREE_H
|
|
|
|
#include "ntl_vector3dim.h"
|
|
#include "ntl_ray.h"
|
|
|
|
|
|
#define AXIS_X 0
|
|
#define AXIS_Y 1
|
|
#define AXIS_Z 2
|
|
|
|
#define BSP_STACK_SIZE 50
|
|
|
|
|
|
//! bsp tree stack classes, defined in ntl_bsptree.cpp,
|
|
// detailed definition unnecesseary here
|
|
class BSPNode;
|
|
class BSPStackElement;
|
|
class BSPStack;
|
|
class TriangleBBox;
|
|
class ntlScene;
|
|
class ntlTriangle;
|
|
|
|
|
|
//! Class for a bsp tree for triangles
|
|
class ntlTree
|
|
{
|
|
public:
|
|
|
|
//! Default constructor
|
|
ntlTree();
|
|
//! Constructor with init
|
|
ntlTree(int depth, int objnum, ntlScene *scene, int triFlagMask);
|
|
//! Destructor
|
|
~ntlTree();
|
|
|
|
//! subdivide tree
|
|
void subdivide(BSPNode *node, int depth, int axis);
|
|
|
|
//! intersect ray with BSPtree
|
|
void intersect(const ntlRay &ray, gfxReal &distance, ntlVec3Gfx &normal, ntlTriangle *&tri, int flags, bool forceNonsmooth) const;
|
|
//! intersect along +X ray
|
|
void intersectX(const ntlRay &ray, gfxReal &distance, ntlVec3Gfx &normal, ntlTriangle *&tri, int flags, bool forceNonsmooth) const;
|
|
|
|
//! Returns number of nodes
|
|
int getCurrentNodes( void ) { return mCurrentNodes; }
|
|
|
|
protected:
|
|
|
|
// check if a triangle is in a node
|
|
bool checkAABBTriangle(ntlVec3Gfx &min, ntlVec3Gfx &max, ntlTriangle *tri);
|
|
|
|
|
|
// VARs
|
|
|
|
//! distance to plane function for nodes
|
|
gfxReal distanceToPlane(BSPNode *curr, ntlVec3Gfx plane, ntlRay ray) const;
|
|
|
|
//! return ordering of children nodes relatice to origin point
|
|
void getChildren(BSPNode *curr, ntlVec3Gfx origin, BSPNode *&node_near, BSPNode *&node_far) const;
|
|
|
|
//! delete a node of the tree with all sub nodes, dont delete root members
|
|
void deleteNode(BSPNode *curr);
|
|
|
|
//inline bool isLeaf(BSPNode *node) const { return (node->child[0] == NULL); }
|
|
|
|
|
|
//! AABB for tree
|
|
ntlVec3Gfx mStart,mEnd;
|
|
|
|
//! maximum depth of tree
|
|
int mMaxDepth;
|
|
|
|
//! maximum number of objects in one node
|
|
int mMaxListLength;
|
|
|
|
//! root node pointer
|
|
BSPNode *mpRoot;
|
|
//! count no. of node
|
|
int mNumNodes;
|
|
int mAbortSubdiv;
|
|
|
|
//! stack for the node pointers
|
|
BSPStack *mpNodeStack;
|
|
//stack<BSPNode *> nodestack;
|
|
|
|
//! pointer to vertex array
|
|
vector<ntlVec3Gfx> *mpVertices;
|
|
|
|
//! pointer to vertex array
|
|
vector<ntlVec3Gfx> *mpVertNormals;
|
|
|
|
//! vector for all the triangles
|
|
vector<ntlTriangle> *mpTriangles;
|
|
vector<ntlTriangle *> *mppTriangles;
|
|
|
|
//! temporary array for triangle distribution to nodes
|
|
char *mpTriDist;
|
|
|
|
//! temporary array for triangle bounding boxes
|
|
TriangleBBox *mpTBB;
|
|
|
|
//! triangle mask - include only triangles that match mask
|
|
int mTriangleMask;
|
|
|
|
//! Status vars (max depth, # of current nodes)
|
|
int mCurrentDepth, mCurrentNodes;
|
|
|
|
//! duplicated triangles, inited during subdivide
|
|
int mTriDoubles;
|
|
|
|
};
|
|
|
|
|
|
#endif
|
|
|
|
|