Skip to content

Commit

Permalink
feat: fix broken editor planes
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend committed Jun 13, 2024
1 parent a1621ae commit b6690b2
Show file tree
Hide file tree
Showing 18 changed files with 337 additions and 331 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ jobs:
sudo apt-get install ninja-build cmake libdevil-dev mesa-common-dev libxmu-dev libxi-dev libgl-dev libx11-dev libxft-dev libxext-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libglu1-mesa-dev libgtk-3-dev libvulkan-dev vulkan-tools glslang-tools
- name: Configure
run: |
mkdir ${{ github.workspace }}/build && cd ${{ github.workspace }}/build
cd ${{ github.workspace }}
cmake ${{ github.workspace }} -DVCPKG_INSTALL_OPTIONS="--binarysource=clear\;x-gha,readwrite" -G Ninja
- name: Build
run: |
cd ${{ github.workspace }}/build
cd ${{ github.workspace }}
ninja
- name: Package Amnesia
working-directory: ./build
run: tar -czvf ../amnesia-linux-x86-64-release.tar.gz *
- name: Upload Amnesia artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: amnesia-linux-x86-64-release
path: amnesia-linux-x86-64-release.tar.gz
path: build
windows:
runs-on: windows-latest
steps:
Expand Down
22 changes: 13 additions & 9 deletions HPL2/include/graphics/SubMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ namespace hpl {
friend class cSubMeshEntity;

public:
struct NotifyMesh {
uint32_t m_semanticSize;
ShaderSemantic m_semantic[12];
uint32_t changeIndexData: 1;
};
using NotifySubMeshChanged = hpl::Event<NotifyMesh>;
NotifySubMeshChanged m_notify;


// preset traits that are expected throughout the engine
struct PostionTrait {
using Type = float3;
Expand Down Expand Up @@ -81,29 +90,25 @@ namespace hpl {
}

StreamBufferInfo(const StreamBufferInfo& other):
m_gpuBuffer(other.m_gpuBuffer),
m_buffer(other.m_buffer),
m_semantic(other.m_semantic),
m_stride(other.m_stride),
m_numberElements(other.m_numberElements){
}
StreamBufferInfo(StreamBufferInfo&& other):
m_gpuBuffer(std::move(other.m_gpuBuffer)),
m_buffer(std::move(other.m_buffer)),
m_semantic(other.m_semantic),
m_stride(other.m_stride),
m_numberElements(other.m_numberElements){
}

void operator=(const StreamBufferInfo& other) {
m_gpuBuffer = other.m_gpuBuffer;
m_buffer = other.m_buffer;
m_semantic = other.m_semantic;
m_stride = other.m_stride;
m_numberElements = other.m_numberElements;
}
void operator=(StreamBufferInfo&& other) {
m_gpuBuffer = std::move(other.m_gpuBuffer);
m_buffer = std::move(other.m_buffer);
m_semantic = other.m_semantic;
m_stride = other.m_stride;
Expand All @@ -124,9 +129,7 @@ namespace hpl {
constexpr GraphicsBuffer::BufferStructuredView<T> GetStructuredView(uint32_t byteOffset = 0) {
return m_buffer.CreateStructuredView<T>(byteOffset, m_stride);
}
SharedBuffer CommitSharedBuffer();

SharedBuffer m_gpuBuffer;
GraphicsBuffer m_buffer;
uint32_t m_stride = 0;
uint32_t m_numberElements = 0;
Expand Down Expand Up @@ -203,12 +206,14 @@ namespace hpl {

void AddCollider(const MeshCollisionResource& def);
std::span<MeshCollisionResource> GetColliders();
inline std::span<StreamBufferInfo> streamBuffers() {return m_vertexStreams; }
inline std::span<StreamBufferInfo> streamBuffers() { return m_vertexStreams; }
inline std::span<StreamBufferInfo>::iterator getStreamBySemantic(ShaderSemantic semantic) {
return std::find_if(streamBuffers().begin(), streamBuffers().end(), [&](auto& stream) {
return stream.m_semantic == semantic;
});
}


inline IndexBufferInfo& IndexStream() {return m_indexStream; }
void SetIsCollideShape(bool abX) {
m_collideShape = abX;
Expand Down Expand Up @@ -257,9 +262,8 @@ namespace hpl {
bool hasMesh();
void SetStreamBuffers(iVertexBuffer* buffer, std::vector<StreamBufferInfo>&& vertexStreams, IndexBufferInfo&& indexStream);
void Compile();

void CommitBuffer(ShaderSemantic semantic);
private:

cMaterialManager* m_materialManager = nullptr;
tString m_name;

Expand Down
5 changes: 4 additions & 1 deletion HPL2/include/physics/PhysicsWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <map>
#include "graphics/DebugDraw.h"
#include "graphics/GraphicsBuffer.h"
#include "system/SystemTypes.h"
#include "math/MathTypes.h"
#include "graphics/GraphicsTypes.h"
Expand Down Expand Up @@ -127,8 +128,10 @@ namespace hpl {
virtual iCollideShape* CreateSphereShape(const cVector3f &avRadii, cMatrixf* apOffsetMtx)=0;
virtual iCollideShape* CreateCylinderShape(float afRadius, float afHeight, cMatrixf* apOffsetMtx)=0;
virtual iCollideShape* CreateCapsuleShape(float afRadius, float afHeight, cMatrixf* apOffsetMtx)=0;

virtual iCollideShape* CreateMeshShape(iVertexBuffer *apVtxBuffer)=0;
//virtual iCollideShape* CreateMeshShape(size_t numberVerticies,
// GraphicsBuffer::BufferIndexView indexView,
// GraphicsBuffer::BufferStructuredView<float3> position)=0;
/**
* The buffer position must be pointing to where the data is saved!
*/
Expand Down
3 changes: 0 additions & 3 deletions HPL2/include/scene/MeshEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ namespace hpl {

class cMeshEntity : public iEntity3D
{
#ifdef __GNUC__
typedef iRenderable __super;
#endif
friend class cSubMeshEntity;
friend class cMeshEntityRootNodeUpdate;
friend class cMesh;
Expand Down
149 changes: 83 additions & 66 deletions HPL2/include/scene/SubMeshEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,109 +19,126 @@

#pragma once
#include <folly/small_vector.h>
#include <vector>
#include <map>
#include <vector>

#include "Common_3/Graphics/Interfaces/IGraphics.h"
#include "graphics/ForgeHandles.h"
#include "graphics/GraphicsAllocator.h"
#include "math/MathTypes.h"
#include "graphics/GraphicsTypes.h"
#include "system/SystemTypes.h"
#include "scene/Entity3D.h"
#include "graphics/Renderable.h"
#include "graphics/SubMesh.h"
#include "math/MathTypes.h"
#include "math/MeshTypes.h"
#include "scene/Entity3D.h"
#include "system/SystemTypes.h"

namespace hpl {

class cMaterialManager;
class cMeshManager;
class cMesh;
class cSubMesh;
class cMeshEntity;
class cAnimationState;
class cNodeState;
class cBone;
class cNode3D;
class iPhysicsBody;
class cMaterial;
class cBoneState;

class cSubMeshEntity final: public iRenderable
{
HPL_RTTI_IMPL_CLASS(iRenderable, cSubMeshEntity, "{285bbdb4-de5b-4960-bf44-ae543432ff40}")
friend class cMeshEntity;
public:
class cMaterialManager;
class cMeshManager;
class cMesh;
class cSubMesh;
class cMeshEntity;
class cAnimationState;
class cNodeState;
class cBone;
class cNode3D;
class iPhysicsBody;
class cMaterial;
class cBoneState;

class cSubMeshEntity final : public iRenderable {
HPL_RTTI_IMPL_CLASS(iRenderable, cSubMeshEntity, "{285bbdb4-de5b-4960-bf44-ae543432ff40}")
friend class cMeshEntity;

public:
static constexpr uint32_t MaxVertexBindings = 15;

cSubMeshEntity(const tString &asName,cMeshEntity *apMeshEntity, cSubMesh * apSubMesh,cMaterialManager* apMaterialManager);
~cSubMeshEntity();
cSubMeshEntity(const tString& asName, cMeshEntity* apMeshEntity, cSubMesh* apSubMesh, cMaterialManager* apMaterialManager);
~cSubMeshEntity();

virtual cMaterial *GetMaterial() override;
virtual cMaterial* GetMaterial() override;

virtual void UpdateGraphicsForFrame(float afFrameTime) override;
virtual void UpdateGraphicsForFrame(float afFrameTime) override;

virtual iVertexBuffer* GetVertexBuffer() override;
virtual iVertexBuffer* GetVertexBuffer() override;
virtual DrawPacket ResolveDrawPacket(const ForgeRenderer::Frame& frame) override;

virtual cBoundingVolume* GetBoundingVolume() override;
virtual cBoundingVolume* GetBoundingVolume() override;

virtual cMatrixf* GetModelMatrix(cFrustum* apFrustum) override;

virtual cMatrixf* GetModelMatrix(cFrustum *apFrustum) override;
virtual int GetMatrixUpdateCount() override;

virtual int GetMatrixUpdateCount() override;
virtual eRenderableType GetRenderType() override {
return eRenderableType_SubMesh;
}

virtual eRenderableType GetRenderType() override { return eRenderableType_SubMesh;}
cSubMesh* GetSubMesh() const {
return m_subMesh;
}

cSubMesh* GetSubMesh() const { return mpSubMesh;}
void SetLocalNode(cNode3D* apNode);
cNode3D* GetLocalNode();

void SetLocalNode(cNode3D *apNode);
cNode3D* GetLocalNode();
void* GetUserData() {
return mpUserData;
}
void SetUserData(void* apData) {
mpUserData = apData;
}

void* GetUserData(){ return mpUserData;}
void SetUserData(void *apData){ mpUserData = apData;}
// Entity implementation
virtual tString GetEntityType() override {
return "SubMesh";
}

//Entity implementation
virtual tString GetEntityType() override { return "SubMesh";}
virtual void UpdateLogic(float afTimeStep) override;

virtual void UpdateLogic(float afTimeStep) override;
void SetUpdateBody(bool abX);
bool GetUpdateBody();

void SetUpdateBody(bool abX);
bool GetUpdateBody();
void SetCustomMaterial(cMaterial* apMaterial, bool abDestroyOldCustom = true);
cMaterial* GetCustomMaterial() {
return mpMaterial;
}

void SetCustomMaterial(cMaterial *apMaterial, bool abDestroyOldCustom=true);
cMaterial* GetCustomMaterial(){ return mpMaterial;}
private:
bool isGeometryMismatch(cSubMesh* submesh);
void rebuildGpuVertexStreams();
void updateVertexStream(cSubMesh::StreamBufferInfo& stream);
void updateIndexStream(cSubMesh::IndexBufferInfo& stream);

private:
virtual void OnTransformUpdated() override;
virtual void OnTransformUpdated() override;
std::shared_ptr<GeometrySet::GeometrySetSubAllocation> m_geometry;
uint8_t m_activeCopy = 0;
uint32_t m_numberIndecies = 0;
uint32_t m_numberVertices = 0;

cSubMesh *mpSubMesh= nullptr;
cMeshEntity *mpMeshEntity= nullptr;

cMaterial *mpMaterial= nullptr;

cNode3D *mpLocalNode = nullptr;
cSubMesh* m_subMesh = nullptr;
cMeshEntity* mpMeshEntity = nullptr;
cMaterial* mpMaterial = nullptr;
cNode3D* mpLocalNode = nullptr;
cMaterialManager* mpMaterialManager = nullptr;

cMaterialManager* mpMaterialManager= nullptr;
cSubMesh::NotifySubMeshChanged::Handler m_subMeshChangeHandler;

bool mbUpdateBody = false;
bool mbGraphicsUpdated = false;
bool mbUpdateBody = false;
bool mbGraphicsUpdated = false;
bool m_isSkinnedMesh = false;

//This is used to see if null should be returned.
// 0 = no check made, test if matrix is identity
// -1 = Matrix was not identity
// 1 = matrix was identiy
char mlStaticNullMatrixCount = 0;
void *mpUserData;
};
// This is used to see if null should be returned.
// 0 = no check made, test if matrix is identity
// -1 = Matrix was not identity
// 1 = matrix was identiy
char mlStaticNullMatrixCount = 0;
void* mpUserData;
};

typedef std::vector<cSubMeshEntity*> tSubMeshEntityVec;
typedef std::vector<cSubMeshEntity*>::iterator tSubMeshEntityVecIt;
typedef std::vector<cSubMeshEntity*> tSubMeshEntityVec;
typedef std::vector<cSubMeshEntity*>::iterator tSubMeshEntityVecIt;

typedef std::multimap<tString,cSubMeshEntity*> tSubMeshEntityMap;
typedef tSubMeshEntityMap::iterator tSubMeshEntityMapIt;
};
typedef std::multimap<tString, cSubMeshEntity*> tSubMeshEntityMap;
typedef tSubMeshEntityMap::iterator tSubMeshEntityMapIt;
}; // namespace hpl
4 changes: 2 additions & 2 deletions HPL2/sources/graphics/GeometrySet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace hpl {

auto vertexStorageReport = m_vertexStreamAllocator.storageReport();
auto indexStorageReport = m_indexStreamAllocator.storageReport();
LOGF(LogLevel::eINFO, "vertex storage total free space: %d largest region: %d", vertexStorageReport.totalFreeSpace, vertexStorageReport.largestFreeRegion);
LOGF(LogLevel::eINFO, "index storage total free space: %d largest region: %d", indexStorageReport.totalFreeSpace, indexStorageReport.largestFreeRegion);
//LOGF(LogLevel::eDEBUG, "vertex storage total free space: %d largest region: %d", vertexStorageReport.totalFreeSpace, vertexStorageReport.largestFreeRegion);
//LOGF(LogLevel::eDEBUG, "index storage total free space: %d largest region: %d", indexStorageReport.totalFreeSpace, indexStorageReport.largestFreeRegion);

ASSERT(subAllocation->m_indexAllocation.offset != OffsetAllocator::Allocation::NO_SPACE);
ASSERT(subAllocation->m_indexAllocation.metadata != OffsetAllocator::Allocation::NO_SPACE);
Expand Down
18 changes: 0 additions & 18 deletions HPL2/sources/graphics/SubMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,24 +268,6 @@ namespace hpl {
return NULL;
}

// not an ideal solution
SharedBuffer cSubMesh::StreamBufferInfo::CommitSharedBuffer() {
if(!m_gpuBuffer.IsValid()) {
auto rawView = m_buffer.CreateViewRaw();
m_gpuBuffer.Load([&](Buffer** buffer) {
BufferLoadDesc loadDesc = {};
loadDesc.ppBuffer = buffer;
loadDesc.mDesc.mDescriptors = DESCRIPTOR_TYPE_VERTEX_BUFFER;
loadDesc.mDesc.mMemoryUsage = RESOURCE_MEMORY_USAGE_GPU_ONLY;
loadDesc.mDesc.mSize = rawView.NumBytes();
loadDesc.pData = rawView.rawByteSpan().data();
addResource(&loadDesc, nullptr);
return true;
});
}
return m_gpuBuffer;
}

iCollideShape* cSubMesh::CreateCollideShape(iPhysicsWorld* apWorld, std::span<MeshCollisionResource> colliders) {
if (colliders.empty()) {
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion HPL2/sources/impl/MeshLoaderMSH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

namespace hpl {

bool gbLogMSHLoad = false;
static constexpr bool gbLogMSHLoad = false;

cMeshLoaderMSH::cMeshLoaderMSH(iLowLevelGraphics *apLowLevelGraphics) : iMeshLoader(apLowLevelGraphics)
{
Expand Down
7 changes: 1 addition & 6 deletions HPL2/sources/scene/MeshEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@

namespace hpl {

//////////////////////////////////////////////////////////////////////////
// CONSTRUCTORS
//////////////////////////////////////////////////////////////////////////

//-----------------------------------------------------------------------

cMeshEntity::cMeshEntity(const tString asName,cMesh* apMesh, cMaterialManager* apMaterialManager,
cMeshManager* apMeshManager, cAnimationManager *apAnimationManager) :
Expand Down Expand Up @@ -456,7 +451,7 @@ namespace hpl {
while(BoneIt.HasNext())
{
cBoneState *pBoneState = static_cast<cBoneState*>(BoneIt.Next());

SetBoneMatrixFromBodyRec(mpBoneStateRoot->GetWorldMatrix(),pBoneState);
}

Expand Down
Loading

0 comments on commit b6690b2

Please sign in to comment.