You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
2.0 KiB
53 lines
2.0 KiB
#pragma once
|
|
|
|
#include "bsp.h"
|
|
#include "matrix.h"
|
|
|
|
struct EdgeData
|
|
{
|
|
int edgeIndex = 0;
|
|
const edge_t* edge = nullptr;
|
|
std::vector<const face_t*> faces;
|
|
bool isSharpEdge = false;
|
|
};
|
|
|
|
struct Surface
|
|
{
|
|
std::unordered_set<const face_t*> faces;
|
|
};
|
|
|
|
struct FaceBound
|
|
{
|
|
BoundBox worldBounds;
|
|
Matrix4x4 textureTransform;
|
|
BoundBox textureBounds;
|
|
Matrix4x4 lightmapTransform;
|
|
BoundBox lightmapBounds;
|
|
|
|
void addTexturePoint(double s, double t)
|
|
{
|
|
textureBounds.includePoint(Vec3(s, t, 0.0));
|
|
}
|
|
|
|
void addLightmapPoint(double s, double t)
|
|
{
|
|
lightmapBounds.includePoint(Vec3(s, t, 0.0));
|
|
}
|
|
};
|
|
|
|
typedef std::unordered_map<const face_t*, FaceBound> FaceBounds;
|
|
typedef std::unordered_map<const vertex_t*, std::unordered_set<const face_t*>> VertexFaces;
|
|
typedef std::vector<Surface> SurfaceList;
|
|
|
|
bool sample_lightmap(const world_t* world, const face_t* face, const FaceBound& bounds, const Vec3& point, unsigned char* outSample);
|
|
unsigned char sample_lightmap(const world_t* world, const face_t* face, const FaceBound& bounds, const Vec3& point);
|
|
void export_lightmap(const world_t* world, const face_t* face, const FaceBound& bounds, int faceIdx);
|
|
|
|
std::unordered_map<const edge_t*, EdgeData> analyze_edges(const world_t* world);
|
|
unsigned char compute_faceVertex_light(const world_t* world, const face_t* face, unsigned short vertexIndex, const FaceBounds& faceBounds, const std::unordered_map<const edge_t*, EdgeData>& edgeData);
|
|
unsigned char compute_faceVertex_light2(const world_t* world, const face_t* face, unsigned short vertexIndex, const FaceBounds& faceBounds, const VertexFaces& vertexFaces);
|
|
|
|
SurfaceList group_surfaces(const world_t* world, const VertexFaces& vertexFaces);
|
|
unsigned char compute_faceVertex_light3(const world_t* world, const face_t* refFace, const FaceBounds& faceBounds, Vec3 point);
|
|
unsigned char compute_faceVertex_light4(const world_t* world, const face_t* refFace, const FaceBounds& faceBounds, Vec3 point);
|
|
unsigned char compute_faceVertex_light5(const world_t* world, const face_t* refFace, const FaceBounds& faceBounds, Vec3 point);
|