Commit f5bb8a6e authored by D-AIRY's avatar D-AIRY

Очистка декалей при выгрузке уровня

Возможность передачи NULL в качестве первого аргумента SMMatrixInverse
Приседание игрока
Некоторые распараллеливания для ускорения обработки
Исправлен баг с разбрызгиванием крови от неживых игровых объектов
Множественные доработки многопоточности
Удаленные entity теперь не отображаются в списке в редакторе
Сдвигающиеся двери
parent 86fe5f9b
......@@ -120,7 +120,10 @@
<ClCompile Include="..\..\..\source\game\NPCBase.cpp" />
<ClCompile Include="..\..\..\source\game\NPCZombie.cpp" />
<ClCompile Include="..\..\..\source\game\PathCorner.cpp" />
<ClCompile Include="..\..\..\source\game\PropBreakable.cpp" />
<ClCompile Include="..\..\..\source\game\PropButton.cpp" />
<ClCompile Include="..\..\..\source\game\PropDebris.cpp" />
<ClCompile Include="..\..\..\source\game\PropDoor.cpp" />
<ClCompile Include="..\..\..\source\game\PropDynamic.cpp" />
<ClCompile Include="..\..\..\source\game\proptable.cpp" />
<ClCompile Include="..\..\..\source\game\Ragdoll.cpp" />
......@@ -159,7 +162,10 @@
<ClInclude Include="..\..\..\source\game\HUDcontroller.h" />
<ClInclude Include="..\..\..\source\game\IGameState.h" />
<ClInclude Include="..\..\..\source\game\LogicRelay.h" />
<ClInclude Include="..\..\..\source\game\PropBreakable.h" />
<ClInclude Include="..\..\..\source\game\PropButton.h" />
<ClInclude Include="..\..\..\source\game\PropDebris.h" />
<ClInclude Include="..\..\..\source\game\PropDoor.h" />
<ClInclude Include="..\..\..\source\game\PropDynamic.h" />
<ClInclude Include="..\..\..\source\game\Random.h" />
<ClInclude Include="..\..\..\source\game\crosshair.h" />
......
......@@ -216,6 +216,15 @@
<ClCompile Include="..\..\..\source\game\PropDynamic.cpp">
<Filter>Source Files\ents\props</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\game\PropBreakable.cpp">
<Filter>Source Files\ents\props</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\game\PropDebris.cpp">
<Filter>Source Files\ents\props</Filter>
</ClCompile>
<ClCompile Include="..\..\..\source\game\PropDoor.cpp">
<Filter>Source Files\ents\props</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\source\game\sxgame.h">
......@@ -374,5 +383,14 @@
<ClInclude Include="..\..\..\source\game\PropDynamic.h">
<Filter>Header Files\ents\props</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\game\PropBreakable.h">
<Filter>Header Files\ents\props</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\game\PropDebris.h">
<Filter>Header Files\ents\props</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\game\PropDoor.h">
<Filter>Header Files\ents\props</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
bullet3 @ f92f8598
Subproject commit bfe26aafbe2ce7d3800bb30381674c7e6aea8ef0
Subproject commit f92f8598107fa917cf8613fecfb79789f85e7fac
......@@ -142,7 +142,7 @@ void ModelFile::Load(const char * name)
{
fread(m_iMaterials[j][i].szName, 1, MODEL_MAX_NAME, fp);
m_iMaterials[j][i].iMat = m_pMgr->getMaterial(m_iMaterials[j][i].szName); //3
m_iMaterials[j][i].iMat = m_pMgr->getMaterial(m_iMaterials[j][i].szName, m_hdr.iFlags & MODEL_FLAG_STATIC); //3
}
}
......@@ -1060,6 +1060,8 @@ Animation::Animation(AnimationManager * pMgr):
m_pIsBoneWorld[i] = NULL;
}
m_pBoundBox = SGCore_CrBound();
myId = pMgr->reg(this);
}
......@@ -1076,6 +1078,7 @@ Animation::~Animation()
mem_delete_a(m_FinalBones);
mem_delete_a(m_pBoneMatrixRender);
m_pMgr->unreg(myId);
mem_release(m_pBoundBox);
if(!m_isMdlManaged)
{
......@@ -1970,7 +1973,17 @@ UINT Animation::GetPartCount()
const ISXBound * Animation::getBound() const
{
return(m_pMdl->getBound());
const ISXBound *pBound = m_pMdl->getBound();
//if(m_fScale == 1.0f)
{
return(pBound);
}
float3 vCenter, vMax;
pBound->getSphere(&vCenter, NULL);
pBound->getMinMax(NULL, &vMax);
float3 vDelta = (vMax - vCenter) * m_fScale;
m_pBoundBox->setMinMax(&((float3)(vCenter - vDelta)), &((float3)(vCenter + vDelta)));
return(m_pBoundBox);
}
void Animation::assembly()
......@@ -2340,6 +2353,10 @@ void Animation::freePhysData(
}
}
bool Animation::isVisibleFor(ID id)
{
return(m_vIsVisibleFor[id]);
}
/**
*
......
......@@ -230,6 +230,8 @@ public:
virtual void setRagdoll(IAnimRagdoll * pRagdoll);
virtual bool isVisibleFor(ID id);
//static void AssemblyMdl(ModelFile * pOut, const Array<ModelPart*> & mMdls);
protected:
......@@ -315,6 +317,7 @@ protected:
bool m_isMdlManaged;
private:
ISXBound * m_pBoundBox;
void AppendMesh(ModelLoDSubset * to, ModelLoDSubset * from, Array<int> & bone_relink, bool isStatic=false);
};
......
......@@ -27,6 +27,8 @@ See the license in LICENSE
#define SX_DLL
#endif
#define SX_ANIM_DEFAULT_VISCALCOBJ 0
#include <gdefines.h>
#undef SX_LIB_API
......@@ -292,6 +294,8 @@ public:
virtual void enable(bool enable) = 0;
virtual void setRagdoll(IAnimRagdoll * pRagdoll) = 0;
virtual bool isVisibleFor(ID id) = 0;
};
//! \name Функции управления анимацией
......
common @ 3906bd53
Subproject commit a4dc88ffd0720991c2689b7b4209b96ee0e2c33e
Subproject commit 3906bd53a1ae5cd132120ef680fd16c106b6fa7e
......@@ -282,7 +282,7 @@ SX_LIB_API void Core_MWaitFor(ID id)
SX_LIB_API int Core_MGetThreadCount()
{
SXCORE_PRECOND(1);
g_pTaskManager->getThreadCount();
return(g_pTaskManager->getThreadCount());
}
//##########################################################################
......
......@@ -179,6 +179,8 @@ enum PERF_SECTION
PERF_SECTION_VIS_PARTICLES, // R
PERF_SECTION_AI_PATH, // S
PERF_SECTION_CVAR_UPDATE, // T
PERF_SECTION_COUNT
};
static const char *g_szPerfSectionName[] = {
......@@ -427,7 +429,7 @@ struct ISXConfig : public IBaseObject
SX_LIB_API ISXConfig* Core_CrConfig();
//! открыть файл конфигов
SX_LIB_API ISXConfig* Core_OpConfig(const char* path);
SX_LIB_API ISXConfig* Core_OpConfig(const char* path);
//!@}
......
......@@ -93,7 +93,8 @@ DecalManager::DecalManager():
DecalManager::~DecalManager()
{
clear();
mem_release(m_pVertexBuffer);
}
int DecalManager::addDecal(Decal * pDecal)
......@@ -171,6 +172,22 @@ void DecalManager::removeDecal(UINT iDecal)
//printf("removeDecal(); end; c = %d\n", m_vDecals.size());
}
void DecalManager::clear()
{
for(AssotiativeArray<ID, Array<_DecalMatItem>>::Iterator i = m_MaterialSort.begin(); i; i++)
{
for(int j = 0, lj = i.second->size(); j < lj; ++j)
{
mem_delete_a(i.second[0][j].m_pDecal->m_pVerts);
}
}
m_aDecals.clear();
m_vDecals.clearFast();
m_MaterialSort.clear();
m_bNeedUpdate = true;
}
bool DecalManager::inside(const float3_t * p, char axis, float coord)
{
switch(axis)
......@@ -638,15 +655,11 @@ void DecalManager::updateBuffer()
}
if(m_pVertexBuffer)
{
m_pVertexBuffer->Release();
m_pVertexBuffer = NULL;
}
mem_release(m_pVertexBuffer);
if(iVC == 0)
{
m_bNeedUpdate = false;
return;
}
......
......@@ -134,6 +134,8 @@ public:
void render();
void clear();
void update();
void sync();
......
......@@ -83,6 +83,10 @@ SX_LIB_API void SXDecals_Render();
SX_LIB_API void SXDecals_ShootDecal(DECAL_TYPE type, const float3 & fWorldPos, const float3 & normal);
SX_LIB_API void SXDecals_ShootDecalEx(DECAL_TYPE type, const float3 & fWorldPos, const float3 & normal, int flags, ID material = -1, float fScale = 1.0f, const float3 * saxis = NULL);
/*! Удаляет все декали
*/
SX_LIB_API void SXDecals_Clear();
#endif
......
......@@ -103,3 +103,9 @@ SX_LIB_API void SXDecals_ShootDecalEx(DECAL_TYPE type, const float3 & fWorldPos,
SP_PRECOND(_VOID);
g_pMgr->shootDecal(type, fWorldPos, material, 0, saxis, fScale, flags, &normal);
}
SX_LIB_API void SXDecals_Clear()
{
SP_PRECOND(_VOID);
g_pMgr->clear();
}
......@@ -207,9 +207,10 @@ void CBaseAmmo::fire(const float3 &_vStart, const float3 &_vDir, CBaseCharacter
CTakeDamageInfo takeDamageInfo(pAttacker, fEnergyDelta);
takeDamageInfo.m_pInflictor = getParent();
isBloody = true;
CBaseEntity *pEnt = ((CBaseEntity*)aHitPoints[i].pCollisionObject->getUserPointer());
isBloody = pEnt->isBloody();
((CBaseEntity*)aHitPoints[i].pCollisionObject->getUserPointer())->dispatchDamage(takeDamageInfo);
pEnt->dispatchDamage(takeDamageInfo);
}
......
......@@ -44,7 +44,8 @@ CBaseAnimating::CBaseAnimating(CEntityManager * pMgr):
m_fBaseScale(1.0f),
m_pCollideShape(NULL),
m_pRigidBody(NULL),
m_isStatic(false)
m_isStatic(false),
m_collisionGroup(CG_DEFAULT)
{
memset(m_vNextAnim, 0, sizeof(m_vNextAnim));
}
......@@ -114,6 +115,7 @@ void CBaseAnimating::setModel(const char * mdl)
m_pAnimPlayer->setModel(mdl);
}
m_pAnimPlayer->setSkin(m_iSkin);
m_pAnimPlayer->setScale(m_fBaseScale);
initPhysics();
}
......@@ -235,7 +237,7 @@ void CBaseAnimating::createPhysBody()
//m_pRigidBody->setFriction(100.0f);
m_pRigidBody->setUserPointer(this);
SXPhysics_AddShape(m_pRigidBody);
SXPhysics_AddShapeEx(m_pRigidBody, m_collisionGroup, CG_ALL);
if(m_isStatic)
{
......@@ -257,6 +259,24 @@ void CBaseAnimating::releasePhysics()
mem_delete(m_pCollideShape);
}
void CBaseAnimating::setCollisionGroup(COLLISION_GROUP group)
{
if(m_collisionGroup == group)
{
return;
}
m_collisionGroup = group;
if(m_pRigidBody)
{
SXPhysics_RemoveShape(m_pRigidBody);
SXPhysics_AddShapeEx(m_pRigidBody, m_collisionGroup, CG_ALL);
}
}
COLLISION_GROUP CBaseAnimating::getCollisionGroup(COLLISION_GROUP)
{
return(m_collisionGroup);
}
void CBaseAnimating::setPos(const float3 & pos)
{
BaseClass::setPos(pos);
......
......@@ -54,8 +54,10 @@ public:
void setOrient(const SMQuaternion & q);
void setSkin(int iSkin);
void setCollisionGroup(COLLISION_GROUP group);
COLLISION_GROUP getCollisionGroup(COLLISION_GROUP);
protected:
void inputPlayAnim(inputdata_t * pInputdata);
......@@ -72,8 +74,8 @@ protected:
bool m_isStatic;
virtual void initPhysics();
virtual void createPhysBody();
virtual void releasePhysics();
virtual void createPhysBody();
virtual void removePhysBody();
btCollisionShape * m_pCollideShape;
......@@ -93,6 +95,9 @@ protected:
UINT uFadeTime;
bool isActivity;
} m_vNextAnim[BLEND_MAX];
private:
COLLISION_GROUP m_collisionGroup;
};
#endif
......
......@@ -52,14 +52,23 @@ CBaseCharacter::CBaseCharacter(CEntityManager * pMgr):
m_pActiveTool(NULL),
m_fCurrentSpread(0.0f),
m_pHitboxBodies(NULL),
m_fCapsHeight(1.7f),
m_fCapsHeight(1.8f),
m_fCapsHeightCrouch(1.2f),
m_fCapsRadius(0.4f),
m_idQuadLast(-1)
m_idQuadLast(-1),
m_fCurrentHeight(1.0f)
{
m_pCollideShape = new btCapsuleShape(m_fCapsRadius, m_fCapsHeight - m_fCapsRadius * 2.0f);
btTransform startTransform;
startTransform.setIdentity();
//((btCompoundShape*)m_pCollideShape)->addChildShape(startTransform, m_pCollideShapeBottom);
//startTransform.setOrigin(btVector3(0.0f, m_fCapsHeight * 0.5f, 0.0f));
//((btCompoundShape*)m_pCollideShape)->addChildShape(startTransform, m_pCollideShapeTop);
//btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(F3_BTVEC(m_vPosition + float3(0.0f, m_fCapsHeight * 0.5f, 0.0f)));
//startTransform.setOrigin(btVector3(0, 12, 10));
......@@ -87,6 +96,7 @@ CBaseCharacter::CBaseCharacter(CEntityManager * pMgr):
//m_pCharacter->setGravity(1.0f);
m_pCharacter->setFallSpeed(300.0f);
//m_pCharacter->setFallSpeed(30.0f);
m_pCharacter->setMaxPenetrationDepth(0.1f);
SXPhysics_GetDynWorld()->addCollisionObject(m_pGhostObject, CG_CHARACTER, CG_ALL & ~(CG_DEBRIS | CG_HITBOX | CG_WATER));
......@@ -119,6 +129,10 @@ CBaseCharacter::~CBaseCharacter()
REMOVE_ENTITY(m_flashlight);
mem_delete(m_pInventory);
mem_delete(m_pCharacter);
mem_delete(m_pGhostObject);
mem_delete(m_pCollideShape);
if(m_idQuadCurr >= 0)
{
//SAIG_QuadSetState(m_idQuadCurr, AIQUAD_STATE_FREE);
......@@ -207,7 +221,7 @@ void CBaseCharacter::playFootstepsSound()
void CBaseCharacter::setPos(const float3 & pos)
{
BaseClass::setPos(pos);
m_pGhostObject->getWorldTransform().setOrigin(F3_BTVEC(pos + float3(0.0f, m_fCapsHeight * 0.5f, 0.0f)));
m_pGhostObject->getWorldTransform().setOrigin(F3_BTVEC(pos + float3(0.0f, (m_fCurrentHeight * m_fCapsHeight) * 0.5f, 0.0f)));
}
float CBaseCharacter::getAimRange()
......@@ -414,8 +428,11 @@ void CBaseCharacter::onSync()
return;
}
btTransform &trans = m_pGhostObject->getWorldTransform();
m_vPosition = (float3)(float3(trans.getOrigin().x(), trans.getOrigin().y() - m_fCapsHeight * 0.5f, trans.getOrigin().z()));
m_vPosition = (float3)(float3(trans.getOrigin().x(), trans.getOrigin().y() - m_fCapsHeight * m_fCurrentHeight * 0.5f, trans.getOrigin().z()));
float3 vHeadOffset = m_pHeadEnt->getOffsetPos();
vHeadOffset.y = m_fCapsHeight * m_fCurrentHeight - 0.1f;
m_pHeadEnt->setOffsetPos(vHeadOffset);
//находим текущий квад аи сетки на котором находится игрок
......@@ -457,7 +474,7 @@ CHUDcontroller * CBaseCharacter::getHUDcontroller()
return(NULL);
}
void CBaseCharacter::onDeath()
void CBaseCharacter::onDeath(CBaseEntity *pAttacker, CBaseEntity *pInflictor)
{
if(m_idQuadCurr >= 0)
{
......@@ -470,7 +487,7 @@ void CBaseCharacter::onDeath()
cancelNextAnimation();
BaseClass::onDeath();
BaseClass::onDeath(pAttacker, pInflictor);
}
/*void CBaseCharacter::dispatchDamage(CTakeDamageInfo &takeDamageInfo)
......
/***********************************************************
Copyright Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
/*!
\file
Базовый класс персонажа
*/
/*! \ingroup cbaseanimating
......@@ -23,26 +23,26 @@ See the license in LICENSE
class CBaseTool;
//!
//! Типы движения игрока
enum PLAYER_MOVE
{
PM_NONE = 0,
PM_FORWARD = 0x01, //!<
PM_BACKWARD = 0x02, //!<
PM_LEFT = 0x04, //!<
PM_RIGHT = 0x08, //!<
PM_CROUCH = 0x10, //!<
PM_JUMP = 0x20, //!<
PM_RUN = 0x40, //!<
PM_CRAWL = 0x80, //!<
PM_OBSERVER = 0x100, //!<
PM_FORWARD = 0x01, //!< вперед
PM_BACKWARD = 0x02, //!< назад
PM_LEFT = 0x04, //!< влево
PM_RIGHT = 0x08, //!< вправо
PM_CROUCH = 0x10, //!< присесть
PM_JUMP = 0x20, //!< прыгнуть
PM_RUN = 0x40, //!< бежать
PM_CRAWL = 0x80, //!< лежать
PM_OBSERVER = 0x100, //!< наблюдатель
PM_STOP = 0xFFFF
};
class CHUDcontroller;
//! \ingroup cbaseanimating
//! Класс игрока \ingroup cbaseanimating
class CBaseCharacter: public CBaseAnimating
{
DECLARE_CLASS(CBaseCharacter, CBaseAnimating);
......@@ -51,27 +51,27 @@ public:
CBaseCharacter(CEntityManager * pMgr);
~CBaseCharacter();
//! /
//! Запускает/останавливает первичную атаку
void attack(BOOL state);
//! /
//! Запускает/останавливает вторичную атаку
void attack2(BOOL state);
//!
//! Запускает перезарядку активного оружия
void reload();
//! /
//! Включает/выключает фонарь
void toggleFlashlight();
//!
//! Переключает режим стрельбы активного оружия
void nextFireMode();
//!
//! Находится ли игрок на земле
bool onGround();
//!
//! Воспроизводит звук шагов с учетом материала на котором стоит игрок
void playFootstepsSound();
float getAimRange();
//! ( )
//! Получает рассчитанный для текущего оружия коэффициент разброса (с учетом задержки сведения)
float getCurrentSpread();
btCollisionObject *getBtCollisionObject() const
......@@ -87,7 +87,7 @@ public:
void initPhysics();
void releasePhysics();
//!
//! Устанавливает положение в мире
void setPos(const float3 & pos);
//void dispatchDamage(CTakeDamageInfo &takeDamageInfo);
......@@ -99,26 +99,30 @@ public:
virtual CHUDcontroller * getHUDcontroller();
void onDeath();
void onDeath(CBaseEntity *pAttacker, CBaseEntity *pInflictor);
CBaseEntity *getHead();
virtual bool isBloody()
{
return(true);
}
bool isObserver();
void use(bool start);
protected:
//!
//! Фонарик
CLightDirectional* m_flashlight;
//!
//! Текущее движение
UINT m_uMoveDir;
//!
//! Текущий инструмент в руках
CBaseTool * m_pActiveTool;
//! @{
//! Для физики @{
btCollisionShape * m_pCollideShape;
btRigidBody * m_pRigidBody;
btPairCachingGhostObject * m_pGhostObject;
......@@ -126,30 +130,33 @@ protected:
btRigidBody ** m_pHitboxBodies;
//! @}
//!
//! Углы вращения игрока
float3_t m_vPitchYawRoll;
//!
//! Мгновенное значение коэффициента разброса
float getMomentSpread();
//!
//! Задача обновления разброса
ID m_idTaskSpread;
//!
//! Обновляет разброса значение
virtual void updateSpread(float dt);
//!
//! Действующее значение разброса
float m_fCurrentSpread;
CCharacterInventory * m_pInventory;
ID m_idQuadCurr; //!<
ID m_idQuadLast; //!<
ID m_idQuadCurr; //!< текущий квад аи сетки на котором стоит игрок
ID m_idQuadLast; //!< Последний валидный квад аи сетки на котором стоял игрок
float m_fCapsHeight;
float m_fCapsHeightCrouch;
float m_fCapsRadius;
CPointEntity * m_pHeadEnt;
float m_fCurrentHeight;
};
#endif
......
......@@ -170,6 +170,11 @@ void CBaseEntity::setOffsetPos(const float3 & pos)
m_vOffsetPos = pos;
}
float3 CBaseEntity::getOffsetPos()
{
return(m_vOffsetPos);
}
SMQuaternion CBaseEntity::getOrient()
{
return(m_vOrientation);
......@@ -726,10 +731,10 @@ void CBaseEntity::dispatchDamage(CTakeDamageInfo &takeDamageInfo)
{
LibReport(REPORT_MSG_LEVEL_NOTICE, "%s damaged (" COLOR_LRED "%.2f" COLOR_RESET ")\n", getClassName(), fHealth);
}
takeHealth(fHealth);
takeHealth(fHealth, takeDamageInfo.m_pAttacker, takeDamageInfo.m_pInflictor);
}
void CBaseEntity::takeHealth(float fVal)
void CBaseEntity::takeHealth(float fVal, CBaseEntity *pAttacker, CBaseEntity *pInflictor)
{
if(m_fHealth <= 0.0f)
{
......@@ -738,11 +743,15 @@ void CBaseEntity::takeHealth(float fVal)
m_fHealth -= fVal;
if(m_fHealth <= 0.0f)
{
onDeath();
if(<