|
Blender
V2.93
|
#include <assert.h>#include <float.h>#include <limits.h>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "mikktspace.h"Go to the source code of this file.
Classes | |
| struct | SVec3 |
| struct | SSubGroup |
| struct | SGroup |
| struct | STriInfo |
| struct | STSpace |
| union | SEdge |
| struct | VertReverseLookupContext |
Macros | |
| #define | TFALSE 0 |
| #define | TTRUE 1 |
| #define | M_PI 3.1415926535897932384626433832795 |
| #define | INTERNAL_RND_SORT_SEED 39871946 |
| #define | MIKK_INLINE static inline __attribute__((always_inline)) __attribute__((unused)) |
| #define | MARK_DEGENERATE 1 |
| #define | QUAD_ONE_DEGEN_TRI 2 |
| #define | GROUP_WITH_ANY 4 |
| #define | ORIENT_PRESERVING 8 |
| #define | HASH(x, y, z) (((x)*73856093) ^ ((y)*19349663) ^ ((z)*83492791)) |
| #define | HASH_F(x, y, z) HASH(float_as_uint(x), float_as_uint(y), float_as_uint(z)) |
Typedefs | |
| typedef unsigned int | uint |
| typedef struct VertReverseLookupContext | VertReverseLookupContext |
Functions | |
| MIKK_INLINE tbool | veq (const SVec3 v1, const SVec3 v2) |
| MIKK_INLINE SVec3 | vadd (const SVec3 v1, const SVec3 v2) |
| MIKK_INLINE SVec3 | vsub (const SVec3 v1, const SVec3 v2) |
| MIKK_INLINE SVec3 | vscale (const float fS, const SVec3 v) |
| MIKK_INLINE float | LengthSquared (const SVec3 v) |
| MIKK_INLINE float | Length (const SVec3 v) |
| MIKK_INLINE SVec3 | NormalizeSafe (const SVec3 v) |
| MIKK_INLINE float | vdot (const SVec3 v1, const SVec3 v2) |
| MIKK_INLINE tbool | NotZero (const float fX) |
| MIKK_INLINE unsigned int | rotl (unsigned int value, unsigned int count) |
| 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) |
| MIKK_INLINE int | MakeIndex (const int iFace, const int iVert) |
| MIKK_INLINE void | IndexToData (int *piFace, int *piVert, const int iIndexIn) |
| static STSpace | AvgTSpace (const STSpace *pTS0, const STSpace *pTS1) |
| MIKK_INLINE SVec3 | GetPosition (const SMikkTSpaceContext *pContext, const int index) |
| MIKK_INLINE SVec3 | GetNormal (const SMikkTSpaceContext *pContext, const int index) |
| MIKK_INLINE 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) |
| static void | GenerateSharedVerticesIndexListSlow (int piTriList_in_and_out[], const SMikkTSpaceContext *pContext, const int iNrTrianglesIn) |
| static uint | float_as_uint (const float v) |
| static void | radixsort_pair (uint *comp, int *data, uint *comp2, int *data2, int n) |
| 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) |
| MIKK_INLINE 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) |
| static void | GenerateReverseLookup (const int piTriListIn[], const int iNrTrianglesIn, VertReverseLookupContext *pLookupCtx) |
| static int | LookupVertexIndexFromGoodTriangle (VertReverseLookupContext *pLookupCtx, int piTriListIn[], const int iNrTrianglesIn, const int iVertexIndex) |
| static void | FreeReverseLookup (VertReverseLookupContext *pLookupCtx) |
| #define GROUP_WITH_ANY 4 |
Definition at line 165 of file mikktspace.c.
Definition at line 486 of file mikktspace.c.
| #define HASH_F | ( | x, | |
| y, | |||
| z | |||
| ) | HASH(float_as_uint(x), float_as_uint(y), float_as_uint(z)) |
Definition at line 487 of file mikktspace.c.
| #define INTERNAL_RND_SORT_SEED 39871946 |
Definition at line 41 of file mikktspace.c.
| #define M_PI 3.1415926535897932384626433832795 |
Definition at line 38 of file mikktspace.c.
| #define MARK_DEGENERATE 1 |
Definition at line 163 of file mikktspace.c.
| #define MIKK_INLINE static inline __attribute__((always_inline)) __attribute__((unused)) |
Definition at line 46 of file mikktspace.c.
| #define ORIENT_PRESERVING 8 |
Definition at line 166 of file mikktspace.c.
| #define QUAD_ONE_DEGEN_TRI 2 |
Definition at line 164 of file mikktspace.c.
| #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:
Definition at line 34 of file mikktspace.c.
| #define TTRUE 1 |
Definition at line 35 of file mikktspace.c.
| typedef unsigned int uint |
Definition at line 479 of file mikktspace.c.
| typedef struct VertReverseLookupContext VertReverseLookupContext |
| MIKK_INLINE void AddTriToGroup | ( | SGroup * | pGroup, |
| const int | iTriIndex | ||
| ) |
Definition at line 1047 of file mikktspace.c.
References SGroup::iNrFaces, and SGroup::pFaceIndices.
Referenced by AssignRecur(), and Build4RuleGroups().
|
static |
Definition at line 1053 of file mikktspace.c.
References AddTriToGroup(), STriInfo::AssignedGroup, SGroup::bOrientPreservering, STriInfo::FaceNeighbors, GROUP_WITH_ANY, STriInfo::iFlag, SGroup::iVertexRepresentitive, NULL, ORIENT_PRESERVING, TFALSE, and TTRUE.
Referenced by Build4RuleGroups().
Definition at line 227 of file mikktspace.c.
References STSpace::fMagS, STSpace::fMagT, NormalizeSafe(), vadd(), veq(), STSpace::vOs, and STSpace::vOt.
Referenced by GenerateTSpaces().
|
static |
Definition at line 981 of file mikktspace.c.
References AddTriToGroup(), STriInfo::AssignedGroup, AssignRecur(), SGroup::bOrientPreservering, STriInfo::FaceNeighbors, GROUP_WITH_ANY, STriInfo::iFlag, SGroup::iNrFaces, SGroup::iVertexRepresentitive, NULL, ORIENT_PRESERVING, SGroup::pFaceIndices, TFALSE, and TTRUE.
Referenced by genTangSpace().
|
static |
Definition at line 1440 of file mikktspace.c.
References SEdge::f, STriInfo::FaceNeighbors, GetEdge(), SEdge::i0, SEdge::i1, i1, INTERNAL_RND_SORT_SEED, QuickSortEdges(), t, TFALSE, and TTRUE.
Referenced by InitTriInfo().
|
static |
Definition at line 1539 of file mikktspace.c.
References STriInfo::FaceNeighbors, t, TFALSE, and TTRUE.
Referenced by InitTriInfo().
|
static |
Definition at line 832 of file mikktspace.c.
References GetTexCoord(), indices, SVec3::x, and SVec3::y.
Referenced by InitTriInfo().
Definition at line 1375 of file mikktspace.c.
References SSubGroup::iNrFaces, SSubGroup::pTriMembers, TFALSE, and TTRUE.
Referenced by GenerateTSpaces().
|
static |
Definition at line 1845 of file mikktspace.c.
References FreeReverseLookup(), GetPosition(), STriInfo::iFlag, STriInfo::iOrgFaceNumber, STriInfo::iTSpacesOffs, LookupVertexIndexFromGoodTriangle(), MakeIndex(), QUAD_ONE_DEGEN_TRI, t, TFALSE, TTRUE, veq(), and STriInfo::vert_num.
Referenced by genTangSpace().
|
static |
Definition at line 1688 of file mikktspace.c.
References STriInfo::iFlag, STriInfo::iOrgFaceNumber, MARK_DEGENERATE, QUAD_ONE_DEGEN_TRI, t, TFALSE, and TTRUE.
Referenced by genTangSpace().
|
static |
Definition at line 1293 of file mikktspace.c.
References KDL::acos(), fAngle, float(), STriInfo::fMagS, STSpace::fMagS, STriInfo::fMagT, STSpace::fMagT, GetNormal(), GetPosition(), GROUP_WITH_ANY, i1, NormalizeSafe(), v1, v2, vadd(), vdot(), STSpace::vOs, STSpace::vOt, vscale(), vsub(), SVec3::x, SVec3::y, and SVec3::z.
Referenced by GenerateTSpaces().
Definition at line 481 of file mikktspace.c.
References v.
|
static |
Definition at line 1835 of file mikktspace.c.
References VertReverseLookupContext::bIsInitialized, free(), NULL, and VertReverseLookupContext::pLookup.
Referenced by DegenEpilogue().
|
static |
Definition at line 655 of file mikktspace.c.
References GetPosition(), GetTexCoord(), i1, STriInfo::iOrgFaceNumber, STriInfo::iTSpacesOffs, LengthSquared(), SMikkTSpaceInterface::m_getNumFaces, SMikkTSpaceInterface::m_getNumVerticesOfFace, SMikkTSpaceContext::m_pInterface, MakeIndex(), t, T1, T2, T3, TFALSE, TTRUE, STriInfo::vert_num, verts, and vsub().
Referenced by genTangSpace().
|
static |
Definition at line 1778 of file mikktspace.c.
References VertReverseLookupContext::iMaxVertIndex, NULL, VertReverseLookupContext::pLookup, and t.
Referenced by LookupVertexIndexFromGoodTriangle().
|
static |
Definition at line 527 of file mikktspace.c.
References free(), GenerateSharedVerticesIndexListSlow(), GetNormal(), GetPosition(), GetTexCoord(), HASH, hash, HASH_F, indices, NULL, numVertices(), radixsort_pair(), veq(), SVec3::x, SVec3::y, and SVec3::z.
Referenced by genTangSpace().
|
static |
Definition at line 611 of file mikktspace.c.
References GetNormal(), GetPosition(), GetTexCoord(), t, TFALSE, TTRUE, and veq().
Referenced by GenerateSharedVerticesIndexList().
|
static |
Definition at line 1120 of file mikktspace.c.
References AvgTSpace(), STSpace::bOrient, SGroup::bOrientPreservering, CompareSubGroups(), EvalTspace(), free(), GetNormal(), GROUP_WITH_ANY, STSpace::iCounter, STriInfo::iFlag, SSubGroup::iNrFaces, SGroup::iNrFaces, INTERNAL_RND_SORT_SEED, STriInfo::iOrgFaceNumber, STriInfo::iTSpacesOffs, SGroup::iVertexRepresentitive, l, NormalizeSafe(), NULL, ORIENT_PRESERVING, SGroup::pFaceIndices, SSubGroup::pTriMembers, QuickSort(), t, TFALSE, TTRUE, vdot(), STriInfo::vert_num, vscale(), and vsub().
Referenced by genTangSpace().
| tbool genTangSpace | ( | const SMikkTSpaceContext * | pContext, |
| const float | fAngularThreshold | ||
| ) |
Definition at line 274 of file mikktspace.c.
References STSpace::bOrient, Build4RuleGroups(), cosf, DegenEpilogue(), DegenPrologue(), STSpace::fMagS, STSpace::fMagT, free(), GenerateInitialVerticesIndexList(), GenerateSharedVerticesIndexList(), GenerateTSpaces(), GetPosition(), i1, STriInfo::iFlag, InitTriInfo(), SMikkTSpaceInterface::m_getNormal, SMikkTSpaceInterface::m_getNumFaces, SMikkTSpaceInterface::m_getNumVerticesOfFace, SMikkTSpaceInterface::m_getPosition, SMikkTSpaceInterface::m_getTexCoord, M_PI, SMikkTSpaceContext::m_pInterface, SMikkTSpaceInterface::m_setTSpace, SMikkTSpaceInterface::m_setTSpaceBasic, MARK_DEGENERATE, NULL, t, TFALSE, TTRUE, veq(), verts, STSpace::vOs, STSpace::vOt, SVec3::x, SVec3::y, and SVec3::z.
Referenced by genTangSpaceDefault().
| tbool genTangSpaceDefault | ( | const SMikkTSpaceContext * | pContext | ) |
Definition at line 269 of file mikktspace.c.
References genTangSpace().
Referenced by BKE_displist_tangent_calc(), BKE_mesh_calc_loop_tangent_single_ex(), DM_calc_loop_tangents_thread(), emDM_calc_loop_tangents_thread(), and mikk_compute_tangents().
|
static |
Definition at line 1654 of file mikktspace.c.
References indices.
Referenced by BuildNeighborsFast().
| MIKK_INLINE SVec3 GetNormal | ( | const SMikkTSpaceContext * | pContext, |
| const int | index | ||
| ) |
Definition at line 787 of file mikktspace.c.
References IndexToData(), SMikkTSpaceInterface::m_getNormal, SMikkTSpaceContext::m_pInterface, norm(), SVec3::x, SVec3::y, and SVec3::z.
Referenced by EvalTspace(), GenerateSharedVerticesIndexList(), GenerateSharedVerticesIndexListSlow(), and GenerateTSpaces().
| MIKK_INLINE SVec3 GetPosition | ( | const SMikkTSpaceContext * | pContext, |
| const int | index | ||
| ) |
Definition at line 774 of file mikktspace.c.
References IndexToData(), SMikkTSpaceInterface::m_getPosition, SMikkTSpaceContext::m_pInterface, pos, SVec3::x, SVec3::y, and SVec3::z.
Referenced by DegenEpilogue(), EvalTspace(), GenerateInitialVerticesIndexList(), GenerateSharedVerticesIndexList(), GenerateSharedVerticesIndexListSlow(), genTangSpace(), and InitTriInfo().
| MIKK_INLINE SVec3 GetTexCoord | ( | const SMikkTSpaceContext * | pContext, |
| const int | index | ||
| ) |
Definition at line 800 of file mikktspace.c.
References IndexToData(), SMikkTSpaceInterface::m_getTexCoord, SMikkTSpaceContext::m_pInterface, SVec3::x, SVec3::y, and SVec3::z.
Referenced by CalcTexArea(), GenerateInitialVerticesIndexList(), GenerateSharedVerticesIndexList(), GenerateSharedVerticesIndexListSlow(), and InitTriInfo().
| MIKK_INLINE void IndexToData | ( | int * | piFace, |
| int * | piVert, | ||
| const int | iIndexIn | ||
| ) |
Definition at line 221 of file mikktspace.c.
Referenced by GetNormal(), GetPosition(), and GetTexCoord().
|
static |
Definition at line 848 of file mikktspace.c.
References STriInfo::AssignedGroup, BuildNeighborsFast(), BuildNeighborsSlow(), CalcTexArea(), fabsf, STriInfo::FaceNeighbors, STriInfo::fMagS, STriInfo::fMagT, free(), GetPosition(), GetTexCoord(), GROUP_WITH_ANY, STriInfo::iFlag, STriInfo::iOrgFaceNumber, Length(), MARK_DEGENERATE, NotZero(), NULL, ORIENT_PRESERVING, t, TFALSE, TTRUE, v1, v2, vadd(), STriInfo::vOs, STriInfo::vOt, vscale(), vsub(), SVec3::x, SVec3::y, and SVec3::z.
Referenced by genTangSpace().
| MIKK_INLINE float Length | ( | const SVec3 | v | ) |
Definition at line 97 of file mikktspace.c.
References LengthSquared(), sqrtf, and v.
Referenced by InitTriInfo(), and NormalizeSafe().
| MIKK_INLINE float LengthSquared | ( | const SVec3 | v | ) |
Definition at line 92 of file mikktspace.c.
References v.
Referenced by GenerateInitialVerticesIndexList(), and Length().
|
static |
Definition at line 1814 of file mikktspace.c.
References VertReverseLookupContext::bIsInitialized, GenerateReverseLookup(), VertReverseLookupContext::iMaxVertIndex, NULL, VertReverseLookupContext::pLookup, and TTRUE.
Referenced by DegenEpilogue().
| MIKK_INLINE int MakeIndex | ( | const int | iFace, |
| const int | iVert | ||
| ) |
Definition at line 215 of file mikktspace.c.
Referenced by DegenEpilogue(), and GenerateInitialVerticesIndexList().
| MIKK_INLINE SVec3 NormalizeSafe | ( | const SVec3 | v | ) |
Definition at line 109 of file mikktspace.c.
References len, Length(), v, and vscale().
Referenced by AvgTSpace(), EvalTspace(), and GenerateTSpaces().
| MIKK_INLINE tbool NotZero | ( | const float | fX | ) |
|
static |
Definition at line 1389 of file mikktspace.c.
Referenced by GenerateTSpaces().
|
static |
Definition at line 1584 of file mikktspace.c.
References SEdge::array, rotl(), and t.
Referenced by BuildNeighborsFast().
Definition at line 491 of file mikktspace.c.
References data, data2, and pos.
Referenced by GenerateSharedVerticesIndexList().
| MIKK_INLINE unsigned int rotl | ( | unsigned int | value, |
| unsigned int | count | ||
| ) |
Definition at line 143 of file mikktspace.c.
Referenced by QuickSort(), and QuickSortEdges().
| MIKK_INLINE SVec3 vadd | ( | const SVec3 | v1, |
| const SVec3 | v2 | ||
| ) |
Definition at line 59 of file mikktspace.c.
References v1, v2, SVec3::x, SVec3::y, and SVec3::z.
Referenced by AvgTSpace(), EvalTspace(), and InitTriInfo().
| MIKK_INLINE float vdot | ( | const SVec3 | v1, |
| const SVec3 | v2 | ||
| ) |
Definition at line 120 of file mikktspace.c.
Referenced by EvalTspace(), and GenerateTSpaces().
| MIKK_INLINE tbool veq | ( | const SVec3 | v1, |
| const SVec3 | v2 | ||
| ) |
Definition at line 54 of file mikktspace.c.
Referenced by AvgTSpace(), DegenEpilogue(), GenerateSharedVerticesIndexList(), GenerateSharedVerticesIndexListSlow(), and genTangSpace().
| MIKK_INLINE SVec3 vscale | ( | const float | fS, |
| const SVec3 | v | ||
| ) |
Definition at line 81 of file mikktspace.c.
References v, SVec3::x, SVec3::y, and SVec3::z.
Referenced by EvalTspace(), GenerateTSpaces(), InitTriInfo(), and NormalizeSafe().
| MIKK_INLINE SVec3 vsub | ( | const SVec3 | v1, |
| const SVec3 | v2 | ||
| ) |
Definition at line 70 of file mikktspace.c.
References v1, v2, SVec3::x, SVec3::y, and SVec3::z.
Referenced by EvalTspace(), GenerateInitialVerticesIndexList(), GenerateTSpaces(), and InitTriInfo().