EdgeBleeding/EdgeBleeding.h Source File

EdgeBleeding.h
Go to the documentation of this file.
1 #ifndef __EDGEBLEEDING_H
2 #define __EDGEBLEEDING_H
3 
4 #include <math.h>
5 
6 // force inline functions to be inline to achieve max speed
7 #ifndef _DEBUG
8  #ifdef _MSC_VER
9  #ifndef _XKEYCHECK_H
10  #define _XKEYCHECK_H
11  #endif
12  #define inline __forceinline
13  #endif
14 #endif
15 
16 #if defined(JAMBUILD) || defined(__APPLE__)
17  #include <Mudbox/mudbox.h>
18  #include <Mudbox/SSE.h>
19 #else
20  #include "../../include/Mudbox/mudbox.h"
21  #include "../../include/Mudbox/SSE.h"
22 #endif
23 
24 #include <QtCore/QCoreApplication>
25 
26 #ifndef COMPILING_EDGEBLEEDING_DLL
27 #define EBDLL MUDBOX_DLLIMPORT
28 #else
29 #define EBDLL MUDBOX_DLLEXPORT
30 #endif
31 
32 #define MAX_TEXTURE_COUNT 4
34 {
35 public:
36  void Request( mudbox::Texture *pTexture )
37  {
38  for( int i=0; i<cache.size(); i++ )
39  if( cache.at(i) == pTexture )
40  {
41  lastHit = i;
42  return;
43  }
44 
45  if( cache.size() >= MAX_TEXTURE_COUNT )
46  {
47  mudbox::Texture *pT = NULL;
48  if( lastHit != 0 )
49  pT = cache.takeFirst();
50  else
51  pT = cache.takeAt(1);
52  pT->AddDirtyTile( mudbox::ImgTile (0, 0, pT->Width(), pT->Height()) );
54  };
55 
56  cache.append( pTexture );
57  lastHit = cache.size() - 1;
58  if( pTexture->Location() != mudbox::TexturePool::locationGPU )
60  };
61 
62  void Clear()
63  {
64 // for( int i=0; i<cache.size(); i++ )
65 // cache.at(i)->SetLocation( mudbox::TexturePool::locationCPU );
66 
67  cache.clear();
68  };
69 
70 private:
72  int lastHit;
73 };
74 
76 {
77 public:
78 
81 
82  EdgeBleeding( void );
83  static void Initializer();
84 
85  static void FillBleedingAreas( void ) { FillBleedingAreas( false ); }
86  // the bBlend parameter when set to true will ensure that these functions do not
87  // write transparent pixels -- this fixes a problem with seams opening
88  // up on certain triangle edges.
89  static void FillBleedingAreas( bool bBlend );
90  static void FillBleedingAreas( mudbox::Mesh *pMesh, mudbox::TexturePool *pTexture, bool bBlend = false );
91  static void FillBleedingAreasForTriangle(mudbox::Mesh *pMesh, mudbox::TexturePool *pTP, bool bBlend = false);
92 
93 private:
94  inline static float AdjustUV( float value )
95  {
96  float d = 0.0f;
97  return modff(value, &d);
98  //while ( value > 1.0f )
99  // value -= 1.0f;
100  //while ( value < 0.0f )
101  // value += 1.0f;
102  //return value;
103  };
104 
105  static TextureCache s_cTextureCache;
106 };
107 
108 #endif
virtual void SetLocation(unsigned int iLocation)
Sets the location for the texture pool.
void clear()
Definition: qlist.h:764
A Mesh is a collection of vertices organized into faces, and optional Texture Coordinate information...
Definition: mesh.h:452
This is a container class for simple textures.
Definition: material.h:467
T takeAt(int i)
Definition: qlist.h:484
#define EBDLL
Definition: EdgeBleeding.h:27
This is the base class for most classes in the Mudbox SDK.
Definition: node.h:740
virtual void AddDirtyTile(const ImgTile &t)
Notifies the texture that part of it has changed.
Definition: material.h:1023
int size() const
Definition: qlist.h:137
virtual unsigned int Width(void) const
Returns the width of the texture in pixels.
T takeFirst()
Definition: qlist.h:489
void Clear()
Definition: EdgeBleeding.h:62
const T & at(int i) const
Definition: qlist.h:468
virtual unsigned int Height(void) const
Returns the height of the texture in pixels.
GLsizei const GLfloat * value
Definition: GLee.h:1742
Represents a texture tile inside a texture pool.
Definition: material.h:716
static void FillBleedingAreas(void)
Definition: EdgeBleeding.h:85
void Request(mudbox::Texture *pTexture)
Definition: EdgeBleeding.h:36
Represents a rectangle. Used to specify rectangular regions of an image.
Definition: image.h:960
void append(const T &t)
Definition: qlist.h:507
#define MAX_TEXTURE_COUNT
Definition: EdgeBleeding.h:32
#define Q_DECLARE_TR_FUNCTIONS(context)
virtual unsigned int Location(void) const
Gets the location for the texture pool.