aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2015-06-02 09:54:51 +0200
committerraysan5 <raysan5@gmail.com>2015-06-02 09:54:51 +0200
commit6a4afae5cc3c6b8677c8c22f02bdf2b926d517a8 (patch)
tree359403ad83f775dd3b2e205fc1876e79327eefa1 /src
parentfd851d1d8b4919d802bcc5041f9a9ff37669d159 (diff)
downloadraylib-6a4afae5cc3c6b8677c8c22f02bdf2b926d517a8.tar.gz
raylib-6a4afae5cc3c6b8677c8c22f02bdf2b926d517a8.zip
Improved ResolveCollisionCubicmap()
Now it supports multiple maps one next to the other
Diffstat (limited to 'src')
-rw-r--r--src/models.c308
-rw-r--r--src/rlgl.c14
2 files changed, 183 insertions, 139 deletions
diff --git a/src/models.c b/src/models.c
index be1b949a..179032d4 100644
--- a/src/models.c
+++ b/src/models.c
@@ -1171,7 +1171,10 @@ void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size,
MatrixTranspose(&viewMatrix);
Vector3 right = { viewMatrix.m0, viewMatrix.m4, viewMatrix.m8 };
- Vector3 up = { viewMatrix.m1, viewMatrix.m5, viewMatrix.m9 };
+ //Vector3 up = { viewMatrix.m1, viewMatrix.m5, viewMatrix.m9 };
+
+ // NOTE: Billboard locked to axis-Y
+ Vector3 up = { 0, 1, 0 };
/*
a-------b
| |
@@ -1351,180 +1354,219 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
int locationCellX = 0;
int locationCellY = 0;
- locationCellX = floor(playerPosition->x + mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE);
- locationCellY = floor(playerPosition->z + mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE);
-
- // Multiple Axis --------------------------------------------------------------------------------------------
+ locationCellX = floor(playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE);
+ locationCellY = floor(playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE);
- // Axis x-, y-
- if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) &&
- (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0))
+ if (locationCellX >= 0 && locationCellY >= 0 && locationCellX < cubicmap.width && locationCellY < cubicmap.height)
{
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
+ // Multiple Axis --------------------------------------------------------------------------------------------
+
+ // Axis x-, y-
+ if (locationCellX > 0 && locationCellY > 0)
{
- playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- impactDirection = (Vector3) { 1, 0, 1};
+ if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) &&
+ (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0))
+ {
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
+ {
+ playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ impactDirection = (Vector3) { 1, 0, 1};
+ }
+ }
}
- }
- // Axis x-, y+
- if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) &&
- (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0))
- {
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
+ // Axis x-, y+
+ if (locationCellX > 0 && locationCellY < cubicmap.height - 1)
{
- playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- impactDirection = (Vector3) { 1, 0, 1};
+ if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) &&
+ (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0))
+ {
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
+ {
+ playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ impactDirection = (Vector3) { 1, 0, 1};
+ }
+ }
}
- }
- // Axis x+, y-
- if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) &&
- (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0))
- {
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
+ // Axis x+, y-
+ if (locationCellX < cubicmap.width - 1 && locationCellY > 0)
{
- playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- impactDirection = (Vector3) { 1, 0, 1};
+ if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) &&
+ (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0))
+ {
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
+ {
+ playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ impactDirection = (Vector3) { 1, 0, 1};
+ }
+ }
}
- }
- // Axis x+, y+
- if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) &&
- (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0))
- {
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
+ // Axis x+, y+
+ if (locationCellX < cubicmap.width - 1 && locationCellY < cubicmap.height - 1)
{
- playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- impactDirection = (Vector3) { 1, 0, 1};
+ if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) &&
+ (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0))
+ {
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
+ {
+ playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ impactDirection = (Vector3) { 1, 0, 1};
+ }
+ }
}
- }
- // Single Axis ---------------------------------------------------------------------------------------------------
+ // Single Axis ---------------------------------------------------------------------------------------------------
- // Axis x-
- if (cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0)
- {
- if ((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius)
+ // Axis x-
+ if (locationCellX > 0)
{
- playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- impactDirection = (Vector3) { 1, 0, 0};
+ if (cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0)
+ {
+ if ((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius)
+ {
+ playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ impactDirection = (Vector3) { 1, 0, 0};
+ }
+ }
}
- }
- // Axis x+
- if (cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0)
- {
- if ((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius)
+ // Axis x+
+ if (locationCellX < cubicmap.width - 1)
{
- playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- impactDirection = (Vector3) { 1, 0, 0};
+ if (cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0)
+ {
+ if ((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius)
+ {
+ playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ impactDirection = (Vector3) { 1, 0, 0};
+ }
+ }
}
- }
- // Axis y-
- if (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0)
- {
- if ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)
+ // Axis y-
+ if (locationCellY > 0)
{
- playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- impactDirection = (Vector3) { 0, 0, 1};
+ if (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0)
+ {
+ if ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)
+ {
+ playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ impactDirection = (Vector3) { 0, 0, 1};
+ }
+ }
}
- }
- // Axis y+
- if (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0)
- {
- if ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)
+ // Axis y+
+ if (locationCellY < cubicmap.height - 1)
{
- playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- impactDirection = (Vector3) { 0, 0, 1};
+ if (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0)
+ {
+ if ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)
+ {
+ playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ impactDirection = (Vector3) { 0, 0, 1};
+ }
+ }
}
- }
- // Diagonals -------------------------------------------------------------------------------------------------------
+ // Diagonals -------------------------------------------------------------------------------------------------------
- // Axis x-, y-
- if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r == 0) &&
- (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r == 0) &&
- (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX - 1)].r != 0))
- {
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
+ // Axis x-, y-
+ if (locationCellX > 0 && locationCellY > 0)
{
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) > ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY)) playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- else playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
-
- // Return ricochet
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
+ if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r == 0) &&
+ (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r == 0) &&
+ (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX - 1)].r != 0))
{
- impactDirection = (Vector3) { 1, 0, 1};
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
+ {
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) > ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY)) playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ else playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+
+ // Return ricochet
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
+ {
+ impactDirection = (Vector3) { 1, 0, 1};
+ }
+ }
}
}
- }
- // Axis x-, y+
- if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r == 0) &&
- (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r == 0) &&
- (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX - 1)].r != 0))
- {
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
+ // Axis x-, y+
+ if (locationCellX > 0 && locationCellY < cubicmap.height - 1)
{
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) > (1 - ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY))) playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- else playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
-
- // Return ricochet
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
+ if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r == 0) &&
+ (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r == 0) &&
+ (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX - 1)].r != 0))
{
- impactDirection = (Vector3) { 1, 0, 1};
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
+ {
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) > (1 - ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY))) playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ else playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+
+ // Return ricochet
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
+ {
+ impactDirection = (Vector3) { 1, 0, 1};
+ }
+ }
}
}
- }
- // Axis x+, y-
- if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r == 0) &&
- (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r == 0) &&
- (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX + 1)].r != 0))
- {
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
+ // Axis x+, y-
+ if (locationCellX < cubicmap.width - 1 && locationCellY > 0)
{
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) < (1 - ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY))) playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- else playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
-
- // Return ricochet
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
+ if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r == 0) &&
+ (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r == 0) &&
+ (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX + 1)].r != 0))
{
- impactDirection = (Vector3) { 1, 0, 1};
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
+ {
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) < (1 - ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY))) playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ else playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+
+ // Return ricochet
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
+ {
+ impactDirection = (Vector3) { 1, 0, 1};
+ }
+ }
}
}
- }
- // Axis x+, y+
- if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r == 0) &&
- (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r == 0) &&
- (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX + 1)].r != 0))
- {
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
+ // Axis x+, y+
+ if (locationCellX < cubicmap.width - 1 && locationCellY < cubicmap.height - 1)
{
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) < ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY)) playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
- else playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
-
- // Return ricochet
- if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
- ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
+ if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r == 0) &&
+ (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r == 0) &&
+ (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX + 1)].r != 0))
{
- impactDirection = (Vector3) { 1, 0, 1};
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
+ {
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) < ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY)) playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+ else playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
+
+ // Return ricochet
+ if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
+ ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
+ {
+ impactDirection = (Vector3) { 1, 0, 1};
+ }
+ }
}
}
}
diff --git a/src/rlgl.c b/src/rlgl.c
index 6a938df3..9f9ab169 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -877,7 +877,7 @@ void rlglInit(void)
TraceLog(INFO, "Number of supported extensions: %i", numExt);
// Show supported extensions
- for (int i = 0; i < numExt; i++) TraceLog(INFO, "Supported extension: %s", ext[i]);
+ //for (int i = 0; i < numExt; i++) TraceLog(INFO, "Supported extension: %s", ext[i]);
// Check required extensions
for (int i = 0; i < numExt; i++)
@@ -1377,12 +1377,16 @@ void rlglDrawModel(Model model, Vector3 position, float rotationAngle, Vector3 r
glEnableVertexAttribArray(model.shader.normalLoc);
}
+ glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, model.texture.id);
+ //glActiveTexture(GL_TEXTURE1);
+ //glBindTexture(GL_TEXTURE_2D, 4);
glDrawArrays(GL_TRIANGLES, 0, model.mesh.vertexCount);
glBindTexture(GL_TEXTURE_2D, 0); // Unbind textures
-
+ glActiveTexture(GL_TEXTURE0);
+
if (vaoSupported) glBindVertexArray(0); // Unbind VAO
else glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind VBOs
@@ -2128,11 +2132,9 @@ void rlglSetDefaultShader(void)
int GetShaderLocation(Shader shader, const char *uniformName)
{
- int location = 0;
-
- location = glGetUniformLocation(shader.id, uniformName);
+ int location = glGetUniformLocation(shader.id, uniformName);
- if (location == 0) TraceLog(WARNING, "[SHDR %i] Shader location for %s could not be found", shader.id, uniformName);
+ if (location == -1) TraceLog(WARNING, "[SHDR ID %i] Shader location for %s could not be found", shader.id, uniformName);
return location;
}