Pyrogenesis trunk
Classes | Macros | Functions | Variables
mikktspace.cpp File Reference
#include "precompiled.h"
#include <assert.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <stdlib.h>
#include "mikktspace.h"
Include dependency graph for mikktspace.cpp:

Classes

struct  SVec3
 
struct  SSubGroup
 
struct  SGroup
 
struct  STriInfo
 
struct  STSpace
 
struct  STmpVert
 
union  SEdge
 

Macros

#define TFALSE   0
 Copyright (C) 2011 by Morten S. More...
 
#define TTRUE   1
 
#define M_PI   3.1415926535897932384626433832795
 
#define INTERNAL_RND_SORT_SEED   39871946
 
#define MARK_DEGENERATE   1
 
#define QUAD_ONE_DEGEN_TRI   2
 
#define GROUP_WITH_ANY   4
 
#define ORIENT_PRESERVING   8
 
#define NOINLINE   __attribute__ ((noinline))
 

Functions

static tbool veq (const SVec3 v1, const SVec3 v2)
 
static SVec3 vadd (const SVec3 v1, const SVec3 v2)
 
static SVec3 vsub (const SVec3 v1, const SVec3 v2)
 
static SVec3 vscale (const float fS, const SVec3 v)
 
static float LengthSquared (const SVec3 v)
 
static float Length (const SVec3 v)
 
static SVec3 Normalize (const SVec3 v)
 
static float vdot (const SVec3 v1, const SVec3 v2)
 
static tbool NotZero (const float fX)
 
static tbool VNotZero (const SVec3 v)
 
static int GenerateInitialVerticesIndexList (STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn)
 
static void GenerateSharedVerticesIndexList (int piTriList_in_and_out[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn)
 
static void InitTriInfo (STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn)
 
static int Build4RuleGroups (STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn)
 
static tbool GenerateTSpaces (STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, const SMikkTSpaceContext *pContext)
 
static int MakeIndex (const int iFace, const int iVert)
 
static void IndexToData (int *piFace, int *piVert, const int iIndexIn)
 
static STSpace AvgTSpace (const STSpace *pTS0, const STSpace *pTS1)
 
static SVec3 GetPosition (const SMikkTSpaceContext *pContext, const int index)
 
static SVec3 GetNormal (const SMikkTSpaceContext *pContext, const int index)
 
static SVec3 GetTexCoord (const SMikkTSpaceContext *pContext, const int index)
 
static void DegenPrologue (STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris)
 
static void DegenEpilogue (STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn, const int iTotTris)
 
tbool genTangSpaceDefault (const SMikkTSpaceContext *pContext)
 
tbool genTangSpace (const SMikkTSpaceContext *pContext, const float fAngularThreshold)
 
NOINLINE int FindGridCell (const float fMin, const float fMax, const float fVal)
 
static void MergeVertsFast (int piTriList_in_and_out[], STmpVert pTmpVert[], const SMikkTSpaceContext *pContext, const int iL_in, const int iR_in)
 
static void MergeVertsSlow (int piTriList_in_and_out[], const SMikkTSpaceContext *pContext, const int pTable[], const int iEntries)
 
static void GenerateSharedVerticesIndexListSlow (int piTriList_in_and_out[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn)
 
static void BuildNeighborsFast (STriInfo pTriInfos[], SEdge *pEdges, const int piTriListIn[], const int iNrTrianglesIn)
 
static void BuildNeighborsSlow (STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn)
 
static float CalcTexArea (const SMikkTSpaceContext *pContext, const int indices[])
 
static tbool AssignRecur (const int piTriListIn[], STriInfo psTriInfos[], const int iMyTriIndex, SGroup *pGroup)
 
static void AddTriToGroup (SGroup *pGroup, const int iTriIndex)
 
static tbool CompareSubGroups (const SSubGroup *pg1, const SSubGroup *pg2)
 
static void QuickSort (int *pSortBuffer, int iLeft, int iRight, unsigned int uSeed)
 
static STSpace EvalTspace (int face_indices[], const int iFaces, const int piTriListIn[], const STriInfo pTriInfos[], const SMikkTSpaceContext *pContext, const int iVertexRepresentitive)
 
static void QuickSortEdges (SEdge *pSortBuffer, int iLeft, int iRight, const int channel, unsigned int uSeed)
 
static void GetEdge (int *i0_out, int *i1_out, int *edgenum_out, const int indices[], const int i0_in, const int i1_in)
 

Variables

const int g_iCells = 2048
 

Macro Definition Documentation

◆ GROUP_WITH_ANY

#define GROUP_WITH_ANY   4

◆ INTERNAL_RND_SORT_SEED

#define INTERNAL_RND_SORT_SEED   39871946

◆ M_PI

#define M_PI   3.1415926535897932384626433832795

◆ MARK_DEGENERATE

#define MARK_DEGENERATE   1

◆ NOINLINE

#define NOINLINE   __attribute__ ((noinline))

◆ ORIENT_PRESERVING

#define ORIENT_PRESERVING   8

◆ QUAD_ONE_DEGEN_TRI

#define QUAD_ONE_DEGEN_TRI   2

◆ TFALSE

#define TFALSE   0

Copyright (C) 2011 by Morten S.

Mikkelsen

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

◆ TTRUE

#define TTRUE   1

Function Documentation

◆ AddTriToGroup()

static void AddTriToGroup ( SGroup pGroup,
const int  iTriIndex 
)
static

◆ AssignRecur()

static tbool AssignRecur ( const int  piTriListIn[],
STriInfo  psTriInfos[],
const int  iMyTriIndex,
SGroup pGroup 
)
static

◆ AvgTSpace()

static STSpace AvgTSpace ( const STSpace pTS0,
const STSpace pTS1 
)
static

◆ Build4RuleGroups()

static int Build4RuleGroups ( STriInfo  pTriInfos[],
SGroup  pGroups[],
int  piGroupTrianglesBuffer[],
const int  piTriListIn[],
const int  iNrTrianglesIn 
)
static

◆ BuildNeighborsFast()

static void BuildNeighborsFast ( STriInfo  pTriInfos[],
SEdge pEdges,
const int  piTriListIn[],
const int  iNrTrianglesIn 
)
static

◆ BuildNeighborsSlow()

static void BuildNeighborsSlow ( STriInfo  pTriInfos[],
const int  piTriListIn[],
const int  iNrTrianglesIn 
)
static

◆ CalcTexArea()

static float CalcTexArea ( const SMikkTSpaceContext pContext,
const int  indices[] 
)
static

◆ CompareSubGroups()

static tbool CompareSubGroups ( const SSubGroup pg1,
const SSubGroup pg2 
)
static

◆ DegenEpilogue()

static void DegenEpilogue ( STSpace  psTspace[],
STriInfo  pTriInfos[],
int  piTriListIn[],
const SMikkTSpaceContext pContext,
const int  iNrTrianglesIn,
const int  iTotTris 
)
static

◆ DegenPrologue()

static void DegenPrologue ( STriInfo  pTriInfos[],
int  piTriList_out[],
const int  iNrTrianglesIn,
const int  iTotTris 
)
static

◆ EvalTspace()

static STSpace EvalTspace ( int  face_indices[],
const int  iFaces,
const int  piTriListIn[],
const STriInfo  pTriInfos[],
const SMikkTSpaceContext pContext,
const int  iVertexRepresentitive 
)
static

◆ FindGridCell()

NOINLINE int FindGridCell ( const float  fMin,
const float  fMax,
const float  fVal 
)

◆ GenerateInitialVerticesIndexList()

static int GenerateInitialVerticesIndexList ( STriInfo  pTriInfos[],
int  piTriList_out[],
const SMikkTSpaceContext pContext,
const int  iNrTrianglesIn 
)
static

◆ GenerateSharedVerticesIndexList()

static void GenerateSharedVerticesIndexList ( int  piTriList_in_and_out[],
const SMikkTSpaceContext pContext,
const int  iNrTrianglesIn 
)
static

◆ GenerateSharedVerticesIndexListSlow()

static void GenerateSharedVerticesIndexListSlow ( int  piTriList_in_and_out[],
const SMikkTSpaceContext pContext,
const int  iNrTrianglesIn 
)
static

◆ GenerateTSpaces()

static tbool GenerateTSpaces ( STSpace  psTspace[],
const STriInfo  pTriInfos[],
const SGroup  pGroups[],
const int  iNrActiveGroups,
const int  piTriListIn[],
const float  fThresCos,
const SMikkTSpaceContext pContext 
)
static

◆ genTangSpace()

tbool genTangSpace ( const SMikkTSpaceContext pContext,
const float  fAngularThreshold 
)

◆ genTangSpaceDefault()

tbool genTangSpaceDefault ( const SMikkTSpaceContext pContext)

◆ GetEdge()

static void GetEdge ( int *  i0_out,
int *  i1_out,
int *  edgenum_out,
const int  indices[],
const int  i0_in,
const int  i1_in 
)
static

◆ GetNormal()

static SVec3 GetNormal ( const SMikkTSpaceContext pContext,
const int  index 
)
static

◆ GetPosition()

static SVec3 GetPosition ( const SMikkTSpaceContext pContext,
const int  index 
)
static

◆ GetTexCoord()

static SVec3 GetTexCoord ( const SMikkTSpaceContext pContext,
const int  index 
)
static

◆ IndexToData()

static void IndexToData ( int *  piFace,
int *  piVert,
const int  iIndexIn 
)
static

◆ InitTriInfo()

static void InitTriInfo ( STriInfo  pTriInfos[],
const int  piTriListIn[],
const SMikkTSpaceContext pContext,
const int  iNrTrianglesIn 
)
static

◆ Length()

static float Length ( const SVec3  v)
static

◆ LengthSquared()

static float LengthSquared ( const SVec3  v)
static

◆ MakeIndex()

static int MakeIndex ( const int  iFace,
const int  iVert 
)
static

◆ MergeVertsFast()

static void MergeVertsFast ( int  piTriList_in_and_out[],
STmpVert  pTmpVert[],
const SMikkTSpaceContext pContext,
const int  iL_in,
const int  iR_in 
)
static

◆ MergeVertsSlow()

static void MergeVertsSlow ( int  piTriList_in_and_out[],
const SMikkTSpaceContext pContext,
const int  pTable[],
const int  iEntries 
)
static

◆ Normalize()

static SVec3 Normalize ( const SVec3  v)
static

◆ NotZero()

static tbool NotZero ( const float  fX)
static

◆ QuickSort()

static void QuickSort ( int *  pSortBuffer,
int  iLeft,
int  iRight,
unsigned int  uSeed 
)
static

◆ QuickSortEdges()

static void QuickSortEdges ( SEdge pSortBuffer,
int  iLeft,
int  iRight,
const int  channel,
unsigned int  uSeed 
)
static

◆ vadd()

static SVec3 vadd ( const SVec3  v1,
const SVec3  v2 
)
static

◆ vdot()

static float vdot ( const SVec3  v1,
const SVec3  v2 
)
static

◆ veq()

static tbool veq ( const SVec3  v1,
const SVec3  v2 
)
static

◆ VNotZero()

static tbool VNotZero ( const SVec3  v)
static

◆ vscale()

static SVec3 vscale ( const float  fS,
const SVec3  v 
)
static

◆ vsub()

static SVec3 vsub ( const SVec3  v1,
const SVec3  v2 
)
static

Variable Documentation

◆ g_iCells

const int g_iCells = 2048