Ecere Software
/
sdk
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a067b82
)
ecere/gfx/3D: Updates to Direct3D driver to not crash on bump maps / cube maps
author
Jerome St-Louis
<jerome@ecere.com>
Wed, 3 Aug 2016 11:49:22 +0000
(07:49 -0400)
committer
Jerome St-Louis
<jerome@ecere.com>
Wed, 3 Aug 2016 11:49:22 +0000
(07:49 -0400)
ecere/src/gfx/3D/Mesh.ec
patch
|
blob
|
history
ecere/src/gfx/3D/meshes/Sphere.ec
patch
|
blob
|
history
ecere/src/gfx/Bitmap.ec
patch
|
blob
|
history
ecere/src/gfx/drivers/Direct3D8DisplayDriver.ec
patch
|
blob
|
history
ecere/src/gfx/drivers/Direct3D9DisplayDriver.ec
patch
|
blob
|
history
diff --git
a/ecere/src/gfx/3D/Mesh.ec
b/ecere/src/gfx/3D/Mesh.ec
index
e7c304c
..
1019b82
100644
(file)
--- a/
ecere/src/gfx/3D/Mesh.ec
+++ b/
ecere/src/gfx/3D/Mesh.ec
@@
-320,13
+320,14
@@
public:
double * weightSum = new0 double[nVertices];
PrimitiveGroup group;
double * weightSum = new0 double[nVertices];
PrimitiveGroup group;
- if(Allocate({ normals = true, tangents = t
rue
}, nVertices, displaySystem))
+ if(Allocate({ normals = true, tangents = t
exCoords != null
}, nVertices, displaySystem))
{
Vector3Df * normals = this.normals;
Vector3Df * tangents = this.tangents;
Pointf * texCoords = this.texCoords;
FillBytes(normals, 0, nVertices * sizeof(Vector3Df));
{
Vector3Df * normals = this.normals;
Vector3Df * tangents = this.tangents;
Pointf * texCoords = this.texCoords;
FillBytes(normals, 0, nVertices * sizeof(Vector3Df));
- FillBytes(tangents, 0, 2*nVertices * sizeof(Vector3Df));
+ if(tangents)
+ FillBytes(tangents, 0, 2*nVertices * sizeof(Vector3Df));
for(group = groups.first; group; group = group.next)
{
int c;
for(group = groups.first; group; group = group.next)
{
int c;
@@
-432,7
+433,7
@@
public:
weightSum[index] += w;
//numShared[index] ++;
weightSum[index] += w;
//numShared[index] ++;
- if(t
exCoord
s)
+ if(t
angent
s)
{
uint ix0 = index;
uint prev = v ? i - 1 : c + nIndex-1;
{
uint ix0 = index;
uint prev = v ? i - 1 : c + nIndex-1;
@@
-495,10
+496,14
@@
public:
for(c = 0; c<nVertices; c++)
{
float s = (float)(1.0 / weightSum[c]); // numShared[c]
for(c = 0; c<nVertices; c++)
{
float s = (float)(1.0 / weightSum[c]); // numShared[c]
- Vector3Df * n = &normals[c]
, * t1 = &tangents[2*c], * t2 = &tangents[2*c+1]
;
+ Vector3Df * n = &normals[c];
n->Scale(n, s), n->Normalize(n);
n->Scale(n, s), n->Normalize(n);
- t1->Scale(t1, s), t1->Normalize(t1);
- t2->Scale(t2, s), t2->Normalize(t2);
+ if(tangents)
+ {
+ Vector3Df * t1 = &tangents[2*c], * t2 = &tangents[2*c+1];
+ t1->Scale(t1, s), t1->Normalize(t1);
+ t2->Scale(t2, s), t2->Normalize(t2);
+ }
}
delete numShared;
delete weightSum;
}
delete numShared;
delete weightSum;
diff --git
a/ecere/src/gfx/3D/meshes/Sphere.ec
b/ecere/src/gfx/3D/meshes/Sphere.ec
index
7670df2
..
60d5523
100644
(file)
--- a/
ecere/src/gfx/3D/meshes/Sphere.ec
+++ b/
ecere/src/gfx/3D/meshes/Sphere.ec
@@
-51,18
+51,21
@@
public:
pNormals[index] = pVertices[index];
pNormals[index] = pVertices[index];
- pTangents[index*2] =
+ if(pTangents)
{
{
- (float) (sin(theta) * cos(omega - Pi/2));
- (float) sin(omega - Pi/2);
- (float) (cos(theta) * cos(omega - Pi/2));
- };
- pTangents[index*2+1] =
- {
- (float) (sin(theta - Pi/2) * cosOmega);
- (float) sin(omega);
- (float) (cos(theta - Pi/2) * cosOmega);
- };
+ pTangents[index*2] =
+ {
+ (float) (sin(theta) * cos(omega - Pi/2));
+ (float) sin(omega - Pi/2);
+ (float) (cos(theta) * cos(omega - Pi/2));
+ };
+ pTangents[index*2+1] =
+ {
+ (float) (sin(theta - Pi/2) * cosOmega);
+ (float) sin(omega);
+ (float) (cos(theta - Pi/2) * cosOmega);
+ };
+ }
//pTangents[index*2 + 1].CrossProduct(pNormals[index], pTangents[index*2]);
pTexCoords[index] = { (float)l / (w-1), (float)lat / (numLat) };
//pTangents[index*2 + 1].CrossProduct(pNormals[index], pTangents[index*2]);
pTexCoords[index] = { (float)l / (w-1), (float)lat / (numLat) };
diff --git
a/ecere/src/gfx/Bitmap.ec
b/ecere/src/gfx/Bitmap.ec
index
c1d3725
..
4e85b2e
100644
(file)
--- a/
ecere/src/gfx/Bitmap.ec
+++ b/
ecere/src/gfx/Bitmap.ec
@@
-949,10
+949,11
@@
public:
public class CubeMap : Bitmap
{
public:
public class CubeMap : Bitmap
{
public:
-
void
Load(DisplaySystem displaySystem, const String * names, const String extension, bool oldStyle)
+
bool
Load(DisplaySystem displaySystem, const String * names, const String extension, bool oldStyle)
{
int i;
{
int i;
- for(i = 0; i < 6; i++)
+ bool result = true;
+ for(i = 0; result && i < 6; i++)
{
char location[MAX_LOCATION];
Bitmap face = i > 0 ? { } : this;
{
char location[MAX_LOCATION];
Bitmap face = i > 0 ? { } : this;
@@
-962,13
+963,16
@@
public:
if(face.Load(location, null, null))
{
face.driverData = driverData;
if(face.Load(location, null, null))
{
face.driverData = driverData;
- displaySystem.driver.MakeDDBitmap(displaySystem, face, true, (i + 1) | (oldStyle << 3));
+
result =
displaySystem.driver.MakeDDBitmap(displaySystem, face, true, (i + 1) | (oldStyle << 3));
}
}
+ else
+ result = false;
if(i > 0)
{
face.driverData = 0;
delete face;
}
}
if(i > 0)
{
face.driverData = 0;
delete face;
}
}
+ return result;
}
};
}
};
diff --git
a/ecere/src/gfx/drivers/Direct3D8DisplayDriver.ec
b/ecere/src/gfx/drivers/Direct3D8DisplayDriver.ec
index
de87cb4
..
567e81e
100644
(file)
--- a/
ecere/src/gfx/drivers/Direct3D8DisplayDriver.ec
+++ b/
ecere/src/gfx/drivers/Direct3D8DisplayDriver.ec
@@
-677,7
+677,7
@@
class Direct3D8DisplayDriver : DisplayDriver
{
bool result = false;
D3D8System d3dSystem = displaySystem.driverData;
{
bool result = false;
D3D8System d3dSystem = displaySystem.driverData;
- if(bitmap.Convert(null, pixelFormat888, null))
+ if(
cubeMapFace &&
bitmap.Convert(null, pixelFormat888, null))
{
IDirect3DTexture8 * texture;
uint w = pow2i(Min(bitmap.width, 512)), h = pow2i(Min(bitmap.height, 512));
{
IDirect3DTexture8 * texture;
uint w = pow2i(Min(bitmap.width, 512)), h = pow2i(Min(bitmap.height, 512));
diff --git
a/ecere/src/gfx/drivers/Direct3D9DisplayDriver.ec
b/ecere/src/gfx/drivers/Direct3D9DisplayDriver.ec
index
b57cfa1
..
b21d4c9
100644
(file)
--- a/
ecere/src/gfx/drivers/Direct3D9DisplayDriver.ec
+++ b/
ecere/src/gfx/drivers/Direct3D9DisplayDriver.ec
@@
-675,7
+675,7
@@
class Direct3D9DisplayDriver : DisplayDriver
{
bool result = false;
D3DSystem d3dSystem = displaySystem.driverData;
{
bool result = false;
D3DSystem d3dSystem = displaySystem.driverData;
- if(bitmap.Convert(null, pixelFormat888, null))
+ if(
!cubeMapFace &&
bitmap.Convert(null, pixelFormat888, null))
{
IDirect3DTexture9 * texture;
uint w = pow2i(Min(bitmap.width, 512)), h = pow2i(Min(bitmap.height, 512));
{
IDirect3DTexture9 * texture;
uint w = pow2i(Min(bitmap.width, 512)), h = pow2i(Min(bitmap.height, 512));