Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
313 changes: 48 additions & 265 deletions README.md

Large diffs are not rendered by default.

Binary file added img/collision.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cullingTestView.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/graph1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/graph2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/screenshot2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/screenshot3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/tessel_high.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/tessel_low.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/Blades.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <array>
#include "Model.h"

constexpr static unsigned int NUM_BLADES = 1 << 13;
//constexpr static unsigned int NUM_BLADES = 1 << 13;
constexpr static unsigned int NUM_BLADES = 1 << 17; // 1 << 20;
constexpr static float MIN_HEIGHT = 1.3f;
constexpr static float MAX_HEIGHT = 2.5f;
constexpr static float MIN_WIDTH = 0.1f;
Expand Down
44 changes: 44 additions & 0 deletions src/CollidorSphere.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <iostream>

#define GLM_FORCE_RADIANS
// Use Vulkan depth range of 0.0 to 1.0 instead of OpenGL
#define GLM_FORCE_DEPTH_ZERO_TO_ONE

#include "CollidorSphere.h"
#include "BufferUtils.h"

CollidorSphere::CollidorSphere(Device* device, glm::vec3 centroid_pos, float radius) : device(device) {

collidorSphereObject.collidorSphereInfo = glm::vec4(centroid_pos, radius);


BufferUtils::CreateBuffer(device, sizeof(CollidorSphereObject), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, buffer, bufferMemory);
vkMapMemory(device->GetVkDevice(), bufferMemory, 0, sizeof(CollidorSphereObject), 0, &mappedData);
memcpy(mappedData, &collidorSphereObject, sizeof(CollidorSphereObject));
}

VkBuffer CollidorSphere::GetBuffer() const {
return buffer;
}

void CollidorSphere::UpdatePosition(glm::vec3 moveDir) {

glm::vec4 originInfo = collidorSphereObject.collidorSphereInfo;
glm::vec3 originPos = glm::vec3(originInfo);

float moveSpeed = 0.2f;

glm::vec3 newPos = originPos + moveSpeed * moveDir;
newPos.x = glm::clamp(newPos.x, -25.0f, 25.0f);
newPos.z = glm::clamp(newPos.z, -25.0f, 25.0f);

collidorSphereObject.collidorSphereInfo = glm::vec4(newPos, originInfo.w);

memcpy(mappedData, &collidorSphereObject, sizeof(CollidorSphereObject));
}

CollidorSphere::~CollidorSphere() {
vkUnmapMemory(device->GetVkDevice(), bufferMemory);
vkDestroyBuffer(device->GetVkDevice(), buffer, nullptr);
vkFreeMemory(device->GetVkDevice(), bufferMemory, nullptr);
}
29 changes: 29 additions & 0 deletions src/CollidorSphere.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <glm/glm.hpp>
#include "Device.h"

struct CollidorSphereObject {
glm::vec4 collidorSphereInfo;
};

class CollidorSphere {
private:
Device* device;

CollidorSphereObject collidorSphereObject;

VkBuffer buffer;
VkDeviceMemory bufferMemory;

void* mappedData;


public:
CollidorSphere(Device* device, glm::vec3 centroid_pos, float radius);
~CollidorSphere();

VkBuffer GetBuffer() const;

void UpdatePosition(glm::vec3 moveDir);
};
Loading