Skip to content

Fix cylinder marker has a 2D colshape instead of 3D and Fix collision radius not matching visual #3436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientColTube.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class CClientColTube final : public CClientColShape
m_fHeight = fHeight;
SizeChanged();
};
float AdjustSize(float fSize);

protected:
float m_fRadius;
Expand Down
16 changes: 15 additions & 1 deletion Client/mods/deathmatch/logic/CClientMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ float CClientMarker::GetSize() const
return m_pMarker->GetSize();
}

float CClientColTube::AdjustSize(float fSize)
{
return (fSize / 2.0f) + 0.15f;
}

void CClientMarker::SetSize(float fSize)
{
switch (m_pCollision->GetShapeType())
Expand All @@ -314,7 +319,15 @@ void CClientMarker::SetSize(float fSize)
pShape->SetRadius(fSize);
break;
}
case COLSHAPE_TUBE:
{
CClientColTube* pShape = static_cast<CClientColTube*>(m_pCollision);
pShape->SetRadius(pShape->AdjustSize(fSize));
pShape->SetHeight(fSize);
break;
}
}

m_pMarker->SetSize(fSize);
}

Expand Down Expand Up @@ -469,7 +482,8 @@ void CClientMarker::CreateOfType(int iType)
CClient3DMarker* p3DMarker = new CClient3DMarker(this);
p3DMarker->Set3DMarkerType(CClient3DMarker::TYPE_CYLINDER);
m_pMarker = p3DMarker;
m_pCollision = new CClientColCircle(g_pClientGame->GetManager(), INVALID_ELEMENT_ID, vecOrigin, GetSize());

m_pCollision = new CClientColTube(g_pClientGame->GetManager(), INVALID_ELEMENT_ID, vecOrigin, GetSize(), GetSize());
m_pCollision->m_pOwningMarker = this;
m_pCollision->SetHitCallback(this);
break;
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CColTube.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CColTube : public CColShape
m_fHeight = fHeight;
SizeChanged();
};
float AdjustSize(float fSize);

protected:
bool ReadSpecialData(const int iLine) override;
Expand Down
24 changes: 20 additions & 4 deletions Server/mods/deathmatch/logic/CMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "CMarkerManager.h"
#include "CColCircle.h"
#include "CColSphere.h"
#include "CColTube.h"
#include "CResource.h"
#include "CLogger.h"
#include "Utils.h"
Expand Down Expand Up @@ -383,6 +384,11 @@ void CMarker::Callback_OnCollisionDestroy(CColShape* pCollision)
m_pCollision = NULL;
}

float CColTube::AdjustSize(float fSize)
{
return (fSize / 2.0f) + 0.15f;
}

void CMarker::UpdateCollisionObject(unsigned char ucOldType)
{
// Different type than before?
Expand All @@ -395,15 +401,19 @@ void CMarker::UpdateCollisionObject(unsigned char ucOldType)
{
if (m_pCollision)
g_pGame->GetElementDeleter()->Delete(m_pCollision);

m_pCollision = new CColCircle(m_pColManager, nullptr, m_vecPosition, m_fSize, true);
m_pCollision = new CColCircle(m_pColManager, nullptr, m_vecPosition, m_fSize, true);
}
else if (m_ucType == CMarker::TYPE_CYLINDER)
{
if (m_pCollision)
g_pGame->GetElementDeleter()->Delete(m_pCollision);
m_pCollision = new CColTube(m_pColManager, nullptr, m_vecPosition, m_fSize, m_fSize);
}
else if (ucOldType == CMarker::TYPE_CHECKPOINT)
{
if (m_pCollision)
g_pGame->GetElementDeleter()->Delete(m_pCollision);

m_pCollision = new CColSphere(m_pColManager, nullptr, m_vecPosition, m_fSize, true);
m_pCollision = new CColSphere(m_pColManager, nullptr, m_vecPosition, m_fSize, true);
}

m_pCollision->SetCallback(this);
Expand All @@ -416,6 +426,12 @@ void CMarker::UpdateCollisionObject(unsigned char ucOldType)
{
static_cast<CColCircle*>(m_pCollision)->SetRadius(m_fSize);
}
else if (m_ucType == CMarker::TYPE_CYLINDER)
{
CColTube* pShape = static_cast<CColTube*>(m_pCollision);
pShape->SetRadius(pShape->AdjustSize(m_fSize));
pShape->SetHeight(m_fSize);
}
else
{
static_cast<CColSphere*>(m_pCollision)->SetRadius(m_fSize);
Expand Down
Loading