Skip to content

Commit

Permalink
fix build issues for editor
Browse files Browse the repository at this point in the history
  • Loading branch information
goopey7 committed Dec 30, 2023
1 parent 79f5bf9 commit 1057ba3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ file(GLOB STB_IMAGE_HEADER "libs/stb/stb_image.h")
add_executable(${PROJECT_NAME} ${ENGINE_SRC_FILES} ${STB_VORBIS_SOURCE})

#define app type
#target_compile_definitions(${PROJECT_NAME} PRIVATE GOOP_APPTYPE_EDITOR=1)
target_compile_definitions(${PROJECT_NAME} PRIVATE GOOP_APPTYPE_EDITOR=1)

# define systems
target_compile_definitions(${PROJECT_NAME} PRIVATE GOOP_RENDERER_VULKAN)
Expand Down
26 changes: 23 additions & 3 deletions goop/sys/platform/vulkan/Renderer_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ void Renderer_Vulkan::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_
buffers->getIndexBuffer(currentFrame) != nullptr)
{
// for each different instance, render all instances of that mesh
size_t uniqueInstances = buffers->getNumUniqueInstances(currentFrame);
for (size_t i = 0; i < buffers->getNumUniqueInstances(currentFrame); i++)
{
int instanceCount = buffers->getInstanceCount(currentFrame, i);
Expand Down Expand Up @@ -477,14 +476,35 @@ bool Renderer_Vulkan::renderScene(uint32_t width, uint32_t height, uint32_t imag
buffers->getIndexBuffer(currentFrame) != nullptr)
{
// for each different instance, render all instances of that mesh
size_t uniqueInstances = buffers->getNumUniqueInstances(currentFrame);
for (size_t i = 0; i < buffers->getNumUniqueInstances(currentFrame); i++)
{
int instanceCount = buffers->getInstanceCount(currentFrame, i);
int instanceOffset = buffers->getInstanceOffsets(currentFrame, i);
int indexCount = buffers->getIndexCount(currentFrame, i);
int indexOffset = buffers->getIndexOffset(currentFrame, i);
vkCmdDrawIndexed(cb, indexCount, instanceCount, indexOffset, 0, instanceOffset);
int meshID = buffers->getMeshID(currentFrame, i);
// get entities who have the mesh ID we're rendering
std::queue<Entity> entitiesToRender;
auto view = scene->view<MeshComponent>();
for (auto entity : view)
{
Entity e = goop::Entity(entity, scene);
if (e.getComponent<MeshComponent>().id == meshID)
{
entitiesToRender.push(goop::Entity(entity, scene));
}
}

for (int instanceIndex = instanceOffset; instanceIndex < instanceOffset + instanceCount;
instanceIndex++)
{
auto transform =
entitiesToRender.front().getComponent<TransformComponent>().transform;
vkCmdPushConstants(cb, pipeline->getPipelineLayout(),
VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::mat4), &transform);
vkCmdDrawIndexed(cb, indexCount, 1, indexOffset, 0, instanceIndex);
entitiesToRender.pop();
}
}
}

Expand Down

0 comments on commit 1057ba3

Please sign in to comment.