Merge branch 'feature/physics_sleep' into modnark
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -40,6 +40,9 @@
|
|||||||
*.ilk
|
*.ilk
|
||||||
*.dep
|
*.dep
|
||||||
|
|
||||||
|
# ResEditor files
|
||||||
|
*.aps
|
||||||
|
|
||||||
/Debug
|
/Debug
|
||||||
/Release
|
/Release
|
||||||
stdout.txt
|
stdout.txt
|
||||||
@@ -54,3 +57,4 @@ desktop.ini
|
|||||||
|
|
||||||
#Redist
|
#Redist
|
||||||
!Installer/Redist/*
|
!Installer/Redist/*
|
||||||
|
UpgradeLog.htm
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
ProgramDatabaseFile=".\Release/Blocks3D.pdb"
|
ProgramDatabaseFile=".\Release/Blocks3D.pdb"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
|
StackReserveSize="16777216"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
@@ -179,6 +180,7 @@
|
|||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile=".\Debug/Blocks3D.pdb"
|
ProgramDatabaseFile=".\Debug/Blocks3D.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
|
StackReserveSize="16777216"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
@@ -733,6 +735,14 @@
|
|||||||
RelativePath=".\src\include\TextureHandler.h"
|
RelativePath=".\src\include\TextureHandler.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\ToolEnum.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\VS2005CompatShim.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\win32Defines.h"
|
RelativePath=".\src\include\win32Defines.h"
|
||||||
>
|
>
|
||||||
|
|||||||
BIN
Dialogs.aps
BIN
Dialogs.aps
Binary file not shown.
@@ -10,7 +10,7 @@
|
|||||||
#define APP_GENER 0
|
#define APP_GENER 0
|
||||||
#define APP_MAJOR 0
|
#define APP_MAJOR 0
|
||||||
#define APP_MINOR 106
|
#define APP_MINOR 106
|
||||||
#define APP_PATCH 2
|
#define APP_PATCH 4
|
||||||
#define APP_VER_STRING APP_GENER.APP_MAJOR.APP_MINOR.APP_PATCH
|
#define APP_VER_STRING APP_GENER.APP_MAJOR.APP_MINOR.APP_PATCH
|
||||||
|
|
||||||
#define VER_PREFIX( N ) v##N
|
#define VER_PREFIX( N ) v##N
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border: outset 2px;">
|
<body style="background-color: ButtonFace; margin: 0; padding: 5px; overflow: hidden; border: outset 2px;">
|
||||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="alert(window.external.ToggleHopperBin(0))">
|
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(0)">
|
||||||
<img src="../images/GameTool.png" />
|
<img src="../images/GameTool.png" />
|
||||||
</span>
|
</span>
|
||||||
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(1)">
|
<span class="container" onmousedown="toolOvr(this)" onmouseup="toolOut(this)" onmouseout="toolOut(this)" onclick="window.external.ToggleHopperBin(1)">
|
||||||
|
|||||||
@@ -7,10 +7,19 @@ class LevelInstance :
|
|||||||
public:
|
public:
|
||||||
LevelInstance(void);
|
LevelInstance(void);
|
||||||
~LevelInstance(void);
|
~LevelInstance(void);
|
||||||
|
bool HighScoreIsGood;
|
||||||
|
Enum::ActionType::Value TimerUpAction;
|
||||||
|
Enum::AffectType::Value TimerAffectsScore;
|
||||||
|
bool RunOnOpen;
|
||||||
float timer;
|
float timer;
|
||||||
int score;
|
int score;
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
std::string winMessage;
|
std::string winMessage;
|
||||||
std::string loseMessage;
|
std::string loseMessage;
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
void winCondition();
|
||||||
|
void loseCondition();
|
||||||
|
void pauseCondition();
|
||||||
|
void drawCondition();
|
||||||
|
void Step(SimTime sdt);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,4 +20,16 @@ namespace Enum
|
|||||||
Player = 7, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, None = 0
|
Player = 7, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, None = 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
namespace ActionType
|
||||||
|
{
|
||||||
|
enum Value {
|
||||||
|
Nothing = 0, Pause = 1, Lose = 2, Draw = 3, Win = 4
|
||||||
|
};
|
||||||
|
}
|
||||||
|
namespace AffectType
|
||||||
|
{
|
||||||
|
enum Value {
|
||||||
|
NoChange = 0, Increase = 1, Decrease = 2
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
11
src/include/ToolEnum.h
Normal file
11
src/include/ToolEnum.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Enum
|
||||||
|
{
|
||||||
|
namespace Hopper
|
||||||
|
{
|
||||||
|
enum Value {
|
||||||
|
GameTool = 0, Grab = 1, Clone = 2, Hammer = 3, Slingshot = 4, Rocket = 5, Laser = 6
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/include/VS2005CompatShim.h
Normal file
26
src/include/VS2005CompatShim.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef COMPAT_SHIM
|
||||||
|
#define COMPAT_SHIM
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
std::string toString(const T &value)
|
||||||
|
{
|
||||||
|
std::ostringstream os;
|
||||||
|
os << value;
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
std::string to_string( int value ) {return toString(value);}
|
||||||
|
std::string to_string( long value ) {return toString(value);}
|
||||||
|
std::string to_string( long long value ) {return toString(value);}
|
||||||
|
std::string to_string( unsigned value ) {return toString(value);}
|
||||||
|
std::string to_string( unsigned long value ) {return toString(value);}
|
||||||
|
std::string to_string( unsigned long long value ) {return toString(value);}
|
||||||
|
std::string to_string( float value ) {return toString(value);}
|
||||||
|
std::string to_string( double value ) {return toString(value);}
|
||||||
|
std::string to_string( long double value ) {return toString(value);}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -323,6 +323,9 @@ void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|||||||
|
|
||||||
if(_dataModel->isRunning())
|
if(_dataModel->isRunning())
|
||||||
{
|
{
|
||||||
|
LevelInstance* Level = _dataModel->getLevel();
|
||||||
|
Level->Step(sdt);
|
||||||
|
|
||||||
// XplicitNgine Start
|
// XplicitNgine Start
|
||||||
std::vector<PartInstance *> toDelete;
|
std::vector<PartInstance *> toDelete;
|
||||||
for(size_t i = 0; i < _dataModel->getWorkspace()->partObjects.size(); i++)
|
for(size_t i = 0; i < _dataModel->getWorkspace()->partObjects.size(); i++)
|
||||||
@@ -343,9 +346,9 @@ void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|||||||
p->setParent(NULL);
|
p->setParent(NULL);
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < 6; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
_dataModel->getEngine()->step(0.1F);
|
_dataModel->getEngine()->step(0.03F);
|
||||||
}
|
}
|
||||||
onLogic();
|
onLogic();
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "DataModelV2/DataModelInstance.h"
|
||||||
#include "DataModelV2/LevelInstance.h"
|
#include "DataModelV2/LevelInstance.h"
|
||||||
|
|
||||||
LevelInstance::LevelInstance(void)
|
LevelInstance::LevelInstance(void)
|
||||||
@@ -16,6 +17,61 @@ LevelInstance::~LevelInstance(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static TCHAR* strActionType(int option)
|
||||||
|
{
|
||||||
|
switch(option)
|
||||||
|
{
|
||||||
|
case Enum::ActionType::Nothing:
|
||||||
|
return "Nothing";
|
||||||
|
case Enum::ActionType::Pause:
|
||||||
|
return "Pause";
|
||||||
|
case Enum::ActionType::Lose:
|
||||||
|
return "Lose";
|
||||||
|
case Enum::ActionType::Draw:
|
||||||
|
return "Draw";
|
||||||
|
case Enum::ActionType::Win:
|
||||||
|
return "Win";
|
||||||
|
}
|
||||||
|
return "Nothing";
|
||||||
|
}
|
||||||
|
|
||||||
|
static Enum::ActionType::Value EnumActionType(TCHAR* option)
|
||||||
|
{
|
||||||
|
if(strcmp("Nothing", option) == 0)
|
||||||
|
return Enum::ActionType::Nothing;
|
||||||
|
if(strcmp("Pause", option) == 0)
|
||||||
|
return Enum::ActionType::Pause;
|
||||||
|
if(strcmp("Lose", option) == 0)
|
||||||
|
return Enum::ActionType::Lose;
|
||||||
|
if(strcmp("Draw", option) == 0)
|
||||||
|
return Enum::ActionType::Draw;
|
||||||
|
return Enum::ActionType::Win;
|
||||||
|
}
|
||||||
|
|
||||||
|
static TCHAR* strAffectType(int option)
|
||||||
|
{
|
||||||
|
switch(option)
|
||||||
|
{
|
||||||
|
case Enum::AffectType::NoChange:
|
||||||
|
return "NoChange";
|
||||||
|
case Enum::AffectType::Increase:
|
||||||
|
return "Increase";
|
||||||
|
case Enum::AffectType::Decrease:
|
||||||
|
return "Decrease";
|
||||||
|
}
|
||||||
|
return "NoChange";
|
||||||
|
}
|
||||||
|
|
||||||
|
static Enum::AffectType::Value EnumAffectType(TCHAR* option)
|
||||||
|
{
|
||||||
|
if(strcmp("NoChange", option) == 0)
|
||||||
|
return Enum::AffectType::NoChange;
|
||||||
|
if(strcmp("Increase", option) == 0)
|
||||||
|
return Enum::AffectType::Increase;
|
||||||
|
return Enum::AffectType::Decrease;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char timerTxt[12];
|
char timerTxt[12];
|
||||||
char scoreTxt[12];
|
char scoreTxt[12];
|
||||||
std::vector<PROPGRIDITEM> LevelInstance::getProperties()
|
std::vector<PROPGRIDITEM> LevelInstance::getProperties()
|
||||||
@@ -29,12 +85,28 @@ std::vector<PROPGRIDITEM> LevelInstance::getProperties()
|
|||||||
"The message that shows when the player wins.",
|
"The message that shows when the player wins.",
|
||||||
(LPARAM)winMessage.c_str(),
|
(LPARAM)winMessage.c_str(),
|
||||||
PIT_EDIT));
|
PIT_EDIT));
|
||||||
|
|
||||||
properties.push_back(createPGI("Messages",
|
properties.push_back(createPGI("Messages",
|
||||||
"LoseMessage",
|
"LoseMessage",
|
||||||
"The message that shows when the player loses.",
|
"The message that shows when the player loses.",
|
||||||
(LPARAM)loseMessage.c_str(),
|
(LPARAM)loseMessage.c_str(),
|
||||||
PIT_EDIT));
|
PIT_EDIT));
|
||||||
|
|
||||||
|
properties.push_back(createPGI(
|
||||||
|
"Gameplay",
|
||||||
|
"HighScoreIsGood",
|
||||||
|
"Some temporary string here",
|
||||||
|
(LPARAM)HighScoreIsGood,
|
||||||
|
PIT_CHECK
|
||||||
|
));
|
||||||
|
|
||||||
|
properties.push_back(createPGI(
|
||||||
|
"Gameplay",
|
||||||
|
"RunOnOpen",
|
||||||
|
"Some temporary string here",
|
||||||
|
(LPARAM)RunOnOpen,
|
||||||
|
PIT_CHECK
|
||||||
|
));
|
||||||
|
|
||||||
sprintf_s(timerTxt, "%g", timer);
|
sprintf_s(timerTxt, "%g", timer);
|
||||||
sprintf_s(scoreTxt, "%d", score);
|
sprintf_s(scoreTxt, "%d", score);
|
||||||
@@ -43,11 +115,28 @@ std::vector<PROPGRIDITEM> LevelInstance::getProperties()
|
|||||||
"The amount of time in seconds the player has to complete this level.\r\n\r\nPut 0 if time is limitless.",
|
"The amount of time in seconds the player has to complete this level.\r\n\r\nPut 0 if time is limitless.",
|
||||||
(LPARAM)timerTxt,
|
(LPARAM)timerTxt,
|
||||||
PIT_EDIT));
|
PIT_EDIT));
|
||||||
|
|
||||||
properties.push_back(createPGI("Gameplay",
|
properties.push_back(createPGI("Gameplay",
|
||||||
"InitialScoreValue",
|
"InitialScoreValue",
|
||||||
"The amount of points the player starts with.",
|
"The amount of points the player starts with.",
|
||||||
(LPARAM)scoreTxt,
|
(LPARAM)scoreTxt,
|
||||||
PIT_EDIT));
|
PIT_EDIT));
|
||||||
|
|
||||||
|
properties.push_back(createPGI("Gameplay",
|
||||||
|
"TimerUpAction",
|
||||||
|
"Some temporary string here",
|
||||||
|
(LPARAM)strActionType(TimerUpAction),
|
||||||
|
PIT_COMBO,
|
||||||
|
TEXT("Nothing\0Pause\0Lose\0Draw\0Win\0")
|
||||||
|
));
|
||||||
|
|
||||||
|
properties.push_back(createPGI("Gameplay",
|
||||||
|
"TimerAffectsScore",
|
||||||
|
"Some temporary string here",
|
||||||
|
(LPARAM)strAffectType(TimerAffectsScore),
|
||||||
|
PIT_COMBO,
|
||||||
|
TEXT("NoChange\0Increase\0Decrease\0")
|
||||||
|
));
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
||||||
@@ -68,6 +157,87 @@ void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
|||||||
{
|
{
|
||||||
winMessage = (LPSTR)pItem->lpCurValue;
|
winMessage = (LPSTR)pItem->lpCurValue;
|
||||||
}
|
}
|
||||||
|
else if(strcmp(pItem->lpszPropName, "TimerUpAction") == 0)
|
||||||
|
{
|
||||||
|
TimerUpAction = EnumActionType((TCHAR*)pItem->lpCurValue);
|
||||||
|
}
|
||||||
|
else if(strcmp(pItem->lpszPropName, "TimerAffectsScore") == 0)
|
||||||
|
{
|
||||||
|
TimerAffectsScore = EnumAffectType((TCHAR*)pItem->lpCurValue);
|
||||||
|
}
|
||||||
|
else if(strcmp(pItem->lpszPropName, "HighScoreIsGood") == 0)
|
||||||
|
{
|
||||||
|
HighScoreIsGood = pItem->lpCurValue == TRUE;
|
||||||
|
}
|
||||||
|
else if(strcmp(pItem->lpszPropName, "RunOnOpen") == 0)
|
||||||
|
{
|
||||||
|
RunOnOpen = pItem->lpCurValue == TRUE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Instance::PropUpdate(pItem);
|
Instance::PropUpdate(pItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LevelInstance::winCondition()
|
||||||
|
{
|
||||||
|
DataModelInstance* DataModel = (DataModelInstance*)getParent(); //If level parent gets changed to something other than Datamodel it could cause nasty data corruption bugs
|
||||||
|
DataModel->setMessage(winMessage);
|
||||||
|
DataModel->toggleRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelInstance::loseCondition()
|
||||||
|
{
|
||||||
|
DataModelInstance* DataModel = (DataModelInstance*)getParent();
|
||||||
|
DataModel->setMessage(loseMessage);
|
||||||
|
DataModel->toggleRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelInstance::pauseCondition()
|
||||||
|
{
|
||||||
|
DataModelInstance* DataModel = (DataModelInstance*)getParent();
|
||||||
|
DataModel->toggleRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelInstance::drawCondition()
|
||||||
|
{
|
||||||
|
DataModelInstance* DataModel = (DataModelInstance*)getParent();
|
||||||
|
DataModel->toggleRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LevelInstance::Step(SimTime sdt)
|
||||||
|
{
|
||||||
|
switch(TimerAffectsScore)
|
||||||
|
{
|
||||||
|
case Enum::AffectType::NoChange:
|
||||||
|
break;
|
||||||
|
case Enum::AffectType::Increase:
|
||||||
|
score += 1;
|
||||||
|
break;
|
||||||
|
case Enum::AffectType::Decrease:
|
||||||
|
if (score > 0)
|
||||||
|
score -= 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (timer >= 0.1f){ //Due to timing used this could cause the number go into negatives for one step
|
||||||
|
timer -= sdt;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
timer = 0.0f;
|
||||||
|
switch(TimerUpAction)
|
||||||
|
{
|
||||||
|
case Enum::ActionType::Nothing:
|
||||||
|
break;
|
||||||
|
case Enum::ActionType::Pause:
|
||||||
|
pauseCondition();
|
||||||
|
break;
|
||||||
|
case Enum::ActionType::Lose:
|
||||||
|
loseCondition();
|
||||||
|
break;
|
||||||
|
case Enum::ActionType::Draw:
|
||||||
|
drawCondition();
|
||||||
|
break;
|
||||||
|
case Enum::ActionType::Win:
|
||||||
|
winCondition();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -259,7 +259,6 @@ void PartInstance::setCFrameNoSync(CoordinateFrame coordinateFrame)
|
|||||||
{
|
{
|
||||||
cFrame = coordinateFrame;
|
cFrame = coordinateFrame;
|
||||||
position = coordinateFrame.translation;
|
position = coordinateFrame.translation;
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PartInstance::collides(PartInstance * part)
|
bool PartInstance::collides(PartInstance * part)
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ XplicitNgine::XplicitNgine()
|
|||||||
physSpace = dHashSpaceCreate(0);
|
physSpace = dHashSpaceCreate(0);
|
||||||
contactgroup = dJointGroupCreate(0);
|
contactgroup = dJointGroupCreate(0);
|
||||||
|
|
||||||
dWorldSetGravity(physWorld, 0, -0.5, 0);
|
dWorldSetGravity(physWorld, 0, -9.8, 0);
|
||||||
|
dWorldSetAutoDisableFlag(physWorld, 1);
|
||||||
|
dWorldSetAutoDisableLinearThreshold(physWorld, 0.05F);
|
||||||
|
dWorldSetAutoDisableAngularThreshold(physWorld, 0.05F);
|
||||||
|
dWorldSetAutoDisableSteps(physWorld, 400);
|
||||||
|
|
||||||
this->name = "PhysicsService";
|
this->name = "PhysicsService";
|
||||||
//dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
|
//dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
|
||||||
@@ -70,8 +74,30 @@ void XplicitNgine::deleteBody(PartInstance* partInstance)
|
|||||||
{
|
{
|
||||||
if(partInstance->physBody != NULL)
|
if(partInstance->physBody != NULL)
|
||||||
{
|
{
|
||||||
while(dBodyGetNumJoints(partInstance->physBody) > 0) {
|
dBodyEnable(partInstance->physBody);
|
||||||
dJointDestroy(dBodyGetJoint(partInstance->physBody, 0));
|
dGeomEnable(partInstance->physGeom[0]);
|
||||||
|
//createBody(partInstance);
|
||||||
|
//step(0.5F);
|
||||||
|
for(int i = 0; i < dBodyGetNumJoints(partInstance->physBody); i++) {
|
||||||
|
dBodyID b1 = dJointGetBody(dBodyGetJoint(partInstance->physBody, i), 0);
|
||||||
|
dBodyID b2 = dJointGetBody(dBodyGetJoint(partInstance->physBody, i), 1);
|
||||||
|
|
||||||
|
if(b1 != NULL)
|
||||||
|
{
|
||||||
|
dBodyEnable(b1);
|
||||||
|
PartInstance * part = (PartInstance *)dBodyGetData(b1);
|
||||||
|
if(part != NULL)
|
||||||
|
dGeomEnable(part->physGeom[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b2 != NULL)
|
||||||
|
{
|
||||||
|
dBodyEnable(b2);
|
||||||
|
PartInstance * part = (PartInstance *)dBodyGetData(b2);
|
||||||
|
if(part != NULL)
|
||||||
|
dGeomEnable(part->physGeom[0]);
|
||||||
|
}
|
||||||
|
dJointDestroy(dBodyGetJoint(partInstance->physBody, i));
|
||||||
}
|
}
|
||||||
dBodyDestroy(partInstance->physBody);
|
dBodyDestroy(partInstance->physBody);
|
||||||
dGeomDestroy(partInstance->physGeom[0]);
|
dGeomDestroy(partInstance->physGeom[0]);
|
||||||
@@ -84,18 +110,21 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
// calculate collisions
|
// calculate collisions
|
||||||
//dSpaceCollide (physSpace,0,&collisionCallback);
|
//dSpaceCollide (physSpace,0,&collisionCallback);
|
||||||
|
|
||||||
|
Vector3 partSize = partInstance->getSize();
|
||||||
|
Vector3 partPosition = partInstance->getPosition();
|
||||||
if(partInstance->physBody == NULL)
|
if(partInstance->physBody == NULL)
|
||||||
{
|
{
|
||||||
// init body
|
// init body
|
||||||
partInstance->physBody = dBodyCreate(physWorld);
|
partInstance->physBody = dBodyCreate(physWorld);
|
||||||
|
dBodySetData(partInstance->physBody, partInstance);
|
||||||
|
|
||||||
// Create geom
|
// Create geom
|
||||||
if(partInstance->shape == Enum::Shape::Block)
|
if(partInstance->shape == Enum::Shape::Block)
|
||||||
{
|
{
|
||||||
partInstance->physGeom[0] = dCreateBox(physSpace,
|
partInstance->physGeom[0] = dCreateBox(physSpace,
|
||||||
partInstance->getSize()[0],
|
partSize.x,
|
||||||
partInstance->getSize()[1],
|
partSize.y,
|
||||||
partInstance->getSize()[2]
|
partSize.z
|
||||||
);
|
);
|
||||||
|
|
||||||
dVector3 result;
|
dVector3 result;
|
||||||
@@ -108,11 +137,11 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
partInstance->physGeom[0] = dCreateSphere(physSpace, partInstance->getSize()[0]/2);
|
partInstance->physGeom[0] = dCreateSphere(physSpace, partSize[0]/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
dMass mass;
|
dMass mass;
|
||||||
mass.setBox(partInstance->getSize().x, partInstance->getSize().y, partInstance->getSize().z, 0.7F);
|
mass.setBox(sqrt(partSize.x*2), sqrt(partSize.y*2), sqrt(partSize.z*2), 0.7F);
|
||||||
dBodySetMass(partInstance->physBody, &mass);
|
dBodySetMass(partInstance->physBody, &mass);
|
||||||
|
|
||||||
// Debug output
|
// Debug output
|
||||||
@@ -121,15 +150,15 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
// Create rigid body
|
// Create rigid body
|
||||||
//printf("[XplicitNgine] Created Geom for PartInstance\n");
|
//printf("[XplicitNgine] Created Geom for PartInstance\n");
|
||||||
dBodySetPosition(partInstance->physBody,
|
dBodySetPosition(partInstance->physBody,
|
||||||
partInstance->getPosition()[0],
|
partPosition.x,
|
||||||
partInstance->getPosition()[1],
|
partPosition.y,
|
||||||
partInstance->getPosition()[2]
|
partPosition.z
|
||||||
);
|
);
|
||||||
|
|
||||||
dGeomSetPosition(partInstance->physGeom[0],
|
dGeomSetPosition(partInstance->physGeom[0],
|
||||||
partInstance->getPosition()[0],
|
partPosition.x,
|
||||||
partInstance->getPosition()[1],
|
partPosition.y,
|
||||||
partInstance->getPosition()[2]);
|
partPosition.z);
|
||||||
|
|
||||||
Matrix3 g3dRot = partInstance->getCFrame().rotation;
|
Matrix3 g3dRot = partInstance->getCFrame().rotation;
|
||||||
float rotation [12] = { g3dRot[0][0], g3dRot[0][1], g3dRot[0][2], 0,
|
float rotation [12] = { g3dRot[0][0], g3dRot[0][1], g3dRot[0][2], 0,
|
||||||
@@ -167,9 +196,11 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
|
|
||||||
void XplicitNgine::step(float stepSize)
|
void XplicitNgine::step(float stepSize)
|
||||||
{
|
{
|
||||||
|
dJointGroupEmpty(contactgroup);
|
||||||
dSpaceCollide (physSpace,0,&collisionCallback);
|
dSpaceCollide (physSpace,0,&collisionCallback);
|
||||||
dWorldQuickStep(physWorld, stepSize);
|
dWorldQuickStep(physWorld, stepSize);
|
||||||
dJointGroupEmpty(contactgroup);
|
//dWorldStepFast1(physWorld, stepSize*2, 100);
|
||||||
|
//dWorldStep(physWorld, stepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XplicitNgine::updateBody(PartInstance *partInstance, CoordinateFrame * cFrame)
|
void XplicitNgine::updateBody(PartInstance *partInstance, CoordinateFrame * cFrame)
|
||||||
@@ -183,6 +214,8 @@ void XplicitNgine::updateBody(PartInstance *partInstance, CoordinateFrame * cFra
|
|||||||
position[1],
|
position[1],
|
||||||
position[2]
|
position[2]
|
||||||
);
|
);
|
||||||
|
dBodyEnable(partInstance->physBody);
|
||||||
|
dGeomEnable(partInstance->physGeom[0]);
|
||||||
|
|
||||||
Matrix3 g3dRot = cFrame->rotation;
|
Matrix3 g3dRot = cFrame->rotation;
|
||||||
float rotation [12] = { g3dRot[0][0], g3dRot[0][1], g3dRot[0][2], 0,
|
float rotation [12] = { g3dRot[0][0], g3dRot[0][1], g3dRot[0][2], 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user