Blender V2.61 - r43446

subd_split.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2011, Blender Foundation.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #ifndef __SUBD_SPLIT_H__
00020 #define __SUBD_SPLIT_H__
00021 
00022 /* DiagSplit: Parallel, Crack-free, Adaptive Tessellation for Micropolygon Rendering
00023  * Splits up patches and determines edge tesselation factors for dicing. Patch
00024  * evaluation at arbitrary points is required for this to work. See the paper
00025  * for more details. */
00026 
00027 #include "subd_dice.h"
00028 
00029 #include "util_types.h"
00030 #include "util_vector.h"
00031 
00032 CCL_NAMESPACE_BEGIN
00033 
00034 class Mesh;
00035 class Patch;
00036 
00037 #define DSPLIT_NON_UNIFORM -1
00038 
00039 class DiagSplit {
00040 public:
00041     vector<QuadDice::SubPatch> subpatches_quad;
00042     vector<QuadDice::EdgeFactors> edgefactors_quad;
00043     vector<TriangleDice::SubPatch> subpatches_triangle;
00044     vector<TriangleDice::EdgeFactors> edgefactors_triangle;
00045 
00046     int test_steps;
00047     int split_threshold;
00048     float dicing_rate;
00049     Camera *camera;
00050 
00051     DiagSplit();
00052 
00053     float3 project(Patch *patch, float2 uv);
00054     int T(Patch *patch, float2 Pstart, float2 Pend);
00055     void partition_edge(Patch *patch, float2 *P, int *t0, int *t1,
00056         float2 Pstart, float2 Pend, int t);
00057 
00058     void dispatch(QuadDice::SubPatch& sub, QuadDice::EdgeFactors& ef);
00059     void split(QuadDice::SubPatch& sub, QuadDice::EdgeFactors& ef, int depth=0);
00060 
00061     void dispatch(TriangleDice::SubPatch& sub, TriangleDice::EdgeFactors& ef);
00062     void split(TriangleDice::SubPatch& sub, TriangleDice::EdgeFactors& ef, int depth=0);
00063 
00064     void split_triangle(Mesh *mesh, Patch *patch, int shader, bool smooth);
00065     void split_quad(Mesh *mesh, Patch *patch, int shader, bool smooth);
00066 };
00067 
00068 CCL_NAMESPACE_END
00069 
00070 #endif /* __SUBD_SPLIT_H__ */
00071