Skip to content

Commit

Permalink
feat: fix broken editor planes (#120)
Browse files Browse the repository at this point in the history
* feat: fix broken editor planes

Signed-off-by: Michael Pollind <[email protected]>

* copy in il library for linux and fix build for windows

Signed-off-by: Michael Pollind <[email protected]>

* feat: tweak

Signed-off-by: Michael Pollind <[email protected]>

* feat: fix viewport for window editor

Signed-off-by: Michael Pollind <[email protected]>

* feat: build yml

Signed-off-by: Michael Pollind <[email protected]>

---------

Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend authored Jun 13, 2024
1 parent a1621ae commit 22d96ef
Show file tree
Hide file tree
Showing 21 changed files with 362 additions and 357 deletions.
23 changes: 8 additions & 15 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 All @@ -53,17 +50,13 @@ jobs:
uses: microsoft/[email protected]
- name: Configure
run: |
mkdir ${{ github.workspace }}\build && cd ${{ github.workspace }}\build
cmake ${{ github.workspace }} -DVCPKG_INSTALL_OPTIONS="--binarysource=clear\;x-gha,readwrite" -DCMAKE_BUILD_TYPE:STRING=Release -DAMNESIA_GAME_DIRECTORY:STRING='' -G "Visual Studio 17 2022" -A x64
- name: Build
run: |
cd ${{ github.workspace }}\build
cd ${{ github.workspace }}
msbuild ALL_BUILD.vcxproj /property:Configuration=Release
- name: Package Amnesia
working-directory: .\build
run: 7z a ..\amnesia-win-x86-64-release.zip *
- name: Upload Amnesia artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: amnesia-win-x86-64-release
path: amnesia-win-x86-64-release.zip
name: amnesia-win32-x86-64-release
path: build
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
Loading

0 comments on commit 22d96ef

Please sign in to comment.