Skip to content

Commit

Permalink
Version 0.9.1 hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
wesselfr committed May 25, 2023
1 parent cdf18f3 commit 7c81f80
Show file tree
Hide file tree
Showing 466 changed files with 1,245 additions and 423 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CMake

on:
push:
branches: [ "master" , "develop" ]
pull_request:
branches: [ "master" , "develop" ]

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-latest

strategy:
matrix:
preset: [directx12-win-debug, directx12-win-release, openGL-x64-debug, openGL-x64-release]

steps:
- uses: actions/checkout@v3

- name: Setup MSVC Console
uses: TheMrMilchmann/setup-msvc-dev@v2
with:
arch: x64

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake --preset ${{matrix.preset}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/out/build/${{matrix.preset}}

#- name: Test
# working-directory: ${{github.workspace}}/../out/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: ctest -C ${{env.BUILD_TYPE}}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ D1X_RAYTRACER_NAME="D1X_RAYTRACER"

D1X_RAYTRACER_VERSION_MAJORi=0
D1X_RAYTRACER_VERSION_MINORi=9
D1X_RAYTRACER_VERSION_MICROi=0
D1X_RAYTRACER_VERSION_MICROi=1

#DXX-Retro last used version
DXX_VERSION_MAJORi=0
Expand Down
2 changes: 0 additions & 2 deletions RT/Core/SlotMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ namespace RT

void Remove(RT_ResourceHandle handle)
{
T *result = nullptr;

Slot *sentinel = &m_slots[0];
if (RT_RESOURCE_HANDLE_VALID(handle))
{
Expand Down
45 changes: 18 additions & 27 deletions RT/Game/Lights.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,40 +237,31 @@ void RT_ShowLightMenu()
{
igPushID_Int(i);
RT_LightDefinition* light = &g_light_definitions[i];
ushort texture_index = piggy_find_bitmap(light->name).index;

char* light_name_buffer = RT_ArenaPrintF(&g_thread_arena, "Light: %s", light->name);
if (igCollapsingHeader_TreeNodeFlags(light_name_buffer, ImGuiTreeNodeFlags_None)) {
if (texture_index > 0){
char* light_name_buffer = RT_ArenaPrintF(&g_thread_arena, "Light: %s", light->name);
if (igCollapsingHeader_TreeNodeFlags(light_name_buffer, ImGuiTreeNodeFlags_None)) {

igText("Texture index: %i", piggy_find_bitmap(light->name).index);
igText("Texture index: %i", texture_index);

RT_Material *def = &g_rt_materials[piggy_find_bitmap(light->name).index];
RT_RenderImGuiTexture(def->albedo_texture, 64.0, 64.0);
RT_Material *def = &g_rt_materials[texture_index];
RT_RenderImGuiTexture(def->albedo_texture, 64.0, 64.0);

igText("Type:");
bool changed_type = false;
changed_type |= igRadioButton_IntPtr("Sphere", &light->kind, RT_LightKind_Area_Sphere);
changed_type |= igRadioButton_IntPtr("Rect", &light->kind, RT_LightKind_Area_Rect);

if (changed_type)
{
g_pending_light_update = true;
}

igText("Emission: {%f, %f, %f}", light->emission.x, light->emission.y, light->emission.z);
igText("Emission: {%f, %f, %f}", light->emission.x, light->emission.y, light->emission.z);

if (igColorEdit3("Emission", &light->emission, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR))
{
g_pending_light_update = true;
}
if (igColorEdit3("Emission", &light->emission, ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR)){
g_pending_light_update = true;
}

igSliderFloat("Spot Angle", &light->spot_angle, 0.0f, 1.0f, "%f", ImGuiSliderFlags_None);
igSliderFloat("Light Radius", &light->spot_softness, 0.0f, 1.0f, "%f", ImGuiSliderFlags_None);
igSliderFloat("Spot Angle", &light->spot_angle, 0.0f, 1.0f, "%f", ImGuiSliderFlags_None);
igSliderFloat("Light Radius", &light->spot_softness, 0.0f, 1.0f, "%f", ImGuiSliderFlags_None);

if (light->kind == RT_LightKind_Area_Sphere)
{
igText("Radius: %f", light->radius);
igSliderFloat("Light Radius", &light->radius, 0.0f, 10.0f, "%f", ImGuiSliderFlags_None);
g_pending_light_update = true;
if (light->kind == RT_LightKind_Area_Sphere){
igText("Radius: %f", light->radius);
igSliderFloat("Light Radius", &light->radius, 0.0f, 10.0f, "%f", ImGuiSliderFlags_None);
g_pending_light_update = true;
}
}
}
igPopID();
Expand Down
9 changes: 5 additions & 4 deletions RT/Game/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
RT_ResourceHandle g_level_resource = { 0 };
int g_active_level = 0;

int m_light_count = 1;
int m_light_count = 0;
RT_Light m_lights[1024] = {0};
int m_lights_definitions[1024] = {0};
side* m_extracted_light_sides[1024] = {0};
Expand Down Expand Up @@ -204,6 +204,8 @@ void RT_ExtractLightsFromSide(side *side, RT_Vertex *vertices, RT_Vec3 normal)

bool RT_LoadLevel()
{


assert(!RT_RESOURCE_HANDLE_VALID(g_level_resource));
// Load level geometry
g_level_resource = RT_UploadLevelGeometry();
Expand Down Expand Up @@ -254,8 +256,7 @@ void RT_RenderLevel(RT_Vec3 player_pos)
// ------------------------------------------------------------------

// Unload current level if other level becomes active.
// TODO: Given mesh unloading is currently not supported, this function will leak memory!!
if (g_active_level != Current_level_num)
if (g_active_level != Current_level_num && RT_RESOURCE_HANDLE_VALID(g_level_resource))
{
RT_UnloadLevel();
}
Expand All @@ -275,7 +276,7 @@ void RT_RenderLevel(RT_Vec3 player_pos)

bool RT_UnloadLevel()
{
// TODO: Unload mesh doesn't exsist yet, level will leak now.
RT_ReleaseMesh(g_level_resource);
g_level_resource = RT_RESOURCE_HANDLE_NULL;

m_light_count = 0;
Expand Down
99 changes: 45 additions & 54 deletions RT/RTgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ static void RT_GetPolyData(RT_TriangleBuffer *buf,
}

short color = w(p + 28);

// NOTE(daniel): I hope the palette is initialized correctly!
ubyte r = gr_palette[color*3 + 0]*4;
ubyte g = gr_palette[color*3 + 1]*4;
Expand Down Expand Up @@ -839,78 +840,68 @@ void RT_DrawSubPolyModel(const RT_ResourceHandle submodel, const RT_Mat4* const
}
}

void RT_DrawPolySubModelTree(const polymodel* model, const vms_angvec* const anim_angles, int index, const int obj_num, const RT_Mat4 submodel_transform) {
bool rendered_before = false;
void RT_DrawPolySubModelTree(const polymodel* model, const vms_angvec* const anim_angles, int index, const int obj_num, const RT_Mat4 submodel_transform)
{
RT_SubmodelTransforms* prev_transforms = &g_rt_prev_submodel_transforms[obj_num];

RT_Mat4 prev_transform = prev_transforms->transforms[index];

// NOTE (Sam)
// I think this is not an issue anymore as the double draw only happened when shooting the lasers.
// Even before we make a new system for the motion vectors it will still not effect anything.
#if 0
typedef struct RT_ObjRenderDebug
{
uint64_t submodels[MAX_SUBMODELS];
} RT_ObjRenderDebug;

static RT_ObjRenderDebug obj_num_last_frame_rendered[MAX_OBJECTS];
if (g_rt_frame_index != 0 && obj_num_last_frame_rendered[obj_num].submodels[index] == g_rt_frame_index)
{
// This should never happen. There is a check for this exact kind of thing in render.c, line 592.
// So why is it happening?
rendered_before = true;
// This is very spammy so turn it on when you want to actually see it.
#if 0
prev_transform = submodel_transform;
// NOTE(daniel): This issue of different rendered meshes not being properly uniquely identified will be fixed
// differently, so for now just render things twice and bust the motion vectors a little bit.
RT_LOGF(RT_LOGSERVERITY_INFO, "Submodel %d, %d was rendered more than once on frame %llu", obj_num, index, g_rt_frame_index);
#endif

}
obj_num_last_frame_rendered[obj_num].submodels[index] = g_rt_frame_index;
#endif

// NOTE(daniel): This issue of different rendered meshes not being properly uniquely identified will be fixed
// differently, so for now just render things twice and bust the motion vectors a little bit.
// if (!rendered_before)
{
RT_SubmodelTransforms *prev_transforms = &g_rt_prev_submodel_transforms[obj_num];
// Draw the submodel
RT_DrawSubPolyModel(model->submodel[index], &submodel_transform, &prev_transform);
prev_transforms->transforms[index] = submodel_transform;

RT_Mat4 prev_transform = prev_transforms->transforms[index];
if (prev_transforms->last_frame_updated[index] != g_rt_frame_index - 1)
{
RT_LOGF(RT_LOGSERVERITY_INFO, "Prev submodel transform (%d:%d) was not from the previous frame.", obj_num, index);
prev_transform = submodel_transform;
}
// Traverse tree structure
for (int i = 0; i < model->model_tree[index].n_children; ++i) {
// anim_angles is an array, where the indices into that array allegedly correspond directly to the child indices :D
const int child_index = model->model_tree[index].child_indices[i];

// Draw the submodel
RT_DrawSubPolyModel(model->submodel[index], &submodel_transform, &prev_transform);
prev_transforms->transforms[index] = submodel_transform;
prev_transforms->last_frame_updated[index] = g_rt_frame_index;

// Traverse tree structure
for (int i = 0; i < model->model_tree[index].n_children; ++i) {
// anim_angles is an array, where the indices into that array allegedly correspond directly to the child indices :D
const int child_index = model->model_tree[index].child_indices[i];

vms_angvec anim_angles_final;
if (anim_angles) {
anim_angles_final.p = anim_angles[child_index].p;
anim_angles_final.b = anim_angles[child_index].b;
anim_angles_final.h = anim_angles[child_index].h;
}
else {
anim_angles_final.p = zero_angles.p;
anim_angles_final.b = zero_angles.b;
anim_angles_final.h = zero_angles.h;
}
vms_angvec anim_angles_final;
if (anim_angles) {
anim_angles_final.p = anim_angles[child_index].p;
anim_angles_final.b = anim_angles[child_index].b;
anim_angles_final.h = anim_angles[child_index].h;
}
else {
anim_angles_final.p = zero_angles.p;
anim_angles_final.b = zero_angles.b;
anim_angles_final.h = zero_angles.h;
}

// Get matrix from local position offset
const vms_vector offset_vms = model->submodel_offsets[child_index];
const RT_Vec3 offset_vec3 = RT_Vec3Fromvms_vector(&offset_vms);
RT_Mat4 offset_mat4 = RT_Mat4FromTranslation(offset_vec3);
offset_mat4 = RT_Mat4Mul(submodel_transform, offset_mat4);
// Get matrix from local position offset
const vms_vector offset_vms = model->submodel_offsets[child_index];
const RT_Vec3 offset_vec3 = RT_Vec3Fromvms_vector(&offset_vms);
RT_Mat4 offset_mat4 = RT_Mat4FromTranslation(offset_vec3);
offset_mat4 = RT_Mat4Mul(submodel_transform, offset_mat4);

// Get matrix from rotation offset
vms_matrix rotation_vms;
vm_angles_2_matrix(&rotation_vms, &anim_angles_final);
RT_Mat4 rotation_mat4 = RT_Mat4Fromvms_matrix(&rotation_vms);
// Get matrix from rotation offset
vms_matrix rotation_vms;
vm_angles_2_matrix(&rotation_vms, &anim_angles_final);
RT_Mat4 rotation_mat4 = RT_Mat4Fromvms_matrix(&rotation_vms);

// Combine them into one big matrix
RT_Mat4 combined_matrix = RT_Mat4Mul(offset_mat4, rotation_mat4);
// Combine them into one big matrix
RT_Mat4 combined_matrix = RT_Mat4Mul(offset_mat4, rotation_mat4);

RT_DrawPolySubModelTree(model, anim_angles, child_index, obj_num, combined_matrix);
}
RT_DrawPolySubModelTree(model, anim_angles, child_index, obj_num, combined_matrix);
}
}

Expand Down
Loading

0 comments on commit 7c81f80

Please sign in to comment.