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

Changed file field config; physics bugfixes

parent ae9bc7d6
bullet3 @ 0d4f8a91
Subproject commit f92f8598107fa917cf8613fecfb79789f85e7fac
Subproject commit 0d4f8a915cd92ffd82a495dd02084896dc4b05b6
......@@ -221,7 +221,6 @@ void CBaseAnimating::createPhysBody()
{
if(m_pCollideShape)
{
btVector3 vInertia;
const float fMass = 1.0f;
m_pCollideShape->calculateLocalInertia(fMass, vInertia);
......@@ -234,10 +233,18 @@ void CBaseAnimating::createPhysBody()
vInertia // local inertia
);
m_pRigidBody = new btRigidBody(rigidBodyCI);
m_pRigidBody->getInvMass();
//m_pRigidBody->setFriction(100.0f);
m_pRigidBody->setUserPointer(this);
SXPhysics_AddShapeEx(m_pRigidBody, m_collisionGroup, CG_ALL);
int colGroup = m_collisionGroup;
int colMask = m_collisionMask;
if(m_isStatic)
{
colGroup = CG_STATIC;
colMask = CG_STATIC_MASK;
}
SXPhysics_AddShapeEx(m_pRigidBody, colGroup, colMask);
if(m_isStatic)
{
......@@ -259,20 +266,21 @@ void CBaseAnimating::releasePhysics()
mem_delete(m_pCollideShape);
}
void CBaseAnimating::setCollisionGroup(COLLISION_GROUP group)
void CBaseAnimating::setCollisionGroup(COLLISION_GROUP group, COLLISION_GROUP mask)
{
if(m_collisionGroup == group)
if(m_collisionGroup == group && m_collisionMask == mask)
{
return;
}
m_collisionGroup = group;
m_collisionMask = mask;
if(m_pRigidBody)
{
SXPhysics_RemoveShape(m_pRigidBody);
SXPhysics_AddShapeEx(m_pRigidBody, m_collisionGroup, CG_ALL);
SXPhysics_AddShapeEx(m_pRigidBody, m_collisionGroup, m_collisionMask);
}
}
COLLISION_GROUP CBaseAnimating::getCollisionGroup(COLLISION_GROUP)
COLLISION_GROUP CBaseAnimating::getCollisionGroup()
{
return(m_collisionGroup);
}
......@@ -364,11 +372,17 @@ void CBaseAnimating::onIsStaticChange(bool isStatic)
{
m_pRigidBody->setLinearFactor(btVector3(0.0f, 0.0f, 0.0f));
m_pRigidBody->setAngularFactor(btVector3(0.0f, 0.0f, 0.0f));
SXPhysics_RemoveShape(m_pRigidBody);
SXPhysics_AddShapeEx(m_pRigidBody, CG_STATIC, CG_STATIC_MASK);
}
else
{
m_pRigidBody->setLinearFactor(btVector3(1.0f, 1.0f, 1.0f));
m_pRigidBody->setAngularFactor(btVector3(1.0f, 1.0f, 1.0f));
SXPhysics_RemoveShape(m_pRigidBody);
SXPhysics_AddShapeEx(m_pRigidBody, m_collisionGroup, m_collisionMask);
}
}
m_isStatic = isStatic;
......
......@@ -55,8 +55,8 @@ public:
void setSkin(int iSkin);
void setCollisionGroup(COLLISION_GROUP group);
COLLISION_GROUP getCollisionGroup(COLLISION_GROUP);
void setCollisionGroup(COLLISION_GROUP group, COLLISION_GROUP mask = CG_ALL);
COLLISION_GROUP getCollisionGroup();
protected:
......@@ -98,6 +98,7 @@ protected:
private:
COLLISION_GROUP m_collisionGroup;
COLLISION_GROUP m_collisionMask = CG_ALL;
};
#endif
......
......@@ -224,8 +224,9 @@ GameData::GameData(HWND hWnd, bool isGame):
SLevel_Load(argv[1], true);
GameData::m_pGameStateManager->activate("ingame");
//GameData::m_pGameStateManager->activate("ingame");
Core_0ConsoleExecCmd("gmode ingame");
Core_0ConsoleExecCmd("spawn");
for(int i = 0; i < 0; ++i)
......@@ -236,6 +237,17 @@ GameData::GameData(HWND hWnd, bool isGame):
}
});
Core_0RegisterConcmdArg("gmode", [](int argc, const char ** argv)
{
if(argc != 2)
{
printf("Usage: gmode <mode>");
return;
}
GameData::m_pGameStateManager->activate(argv[1]);
});
Core_0RegisterConcmd("game_menu", ccmd_game_menu);
Core_0RegisterConcmd("spawn", ccmd_spawn);
......
/***********************************************************
Copyright Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017, 2018
See the license in LICENSE
***********************************************************/
#include "PropDoor.h"
/*! \skydocent prop_door
Дверь
*/
BEGIN_PROPTABLE(CPropDoor)
//!
//! Открыть
DEFINE_INPUT(inputOpen, "open", "Open", PDF_NONE)
//!
//! Закрыть
DEFINE_INPUT(inputClose, "close", "Close", PDF_NONE)
//!
//! Заблокировать
DEFINE_INPUT(inputLock, "lock", "Lock", PDF_NONE)
//!
//! Разблокировать
DEFINE_INPUT(inputUnlock, "unlock", "Unlock", PDF_NONE)
//!
//! Переключить
DEFINE_INPUT(inputToggle, "toggle", "Toggle", PDF_NONE)
//!
//! При начале закрытия
DEFINE_OUTPUT(m_onClose, "OnClose", "On close")
//!
//! При завершении закрытия
DEFINE_OUTPUT(m_onClosed, "OnClosed", "On closed")
//!
//! При начале открытия
DEFINE_OUTPUT(m_onOpen, "OnOpen", "On open")
//!
//! При завершении открытия
DEFINE_OUTPUT(m_onOpened, "OnOpened", "On opened")
//!
//! При попытке использовать заблокированную
DEFINE_OUTPUT(m_onUseLocked, "OnUseLocked", "On use locked")
//!
//! Время до автозакрытия
DEFINE_FIELD_FLOAT(m_fAutoCloseTime, PDFF_NONE, "autoclose_time", "Autoclose time", EDITOR_TIMEFIELD)
//!
//! Повреждение при блокировке
DEFINE_FIELD_FLOAT(m_fBlockDamage, PDFF_NONE, "block_damage", "Block damage", EDITOR_TEXTFIELD)
//! (0-)
//! Величина смещение (0-авто)
DEFINE_FIELD_FLOAT(m_fDistanceOverride, PDFF_NONE, "distance_override", "Distance override", EDITOR_TEXTFIELD)
//! , /
//! Скорость, м/с
DEFINE_FIELD_FLOAT(m_fSpeed, PDFF_NONE, "speed", "Speed", EDITOR_TEXTFIELD)
//!
//! Направление открытия
DEFINE_FIELD_ANGLES(m_qAngle, PDFF_NONE, "open_angle", "Open angle", EDITOR_ANGLES)
DEFINE_FIELD_STRING(m_szSndClose, PDFF_NONE, "snd_close", "Close sound", EDITOR_FILEFIELD)
FILE_OPTION("Sound (*.ogg)", "*.ogg")
FILE_OPTION("Select sound", "ogg")
EDITOR_FILE_END()
DEFINE_FIELD_STRING(m_szSndOpen, PDFF_NONE, "snd_open", "Open sound", EDITOR_FILEFIELD)
FILE_OPTION("Sound (*.ogg)", "*.ogg")
FILE_OPTION("Select sound", "ogg")
EDITOR_FILE_END()
DEFINE_FIELD_STRING(m_szSndLocked, PDFF_NONE, "snd_locked", "Locked sound", EDITOR_FILEFIELD)
FILE_OPTION("Sound (*.ogg)", "*.ogg")
FILE_OPTION("Select sound", "ogg")
EDITOR_FILE_END()
//!
//! Изначально заблокирована
DEFINE_FLAG(DOOR_START_LOCKED, "Start locked")
//!
//! Запрет открытия игроком
DEFINE_FLAG(DOOR_NO_USE, "Disable player USE")
//!
//! Изначально открыта
DEFINE_FLAG(DOOR_START_OPENED, "Start opened")
//!
//! Автозакрытие по таймеру
DEFINE_FLAG(DOOR_AUTOCLOSE, "Autoclose")
//!
//! Форсированное закрытие двери
DEFINE_FLAG(DOOR_FORCE, "Force close")
END_PROPTABLE()
......@@ -313,7 +313,16 @@ void CPropDoor::think(float fDT)
stop();
}
}
setPos(SMVectorLerp(m_vStartPos, m_vEndPos, m_fPositionFrac));
float2 p1(0.0f, 0.0f);
float2 p2(0.42f, 0.0f);
float2 p3(0.58f, 1.0f);
float2 p4(1.0f, 1.0f);
float t = m_fPositionFrac;
float2 p = powf(1.0f - t, 3.0f) * p1 + 3.0f * powf(1.0f - t, 2.0f) * t * p2 + 3.0f * (1.0f - t) * powf(t, 2.0f) * p3 + powf(t, 3.0f) * p4;
t = p.y;
setPos(SMVectorLerp(m_vStartPos, m_vEndPos, t));
}
void CPropDoor::stop()
......
......@@ -153,14 +153,20 @@ void CPhyWorld::update(int thread)
{
return;
}
if(--m_iSkipFrames >= 0)
{
return;
}
static UINT time0 = GetTickCount();
UINT time1 = GetTickCount();
if(time1 - time0 > 5000)
if(time1 == time0)
{
time0 = time1;
return;
}
//printf("%.3fs\n", (float)(time1 - time0) / 1000.0f);
m_pDynamicsWorld->stepSimulation((float)(time1 - time0) / 1000.0f, 0, 1.0f / 60.0f);
time0 = time1;
......@@ -262,8 +268,13 @@ void CPhyWorld::loadGeom(const char * file)
m_pGeomStaticRigidBody->setCollisionFlags(m_pGeomStaticRigidBody->getCollisionFlags() | btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT);
m_pGeomStaticRigidBody->setFriction(100.0f);
//abcdef0123456789
//--------
//worldptr
//1071d577
m_pGeomStaticRigidBody->setUserPointer((void*)0x00000001);
addShape(m_pGeomStaticRigidBody, CG_STATIC, CG_ALL ^ (CG_DOOR | CG_HITBOX | CG_NPCVIEW | CG_STATIC | CG_TRIGGER | CG_WATER));
addShape(m_pGeomStaticRigidBody, CG_STATIC, CG_STATIC_MASK);
}
}
SGeom_ClearArrBuffsGeom(ppVertices, pVertexCount, ppIndices, ppMtls, pIndexCount, iModelCount);
......@@ -457,7 +468,7 @@ void CPhyWorld::loadGeom(const char * file)
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT);
body->setFriction(100.0f);
addShape(body, CG_STATIC, CG_ALL ^ (CG_DOOR | CG_HITBOX | CG_NPCVIEW | CG_STATIC | CG_TRIGGER | CG_WATER));
addShape(body, CG_STATIC, CG_STATIC_MASK);
}
}
}
......@@ -780,6 +791,7 @@ void CPhyWorld::disableSimulation()
void CPhyWorld::enableSimulation()
{
m_isRunning = true;
m_iSkipFrames = 3;
}
//##############################################################
......
......@@ -134,6 +134,7 @@ protected:
int * m_piGreenTotal;
bool m_isRunning;
int m_iSkipFrames = 3;
};
#endif
......@@ -57,6 +57,8 @@ enum COLLISION_GROUP
CG_ALL = 0xFFFFFFFF
};
#define CG_STATIC_MASK (CG_ALL ^ (CG_DOOR | CG_HITBOX | CG_STATIC | CG_TRIGGER | CG_WATER))
//! Описатель физических свойств поверхности
struct SurfaceInfo
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment