Add surface type map
This commit is contained in:
parent
fe100bb938
commit
e6ca952962
|
@ -8,6 +8,13 @@ namespace KeepersCompound.Lightmapper;
|
||||||
|
|
||||||
public class LightMapper
|
public class LightMapper
|
||||||
{
|
{
|
||||||
|
private enum SurfaceType
|
||||||
|
{
|
||||||
|
Solid,
|
||||||
|
Sky,
|
||||||
|
Water,
|
||||||
|
}
|
||||||
|
|
||||||
private class Settings
|
private class Settings
|
||||||
{
|
{
|
||||||
public Vector3 AmbientLight;
|
public Vector3 AmbientLight;
|
||||||
|
@ -22,6 +29,7 @@ public class LightMapper
|
||||||
private ObjectHierarchy _hierarchy;
|
private ObjectHierarchy _hierarchy;
|
||||||
private Raytracer _scene;
|
private Raytracer _scene;
|
||||||
private List<Light> _lights;
|
private List<Light> _lights;
|
||||||
|
private List<SurfaceType> _triangleTypeMap;
|
||||||
|
|
||||||
public LightMapper(
|
public LightMapper(
|
||||||
string installPath,
|
string installPath,
|
||||||
|
@ -33,6 +41,7 @@ public class LightMapper
|
||||||
_misPath = _campaign.GetResourcePath(ResourceType.Mission, missionName);
|
_misPath = _campaign.GetResourcePath(ResourceType.Mission, missionName);
|
||||||
_mission = Timing.TimeStage("Parse DB", () => new DbFile(_misPath));
|
_mission = Timing.TimeStage("Parse DB", () => new DbFile(_misPath));
|
||||||
_hierarchy = Timing.TimeStage("Build Hierarchy", BuildHierarchy);
|
_hierarchy = Timing.TimeStage("Build Hierarchy", BuildHierarchy);
|
||||||
|
_triangleTypeMap = [];
|
||||||
_scene = Timing.TimeStage("Build Scene", BuildRaytracingScene);
|
_scene = Timing.TimeStage("Build Scene", BuildRaytracingScene);
|
||||||
_lights = [];
|
_lights = [];
|
||||||
}
|
}
|
||||||
|
@ -132,12 +141,17 @@ public class LightMapper
|
||||||
vertices.Add(vertex);
|
vertices.Add(vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For now we're only differentiating between solid and sky because portal polys are skipped
|
||||||
|
var renderPoly = cell.RenderPolys[polyIdx];
|
||||||
|
var primType = renderPoly.TextureId == 249 ? SurfaceType.Sky : SurfaceType.Solid;
|
||||||
|
|
||||||
// Cell polygons are n-sided, but fortunately they're convex so we can just do a fan triangulation
|
// Cell polygons are n-sided, but fortunately they're convex so we can just do a fan triangulation
|
||||||
for (var j = 1; j < numPolyVertices - 1; j++)
|
for (var j = 1; j < numPolyVertices - 1; j++)
|
||||||
{
|
{
|
||||||
indices.Add(meshIndexOffset);
|
indices.Add(meshIndexOffset);
|
||||||
indices.Add(meshIndexOffset + j);
|
indices.Add(meshIndexOffset + j);
|
||||||
indices.Add(meshIndexOffset + j + 1);
|
indices.Add(meshIndexOffset + j + 1);
|
||||||
|
_triangleTypeMap.Add(primType);
|
||||||
}
|
}
|
||||||
|
|
||||||
cellIdxOffset += cell.Polys[polyIdx].VertexCount;
|
cellIdxOffset += cell.Polys[polyIdx].VertexCount;
|
||||||
|
|
Loading…
Reference in New Issue