Commit 705add06 authored by D-AIRY's avatar D-AIRY

Fixed helper; Physbox optimisation on load

parent e8efb04b
bullet3 @ 6c0c492d
Subproject commit 0d4f8a915cd92ffd82a495dd02084896dc4b05b6
Subproject commit 6c0c492d5306f8be30221bd2d6a2ed926d6be199
common @ fae22b17
Subproject commit b462b5ba29bf653c7309564ce4cc2d0718fffd03
Subproject commit fae22b172af6ec77e9e767aecd0d012e8fd6414a
This diff is collapsed.
......@@ -38,7 +38,7 @@ inline bool line_intersect_triangle(const float3 &t1, const float3 &t2, const fl
#define AXES_HELPER_SCALE_LENGTH 1.f /*!< */
#define AXES_HELPER_SCALE_ASIZE 0.05f /*!< */
#define AXES_HELPER_SCALE_A2SIZE 0.15f /*!< */
#define AXES_HELPER_SCALE_SPEED 1.f /*!< */
//#define AXES_HELPER_SCALE_SPEED 1.f /*!< */
class CAxesHelper
{
......@@ -64,18 +64,19 @@ public:
void setPosition(const float3 & pos);
void setRotation(const float3 & rot);
void setRotation(const SMQuaternion & rot);
void setScale(const float3 & scale);
//void setScale(const float3 & scale);
const float3 & getPosition();
const float3 & getRotation();
const float3 & getScale();
const SMQuaternion & getRotationQ();
void onMouseMove(int x, int y);
void update();
bool m_bIsDragging;
bool m_bIsDraggingStart;
bool m_bIsDraggingStop;
bool isDragging()
{
return(m_bIsDragging);
}
private:
......@@ -83,6 +84,11 @@ private:
float3 m_vRotation;
SMQuaternion m_qRotation;
float3 m_vScale, m_vScaleOld;
bool m_bIsDragging;
SMPLANE m_movementPlane;
float3 m_vMovementLinePos;
float3 m_vMovementLineDir;
float3 m_vTransOffset;
void drawMove();
void drawCylinder(float3_t lwh, DWORD color = 0xFFFFFFFF);
......@@ -114,12 +120,8 @@ private:
HANDLER_AXE m_currentAxe;
HANDLER_TYPE m_htype;
float3 m_fStartDragPos;
SMMATRIX m_mHelperMat;
SMMATRIX m_mOldHelperMat;
//float3 m_fStartDragPos;
SMMATRIX m_mHelperMatScale2;
SMMATRIX m_mOldDragMat;
SMMATRIX m_mOldDragMatPos;
};
#endif
\ No newline at end of file
......@@ -216,7 +216,15 @@ void CBaseAnimating::initPhysics()
{
if(phTypes[i] == HT_CONVEX)
{
m_pCollideShape = new btConvexHullShape((float*)ppfData[i], pfDataLen[i], sizeof(ppfData[0][0]));
//m_pCollideShape = new btConvexHullShape((float*)ppfData[i], pfDataLen[i], sizeof(ppfData[0][0]));
btConvexHullShape tmpShape((float*)ppfData[i], pfDataLen[i], sizeof(ppfData[0][0]));
tmpShape.setMargin(0);
btVector3 *pData;
int iVertexCount;
SXPhysics_BuildHull(&tmpShape, &pData, &iVertexCount);
m_pCollideShape = new btConvexHullShape((float*)pData, iVertexCount, sizeof(btVector3));
SXPhysics_ReleaseHull(pData, iVertexCount);
}
break;
}
......@@ -478,3 +486,4 @@ void CBaseAnimating::setSkin(int iSkin)
}
m_iSkin = iSkin;
}
......@@ -139,6 +139,10 @@ SX_LIB_API void SXPhysics_DisableSimulation();
SX_LIB_API void SXPhysics_DumpStats();
SX_LIB_API void SXPhysics_BuildHull(btConvexHullShape *pIn, btVector3 **ppOut, int *pNumVertices);
SX_LIB_API void SXPhysics_ReleaseHull(btVector3 *pData, int iNumVertices);
#endif
/*! @} */
......
......@@ -11,6 +11,7 @@ See the license in LICENSE
#include "PhyWorld.h"
#include <core/sxcore.h>
#include <BulletCollision/CollisionShapes/btShapeHull.h>
#if defined(_DEBUG)
# pragma comment(lib, "sxcore_d.lib")
......@@ -185,3 +186,18 @@ SX_LIB_API void SXPhysics_DisableSimulation()
g_pWorld->disableSimulation();
}
SX_LIB_API void SXPhysics_BuildHull(btConvexHullShape *pIn, btVector3 **ppOut, int *pNumVertices)
{
btShapeHull tmpHull(pIn);
tmpHull.buildHull(0);
*pNumVertices = tmpHull.numVertices();
*ppOut = new btVector3[*pNumVertices];
memcpy(*ppOut, tmpHull.getVertexPointer(), sizeof(btVector3)* *pNumVertices);
//return(new btConvexHullShape((const btScalar*)tmpHull.getVertexPointer(), tmpHull.numVertices(), sizeof(btVector3)));
}
SX_LIB_API void SXPhysics_ReleaseHull(btVector3 *pData, int iNumVertices)
{
mem_delete_a(pData);
}
......@@ -13,28 +13,28 @@ LRESULT ComMenuId(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
WORD id = LOWORD(wParam);
//
//
//файл
//новый
if (id == ID_FILE_NEW)
{
level_editor::LevelNew(true);
}
//
//открыть
else if (id == ID_FILE_OPEN)
{
level_editor::LevelOpen();
}
//
//сохранить
else if (id == ID_FILE_SAVE)
{
level_editor::LevelSave();
}
//
//сохранить как
else if (id == ID_FILE_SAVEAS)
{
level_editor::LevelSaveAs();
}
//
//выход
else if (id == ID_FILE_EXIT)
{
return TrueExit(hWnd, uiMsg, wParam, lParam);
......@@ -177,12 +177,12 @@ LRESULT SXLevelEditor_RenderWindow_MouseMove(HWND hWnd, UINT uiMsg, WPARAM wPara
{
if (SSInput_GetKeyState(SIK_LCONTROL) || SSInput_GetKeyState(SIK_LSHIFT))
{
level_editor::pAxesHelper->m_bIsDragging = false;
level_editor::pAxesHelper->m_bIsDraggingStop = true;
//level_editor::pAxesHelper->m_bIsDragging = false;
//level_editor::pAxesHelper->m_bIsDraggingStop = true;
return 0;
}
// id
//если включено копирование и id копирования валидный
if (level_editor::useCopyData && level_editor::idCopy >= 0)
{
if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM)
......@@ -193,16 +193,16 @@ LRESULT SXLevelEditor_RenderWindow_MouseMove(HWND hWnd, UINT uiMsg, WPARAM wPara
return 0;
}
//
level_editor::pAxesHelper->onMouseMove(((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)));
//сообщаем хелперу о движениях мыши
//level_editor::pAxesHelper->onMouseMove(((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)));
//
//если активна статическая геометрия
if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM && level_editor::idActiveElement >= 0)
level_editor::GeomTransformByHelper();
//
//если выделена растительность и выделен конкретный объект
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN && level_editor::idActiveElement >= 0 && level_editor::idActiveGreenSplit >= 0 && level_editor::idActiveGreenObject >= 0)
level_editor::GreenTransformByHelper();
//
//если выделен игровой объект
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GAME && level_editor::idActiveElement >= 0)
level_editor::GameTransformByHelper();
......@@ -214,8 +214,8 @@ LRESULT SXLevelEditor_RenderWindow_LDown(HWND hWnd, UINT uiMsg, WPARAM wParam, L
if (SSInput_GetKeyState(SIK_LCONTROL) || SSInput_GetKeyState(SIK_LSHIFT))
return 0;
level_editor::pAxesHelper->m_bIsDragging = true;
level_editor::pAxesHelper->m_bIsDraggingStart = true;
//level_editor::pAxesHelper->m_bIsDragging = true;
//level_editor::pAxesHelper->m_bIsDraggingStart = true;
return 0;
}
......@@ -223,12 +223,12 @@ LRESULT SXLevelEditor_RenderWindow_LClick(HWND hWnd, UINT uiMsg, WPARAM wParam,
{
if (SSInput_GetKeyState(SIK_LCONTROL) || SSInput_GetKeyState(SIK_LSHIFT))
{
level_editor::pAxesHelper->m_bIsDragging = false;
level_editor::pAxesHelper->m_bIsDraggingStop = true;
//level_editor::pAxesHelper->m_bIsDragging = false;
//level_editor::pAxesHelper->m_bIsDraggingStop = true;
return 0;
}
//
// если включено копирование
if (level_editor::useCopyData && level_editor::idCopy >= 0)
{
if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM)
......@@ -239,13 +239,13 @@ LRESULT SXLevelEditor_RenderWindow_LClick(HWND hWnd, UINT uiMsg, WPARAM wParam,
return 0;
}
level_editor::pAxesHelper->m_bIsDragging = false;
level_editor::pAxesHelper->m_bIsDraggingStop = true;
//level_editor::pAxesHelper->m_bIsDragging = false;
//level_editor::pAxesHelper->m_bIsDraggingStop = true;
static const int *r_win_width = GET_PCVAR_INT("r_win_width");
static const int *r_win_height = GET_PCVAR_INT("r_win_height");
// ,
//если включено выделение, тогда находим
if (level_editor::pCheckBoxTBArrow->getCheck())
{
......@@ -483,8 +483,8 @@ LRESULT SXLevelEditor_ToolBar1_CallWmCommand(HWND hWnd, UINT uiMsg, WPARAM wPara
level_editor::pCheckBoxTBRot->setCheck(false);
level_editor::pCheckBoxTBScale->setCheck(false);
level_editor::pAxesHelper->setType(CAxesHelper::HANDLER_TYPE_NONE);
level_editor::pAxesHelper->m_bIsDragging = false;
level_editor::pAxesHelper->m_bIsDraggingStop = true;
//level_editor::pAxesHelper->m_bIsDragging = false;
//level_editor::pAxesHelper->m_bIsDraggingStop = true;
}
else if (level_editor::pCheckBoxTBPos->getHWND() == hElement)
{
......@@ -501,8 +501,8 @@ LRESULT SXLevelEditor_ToolBar1_CallWmCommand(HWND hWnd, UINT uiMsg, WPARAM wPara
level_editor::pCheckBoxTBRot->setCheck(false);
level_editor::pCheckBoxTBScale->setCheck(false);
level_editor::pAxesHelper->setType(CAxesHelper::HANDLER_TYPE_MOVE);
level_editor::pAxesHelper->m_bIsDragging = false;
level_editor::pAxesHelper->m_bIsDraggingStop = true;
//level_editor::pAxesHelper->m_bIsDragging = false;
//level_editor::pAxesHelper->m_bIsDraggingStop = true;
}
else
level_editor::pCheckBoxTBPos->setCheck(false);
......@@ -515,8 +515,8 @@ LRESULT SXLevelEditor_ToolBar1_CallWmCommand(HWND hWnd, UINT uiMsg, WPARAM wPara
level_editor::pCheckBoxTBPos->setCheck(false);
level_editor::pCheckBoxTBScale->setCheck(false);
level_editor::pAxesHelper->setType(CAxesHelper::HANDLER_TYPE_ROTATE);
level_editor::pAxesHelper->m_bIsDragging = false;
level_editor::pAxesHelper->m_bIsDraggingStop = true;
//level_editor::pAxesHelper->m_bIsDragging = false;
//level_editor::pAxesHelper->m_bIsDraggingStop = true;
}
else
level_editor::pCheckBoxTBRot->setCheck(false);
......@@ -529,8 +529,8 @@ LRESULT SXLevelEditor_ToolBar1_CallWmCommand(HWND hWnd, UINT uiMsg, WPARAM wPara
level_editor::pCheckBoxTBRot->setCheck(false);
level_editor::pCheckBoxTBArrow->setCheck(false);
level_editor::pAxesHelper->setType(CAxesHelper::HANDLER_TYPE_SCALE);
level_editor::pAxesHelper->m_bIsDragging = false;
level_editor::pAxesHelper->m_bIsDraggingStop = true;
//level_editor::pAxesHelper->m_bIsDragging = false;
//level_editor::pAxesHelper->m_bIsDraggingStop = true;
}
else
level_editor::pCheckBoxTBScale->setCheck(false);
......
......@@ -246,7 +246,7 @@ void level_editor::GameSel(int iSelected)
level_editor::pAxesHelper->setPosition(pEntity->getPos());
level_editor::pAxesHelper->setRotation(pEntity->getOrient());
level_editor::pAxesHelper->setScale(float3(1, 1, 1));
//level_editor::pAxesHelper->setScale(float3(1, 1, 1));
}
void level_editor::GameTraceSetPos()
......@@ -437,10 +437,10 @@ void level_editor::GameVisibleProperties(bool bf)
void level_editor::GameTransformByHelper()
{
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GAME && level_editor::idActiveElement >= 0))
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GAME && ID_VALID(level_editor::idActiveElement)))
return;
if (level_editor::pAxesHelper->m_bIsDragging == false)
if(!level_editor::pAxesHelper->isDragging())
return;
ID idGameObj = level_editor::pListBoxList->getItemData(level_editor::idActiveElement);
......
......@@ -116,7 +116,7 @@ void level_editor::GreenTraceSelect()
ID idMtrl = -1;
ID idModel = -1;
//
//если выделение объектов
if (level_editor::pComboBoxGreenSel->getSel() == 0)
{
if (SGreen_TraceBeam(&(level_editor::vRayOrigin), &(level_editor::vRayDir), &vResult, &idGreen, &idSplit, &idObj, &idMtrl))
......@@ -141,7 +141,7 @@ void level_editor::GreenTraceSelect()
level_editor::idMtl = idMtrl;
}
}
//
//если единичная генерация
else if (level_editor::pComboBoxGreenSel->getSel() == 1)
{
if (SGeom_TraceBeam(&(level_editor::vRayOrigin), &(level_editor::vRayDir), &vResult, &idModel, &idMtrl))
......@@ -164,7 +164,7 @@ void level_editor::GreenTraceSelect()
}
}
//
//если генерация в ограничивающем объеме
else if (level_editor::pComboBoxGreenSel->getSel() == 2)
{
if (SGeom_TraceBeam(&(level_editor::vRayOrigin), &(level_editor::vRayDir), &vResult, &idModel, &idMtrl))
......@@ -190,7 +190,7 @@ void level_editor::GreenTraceSelect()
}
}
}
//
//если удаление
else if (level_editor::pComboBoxGreenSel->getSel() == 3)
{
if (SGreen_TraceBeam(&(level_editor::vRayOrigin), &(level_editor::vRayDir), &vResult, &idGreen, &idSplit, &idObj, &idMtrl))
......@@ -210,7 +210,7 @@ void level_editor::GreenTraceSetPos()
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN && level_editor::idActiveElement >= 0 && level_editor::idActiveGreenSplit >= 0 && level_editor::idActiveGreenObject >= 0))
return;
// ,
//если включено индивидуальное выделение, то перемещаем объект растительности
if (level_editor::pComboBoxGreenSel->getSel() == 0)
{
float3_t vCurrPos;
......@@ -230,31 +230,31 @@ void level_editor::GreenTraceSetPos()
void level_editor::GreenTransformByHelper()
{
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN && level_editor::idActiveElement >= 0 && level_editor::idActiveGreenSplit >= 0 && level_editor::idActiveGreenObject >= 0))
if(!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN && ID_VALID(level_editor::idActiveElement) && ID_VALID(level_editor::idActiveGreenSplit) && ID_VALID(level_editor::idActiveGreenObject)))
return;
if (level_editor::pAxesHelper->m_bIsDragging == false)
if(!level_editor::pAxesHelper->isDragging())
return;
// ,
if (level_editor::pComboBoxGreenSel->getSel() == 0)
//если включено индивидуальное выделение, то перемещаем объект растительности
if(level_editor::pComboBoxGreenSel->getSel() == 0)
{
float3_t vCurrPos;
SGreen_GetPosObject(level_editor::idActiveElement, level_editor::idActiveGreenSplit, level_editor::idActiveGreenObject, &vCurrPos);
float3 vNewPos = level_editor::pAxesHelper->getPosition();
if (vCurrPos.x != vNewPos.x || vCurrPos.y != vNewPos.y || vCurrPos.z != vNewPos.z)
if(vCurrPos.x != vNewPos.x || vCurrPos.y != vNewPos.y || vCurrPos.z != vNewPos.z)
SGreen_SetPosObject(level_editor::idActiveElement, &level_editor::idActiveGreenSplit, &level_editor::idActiveGreenObject, &(float3_t)vNewPos);
}
}
void level_editor::GreenSetPos4Box()
{
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN && level_editor::idActiveElement >= 0))
if(!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN && ID_VALID(level_editor::idActiveElement)))
return;
float3 vResult;
// ,
//если включена генерация в ограничивающем объеме, значит перемещаем этот объем
if (level_editor::pComboBoxGreenSel->getSel() == 2)
{
if (SGeom_TraceBeam(&(level_editor::vRayOrigin), &(level_editor::vRayDir), &vResult, 0, 0))
......
......@@ -2240,6 +2240,8 @@ void level_editor::LevelEditorUpdate(DWORD timeDelta)
if (level_editor::pAxesHelper)
{
level_editor::pAxesHelper->update();
SGCore_GetDXDevice()->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
SGCore_GetDXDevice()->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_FALSE);
level_editor::pAxesHelper->render();
......
......@@ -246,13 +246,13 @@ void level_editor::GeomCopy()
void level_editor::GeomTransformByHelper()
{
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM && level_editor::idActiveElement >= 0))
if (!(level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM && ID_VALID(level_editor::idActiveElement)))
return;
static float3 vStartScale;
static bool isStartScale = true;
if (level_editor::pAxesHelper->m_bIsDragging == false)
if(!level_editor::pAxesHelper->isDragging())
{
isStartScale = true;
return;
......
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