Skip to content

Commit

Permalink
UPBGE: Cleanup BL_BlenderDataConversion.[cpp/h].
Browse files Browse the repository at this point in the history
This cleanup contains:
- uncrusity pass
- remove extra class/struct keyword
- remove pre definition of variable
- clean comments
  • Loading branch information
panzergame committed Oct 10, 2017
1 parent afabe80 commit f6114dc
Show file tree
Hide file tree
Showing 9 changed files with 744 additions and 850 deletions.
1,496 changes: 701 additions & 795 deletions source/gameengine/Converter/BL_BlenderDataConversion.cpp

Large diffs are not rendered by default.

30 changes: 11 additions & 19 deletions source/gameengine/Converter/BL_BlenderDataConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,17 @@
#include "KX_PhysicsEngineEnums.h"
#include "SCA_IInputDevice.h"

struct Material;
struct Mesh;
struct DerivedMesh;
struct Object;
struct Main;
class RAS_Rasterizer;
class RAS_ICanvas;
class KX_KetsjiEngine;
class KX_Scene;
class BL_BlenderSceneConverter;
struct Mesh;
struct DerivedMesh;
struct Object;
struct Main;

struct BL_MeshMaterial
{
struct BL_MeshMaterial {
RAS_IDisplayArray *array;
RAS_MaterialBucket *bucket;
bool visible;
Expand All @@ -59,18 +57,12 @@ struct BL_MeshMaterial

RAS_MeshObject *BL_ConvertMesh(Mesh *mesh, Object *lightobj, KX_Scene *scene, BL_BlenderSceneConverter& converter);
void BL_ConvertDerivedMeshToArray(DerivedMesh *dm, Mesh *me, const std::vector<BL_MeshMaterial>& mats,
const RAS_MeshObject::LayersInfo& layersInfo);
const RAS_MeshObject::LayersInfo& layersInfo);

void BL_ConvertBlenderObjects(Main *maggie,
KX_Scene *kxscene,
KX_KetsjiEngine *ketsjiEngine,
e_PhysicsEngine physics_engine,
RAS_Rasterizer *rendertools,
RAS_ICanvas *canvas,
BL_BlenderSceneConverter& sceneconverter,
bool alwaysUseExpandFraming,
bool libloading=false);
void BL_ConvertBlenderObjects(Main *maggie, KX_Scene *kxscene, KX_KetsjiEngine *ketsjiEngine, e_PhysicsEngine physics_engine,
RAS_Rasterizer *rendertools, RAS_ICanvas *canvas, BL_BlenderSceneConverter& sceneconverter,
bool alwaysUseExpandFraming, bool libloading);

SCA_IInputDevice::SCA_EnumInputs ConvertKeyCode(int key_code);
SCA_IInputDevice::SCA_EnumInputs BL_ConvertKeyCode(int key_code);

#endif /* __BL_BLENDERDATACONVERSION_H__ */
#endif // __BL_BLENDERDATACONVERSION_H__
6 changes: 3 additions & 3 deletions source/gameengine/Converter/BL_ConvertSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ void BL_ConvertSensors(struct Object* blenderobject,
if (eventmgr)
{
gamesensor = new SCA_KeyboardSensor(eventmgr,
ConvertKeyCode(blenderkeybdsensor->key),
ConvertKeyCode(blenderkeybdsensor->qual),
ConvertKeyCode(blenderkeybdsensor->qual2),
BL_ConvertKeyCode(blenderkeybdsensor->key),
BL_ConvertKeyCode(blenderkeybdsensor->qual),
BL_ConvertKeyCode(blenderkeybdsensor->qual2),
(blenderkeybdsensor->type == SENS_ALL_KEYS),
blenderkeybdsensor->targetName,
blenderkeybdsensor->toggleName,
Expand Down
4 changes: 0 additions & 4 deletions source/gameengine/GameLogic/SCA_IInputDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
#include "SCA_InputEvent.h"

#include <map>
// #include <pair>

#define MOUSEX MOUSEMOVE
#define MOUSEY ACTIONMOUSE

class SCA_IInputDevice
{
Expand Down
4 changes: 2 additions & 2 deletions source/gameengine/Launcher/LA_Launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void LA_Launcher::InitEngine()
// Setup python console keys used as shortcut.
for (unsigned short i = 0; i < 4; ++i) {
if (gm.pythonkeys[i] != EVENT_NONE) {
m_pythonConsole.keys.push_back(ConvertKeyCode(gm.pythonkeys[i]));
m_pythonConsole.keys.push_back(BL_ConvertKeyCode(gm.pythonkeys[i]));
}
}
m_pythonConsole.use = (gm.flag & GAME_PYTHON_CONSOLE);
Expand Down Expand Up @@ -249,7 +249,7 @@ void LA_Launcher::InitEngine()

DEV_Joystick::Init();

m_ketsjiEngine->SetExitKey(ConvertKeyCode(gm.exitkey));
m_ketsjiEngine->SetExitKey(BL_ConvertKeyCode(gm.exitkey));
#ifdef WITH_PYTHON
CValue::SetDeprecationWarnings(nodepwarnings);
#else
Expand Down
48 changes: 24 additions & 24 deletions source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2688,7 +2688,7 @@ CcdPhysicsEnvironment *CcdPhysicsEnvironment::Create(Scene *blenderscene, bool v
}

void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, KX_GameObject *gameobj, RAS_MeshObject *meshobj,
KX_Scene *kxscene, PHY_ShapeProps *shapeprops, PHY_IMotionState *motionstate,
KX_Scene *kxscene, const PHY_ShapeProps& shapeprops, PHY_IMotionState *motionstate,
int activeLayerBitInfo, bool isCompoundChild, bool hasCompoundChildren)
{
Object *blenderobject = gameobj->GetBlenderObject();
Expand Down Expand Up @@ -2736,15 +2736,15 @@ void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, K
((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_ROT_AXIS) != 0) ? 0.0f : 1.0f,
((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS) != 0) ? 0.0f : 1.0f);
ci.m_localInertiaTensor = btVector3(0.0f, 0.0f, 0.0f);
ci.m_mass = isbulletdyna ? shapeprops->m_mass : 0.0f;
ci.m_clamp_vel_min = shapeprops->m_clamp_vel_min;
ci.m_clamp_vel_max = shapeprops->m_clamp_vel_max;
ci.m_clamp_angvel_min = shapeprops->m_clamp_angvel_min;
ci.m_clamp_angvel_max = shapeprops->m_clamp_angvel_max;
ci.m_stepHeight = isbulletchar ? shapeprops->m_step_height : 0.0f;
ci.m_jumpSpeed = isbulletchar ? shapeprops->m_jump_speed : 0.0f;
ci.m_fallSpeed = isbulletchar ? shapeprops->m_fall_speed : 0.0f;
ci.m_maxJumps = isbulletchar ? shapeprops->m_max_jumps : 0;
ci.m_mass = isbulletdyna ? shapeprops.m_mass : 0.0f;
ci.m_clamp_vel_min = shapeprops.m_clamp_vel_min;
ci.m_clamp_vel_max = shapeprops.m_clamp_vel_max;
ci.m_clamp_angvel_min = shapeprops.m_clamp_angvel_min;
ci.m_clamp_angvel_max = shapeprops.m_clamp_angvel_max;
ci.m_stepHeight = isbulletchar ? shapeprops.m_step_height : 0.0f;
ci.m_jumpSpeed = isbulletchar ? shapeprops.m_jump_speed : 0.0f;
ci.m_fallSpeed = isbulletchar ? shapeprops.m_fall_speed : 0.0f;
ci.m_maxJumps = isbulletchar ? shapeprops.m_max_jumps : 0;

//mmm, for now, take this for the size of the dynamicobject
// Blender uses inertia for radius of dynamic object
Expand Down Expand Up @@ -3077,26 +3077,26 @@ void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, K

ci.m_collisionShape = bm;
ci.m_shapeInfo = shapeInfo;
ci.m_friction = shapeprops->m_friction;//tweak the friction a bit, so the default 0.5 works nice
ci.m_rollingFriction = shapeprops->m_rollingFriction;
ci.m_restitution = shapeprops->m_restitution;
ci.m_friction = shapeprops.m_friction;//tweak the friction a bit, so the default 0.5 works nice
ci.m_rollingFriction = shapeprops.m_rollingFriction;
ci.m_restitution = shapeprops.m_restitution;
ci.m_physicsEnv = this;
// drag / damping is inverted
ci.m_linearDamping = 1.0f - shapeprops->m_lin_drag;
ci.m_angularDamping = 1.0f - shapeprops->m_ang_drag;
ci.m_linearDamping = 1.0f - shapeprops.m_lin_drag;
ci.m_angularDamping = 1.0f - shapeprops.m_ang_drag;
//need a bit of damping, else system doesn't behave well
ci.m_inertiaFactor = shapeprops->m_inertia / 0.4f;//defaults to 0.4, don't want to change behavior
ci.m_inertiaFactor = shapeprops.m_inertia / 0.4f;//defaults to 0.4, don't want to change behavior

ci.m_do_anisotropic = shapeprops->m_do_anisotropic;
ci.m_anisotropicFriction = ToBullet(shapeprops->m_friction_scaling);
ci.m_do_anisotropic = shapeprops.m_do_anisotropic;
ci.m_anisotropicFriction = ToBullet(shapeprops.m_friction_scaling);

//do Fh, do Rot Fh
ci.m_do_fh = shapeprops->m_do_fh;
ci.m_do_rot_fh = shapeprops->m_do_rot_fh;
ci.m_fh_damping = shapeprops->m_fh_damping;
ci.m_fh_distance = shapeprops->m_fh_distance;
ci.m_fh_normal = shapeprops->m_fh_normal;
ci.m_fh_spring = shapeprops->m_fh_spring;
ci.m_do_fh = shapeprops.m_do_fh;
ci.m_do_rot_fh = shapeprops.m_do_rot_fh;
ci.m_fh_damping = shapeprops.m_fh_damping;
ci.m_fh_distance = shapeprops.m_fh_distance;
ci.m_fh_normal = shapeprops.m_fh_normal;
ci.m_fh_spring = shapeprops.m_fh_spring;

ci.m_collisionFilterGroup =
(isbulletsensor) ? short(CcdConstructionInfo::SensorFilter) :
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
KX_GameObject *gameobj,
RAS_MeshObject *meshobj,
KX_Scene *kxscene,
PHY_ShapeProps *shapeprops,
const PHY_ShapeProps& shapeprops,
PHY_IMotionState *motionstate,
int activeLayerBitInfo,
bool isCompoundChild,
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Physics/Common/PHY_IPhysicsEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class PHY_IPhysicsEnvironment
KX_GameObject *gameobj,
RAS_MeshObject *meshobj,
KX_Scene *kxscene,
PHY_ShapeProps *shapeprops,
const PHY_ShapeProps& shapeprops,
PHY_IMotionState *motionstate,
int activeLayerBitInfo,
bool isCompoundChild,
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class DummyPhysicsEnvironment : public PHY_IPhysicsEnvironment
KX_GameObject *gameobj,
RAS_MeshObject *meshobj,
KX_Scene *kxscene,
PHY_ShapeProps *shapeprops,
const PHY_ShapeProps& shapeprops,
PHY_IMotionState *motionstate,
int activeLayerBitInfo,
bool isCompoundChild,
Expand Down

0 comments on commit f6114dc

Please sign in to comment.