|
|
|
@ -1,7 +1,7 @@ |
|
|
|
#include "common.h"
|
|
|
|
#include "lighting.h"
|
|
|
|
|
|
|
|
bool sample_lightmap(const world_t* world, const face_t* face, const BoundBox& bounds, const Vec3& point, unsigned char* outSample) |
|
|
|
bool sample_lightmap(const world_t* world, const face_t* face, const FaceBound& bounds, const Vec3& point, unsigned char* outSample) |
|
|
|
{ |
|
|
|
if (face->lightmap < 0) |
|
|
|
return false; |
|
|
|
@ -9,8 +9,8 @@ bool sample_lightmap(const world_t* world, const face_t* face, const BoundBox& b |
|
|
|
const unsigned char* lightmap = &world->lightmap[face->lightmap]; |
|
|
|
const plane_t* plane = &world->planes[face->plane_id]; |
|
|
|
|
|
|
|
Vec3 minBounds = (bounds.min / 16).floor() * 16.f; |
|
|
|
Vec3 maxBounds = (bounds.max / 16).ceil() * 16.f; |
|
|
|
Vec3 minBounds = (bounds.worldBounds.min / 16).floor() * 16.f; |
|
|
|
Vec3 maxBounds = (bounds.worldBounds.max / 16).ceil() * 16.f; |
|
|
|
|
|
|
|
int width, height; |
|
|
|
int u, v; |
|
|
|
@ -52,7 +52,7 @@ bool sample_lightmap(const world_t* world, const face_t* face, const BoundBox& b |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
unsigned char sample_lightmap(const world_t* world, const face_t* face, const BoundBox& bounds, const Vec3& point) |
|
|
|
unsigned char sample_lightmap(const world_t* world, const face_t* face, const FaceBound& bounds, const Vec3& point) |
|
|
|
{ |
|
|
|
unsigned char sample; |
|
|
|
if (!sample_lightmap(world, face, bounds, point, &sample)) |
|
|
|
@ -61,7 +61,7 @@ unsigned char sample_lightmap(const world_t* world, const face_t* face, const Bo |
|
|
|
return sample; |
|
|
|
} |
|
|
|
|
|
|
|
void export_lightmap(const world_t* world, const face_t* face, const BoundBox& bounds, int faceIdx) |
|
|
|
void export_lightmap(const world_t* world, const face_t* face, const FaceBound& bounds, int faceIdx) |
|
|
|
{ |
|
|
|
if (face->lightmap < 0) |
|
|
|
return; |
|
|
|
@ -75,20 +75,20 @@ void export_lightmap(const world_t* world, const face_t* face, const BoundBox& b |
|
|
|
case 0: |
|
|
|
case 3: |
|
|
|
// Towards X
|
|
|
|
width = (int)(ceil(bounds.max.y / 16) - floor(bounds.min.y / 16)); |
|
|
|
height = (int)(ceil(bounds.max.z / 16) - floor(bounds.min.z / 16)); |
|
|
|
width = (int)(ceil(bounds.worldBounds.max.y / 16) - floor(bounds.worldBounds.min.y / 16)); |
|
|
|
height = (int)(ceil(bounds.worldBounds.max.z / 16) - floor(bounds.worldBounds.min.z / 16)); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
case 4: |
|
|
|
// Towards Y
|
|
|
|
width = (int)(ceil(bounds.max.x / 16) - floor(bounds.min.x / 16)); |
|
|
|
height = (int)(ceil(bounds.max.z / 16) - floor(bounds.min.z / 16)); |
|
|
|
width = (int)(ceil(bounds.worldBounds.max.x / 16) - floor(bounds.worldBounds.min.x / 16)); |
|
|
|
height = (int)(ceil(bounds.worldBounds.max.z / 16) - floor(bounds.worldBounds.min.z / 16)); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
case 5: |
|
|
|
// Towards Z
|
|
|
|
width = (int)(ceil(bounds.max.x / 16) - floor(bounds.min.x / 16)); |
|
|
|
height = (int)(ceil(bounds.max.y / 16) - floor(bounds.min.y / 16)); |
|
|
|
width = (int)(ceil(bounds.worldBounds.max.x / 16) - floor(bounds.worldBounds.min.x / 16)); |
|
|
|
height = (int)(ceil(bounds.worldBounds.max.y / 16) - floor(bounds.worldBounds.min.y / 16)); |
|
|
|
break; |
|
|
|
default: |
|
|
|
printf("Error: unknown plane type %d\n", plane->type); |
|
|
|
|