Skip to content

Commit f6114dc

Browse files
committed
UPBGE: Cleanup BL_BlenderDataConversion.[cpp/h].
This cleanup contains: - uncrusity pass - remove extra class/struct keyword - remove pre definition of variable - clean comments
1 parent afabe80 commit f6114dc

File tree

9 files changed

+744
-850
lines changed

9 files changed

+744
-850
lines changed

source/gameengine/Converter/BL_BlenderDataConversion.cpp

Lines changed: 701 additions & 795 deletions
Large diffs are not rendered by default.

source/gameengine/Converter/BL_BlenderDataConversion.h

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,17 @@
3636
#include "KX_PhysicsEngineEnums.h"
3737
#include "SCA_IInputDevice.h"
3838

39-
struct Material;
40-
struct Mesh;
41-
struct DerivedMesh;
42-
struct Object;
43-
struct Main;
4439
class RAS_Rasterizer;
4540
class RAS_ICanvas;
4641
class KX_KetsjiEngine;
4742
class KX_Scene;
4843
class BL_BlenderSceneConverter;
44+
struct Mesh;
45+
struct DerivedMesh;
46+
struct Object;
47+
struct Main;
4948

50-
struct BL_MeshMaterial
51-
{
49+
struct BL_MeshMaterial {
5250
RAS_IDisplayArray *array;
5351
RAS_MaterialBucket *bucket;
5452
bool visible;
@@ -59,18 +57,12 @@ struct BL_MeshMaterial
5957

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

64-
void BL_ConvertBlenderObjects(Main *maggie,
65-
KX_Scene *kxscene,
66-
KX_KetsjiEngine *ketsjiEngine,
67-
e_PhysicsEngine physics_engine,
68-
RAS_Rasterizer *rendertools,
69-
RAS_ICanvas *canvas,
70-
BL_BlenderSceneConverter& sceneconverter,
71-
bool alwaysUseExpandFraming,
72-
bool libloading=false);
62+
void BL_ConvertBlenderObjects(Main *maggie, KX_Scene *kxscene, KX_KetsjiEngine *ketsjiEngine, e_PhysicsEngine physics_engine,
63+
RAS_Rasterizer *rendertools, RAS_ICanvas *canvas, BL_BlenderSceneConverter& sceneconverter,
64+
bool alwaysUseExpandFraming, bool libloading);
7365

74-
SCA_IInputDevice::SCA_EnumInputs ConvertKeyCode(int key_code);
66+
SCA_IInputDevice::SCA_EnumInputs BL_ConvertKeyCode(int key_code);
7567

76-
#endif /* __BL_BLENDERDATACONVERSION_H__ */
68+
#endif // __BL_BLENDERDATACONVERSION_H__

source/gameengine/Converter/BL_ConvertSensors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ void BL_ConvertSensors(struct Object* blenderobject,
255255
if (eventmgr)
256256
{
257257
gamesensor = new SCA_KeyboardSensor(eventmgr,
258-
ConvertKeyCode(blenderkeybdsensor->key),
259-
ConvertKeyCode(blenderkeybdsensor->qual),
260-
ConvertKeyCode(blenderkeybdsensor->qual2),
258+
BL_ConvertKeyCode(blenderkeybdsensor->key),
259+
BL_ConvertKeyCode(blenderkeybdsensor->qual),
260+
BL_ConvertKeyCode(blenderkeybdsensor->qual2),
261261
(blenderkeybdsensor->type == SENS_ALL_KEYS),
262262
blenderkeybdsensor->targetName,
263263
blenderkeybdsensor->toggleName,

source/gameengine/GameLogic/SCA_IInputDevice.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
#include "SCA_InputEvent.h"
3636

3737
#include <map>
38-
// #include <pair>
39-
40-
#define MOUSEX MOUSEMOVE
41-
#define MOUSEY ACTIONMOUSE
4238

4339
class SCA_IInputDevice
4440
{

source/gameengine/Launcher/LA_Launcher.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void LA_Launcher::InitEngine()
166166
// Setup python console keys used as shortcut.
167167
for (unsigned short i = 0; i < 4; ++i) {
168168
if (gm.pythonkeys[i] != EVENT_NONE) {
169-
m_pythonConsole.keys.push_back(ConvertKeyCode(gm.pythonkeys[i]));
169+
m_pythonConsole.keys.push_back(BL_ConvertKeyCode(gm.pythonkeys[i]));
170170
}
171171
}
172172
m_pythonConsole.use = (gm.flag & GAME_PYTHON_CONSOLE);
@@ -249,7 +249,7 @@ void LA_Launcher::InitEngine()
249249

250250
DEV_Joystick::Init();
251251

252-
m_ketsjiEngine->SetExitKey(ConvertKeyCode(gm.exitkey));
252+
m_ketsjiEngine->SetExitKey(BL_ConvertKeyCode(gm.exitkey));
253253
#ifdef WITH_PYTHON
254254
CValue::SetDeprecationWarnings(nodepwarnings);
255255
#else

source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,7 +2688,7 @@ CcdPhysicsEnvironment *CcdPhysicsEnvironment::Create(Scene *blenderscene, bool v
26882688
}
26892689

26902690
void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, KX_GameObject *gameobj, RAS_MeshObject *meshobj,
2691-
KX_Scene *kxscene, PHY_ShapeProps *shapeprops, PHY_IMotionState *motionstate,
2691+
KX_Scene *kxscene, const PHY_ShapeProps& shapeprops, PHY_IMotionState *motionstate,
26922692
int activeLayerBitInfo, bool isCompoundChild, bool hasCompoundChildren)
26932693
{
26942694
Object *blenderobject = gameobj->GetBlenderObject();
@@ -2736,15 +2736,15 @@ void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, K
27362736
((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Y_ROT_AXIS) != 0) ? 0.0f : 1.0f,
27372737
((blenderobject->gameflag2 & OB_LOCK_RIGID_BODY_Z_ROT_AXIS) != 0) ? 0.0f : 1.0f);
27382738
ci.m_localInertiaTensor = btVector3(0.0f, 0.0f, 0.0f);
2739-
ci.m_mass = isbulletdyna ? shapeprops->m_mass : 0.0f;
2740-
ci.m_clamp_vel_min = shapeprops->m_clamp_vel_min;
2741-
ci.m_clamp_vel_max = shapeprops->m_clamp_vel_max;
2742-
ci.m_clamp_angvel_min = shapeprops->m_clamp_angvel_min;
2743-
ci.m_clamp_angvel_max = shapeprops->m_clamp_angvel_max;
2744-
ci.m_stepHeight = isbulletchar ? shapeprops->m_step_height : 0.0f;
2745-
ci.m_jumpSpeed = isbulletchar ? shapeprops->m_jump_speed : 0.0f;
2746-
ci.m_fallSpeed = isbulletchar ? shapeprops->m_fall_speed : 0.0f;
2747-
ci.m_maxJumps = isbulletchar ? shapeprops->m_max_jumps : 0;
2739+
ci.m_mass = isbulletdyna ? shapeprops.m_mass : 0.0f;
2740+
ci.m_clamp_vel_min = shapeprops.m_clamp_vel_min;
2741+
ci.m_clamp_vel_max = shapeprops.m_clamp_vel_max;
2742+
ci.m_clamp_angvel_min = shapeprops.m_clamp_angvel_min;
2743+
ci.m_clamp_angvel_max = shapeprops.m_clamp_angvel_max;
2744+
ci.m_stepHeight = isbulletchar ? shapeprops.m_step_height : 0.0f;
2745+
ci.m_jumpSpeed = isbulletchar ? shapeprops.m_jump_speed : 0.0f;
2746+
ci.m_fallSpeed = isbulletchar ? shapeprops.m_fall_speed : 0.0f;
2747+
ci.m_maxJumps = isbulletchar ? shapeprops.m_max_jumps : 0;
27482748

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

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

3090-
ci.m_do_anisotropic = shapeprops->m_do_anisotropic;
3091-
ci.m_anisotropicFriction = ToBullet(shapeprops->m_friction_scaling);
3090+
ci.m_do_anisotropic = shapeprops.m_do_anisotropic;
3091+
ci.m_anisotropicFriction = ToBullet(shapeprops.m_friction_scaling);
30923092

30933093
//do Fh, do Rot Fh
3094-
ci.m_do_fh = shapeprops->m_do_fh;
3095-
ci.m_do_rot_fh = shapeprops->m_do_rot_fh;
3096-
ci.m_fh_damping = shapeprops->m_fh_damping;
3097-
ci.m_fh_distance = shapeprops->m_fh_distance;
3098-
ci.m_fh_normal = shapeprops->m_fh_normal;
3099-
ci.m_fh_spring = shapeprops->m_fh_spring;
3094+
ci.m_do_fh = shapeprops.m_do_fh;
3095+
ci.m_do_rot_fh = shapeprops.m_do_rot_fh;
3096+
ci.m_fh_damping = shapeprops.m_fh_damping;
3097+
ci.m_fh_distance = shapeprops.m_fh_distance;
3098+
ci.m_fh_normal = shapeprops.m_fh_normal;
3099+
ci.m_fh_spring = shapeprops.m_fh_spring;
31003100

31013101
ci.m_collisionFilterGroup =
31023102
(isbulletsensor) ? short(CcdConstructionInfo::SensorFilter) :

source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
258258
KX_GameObject *gameobj,
259259
RAS_MeshObject *meshobj,
260260
KX_Scene *kxscene,
261-
PHY_ShapeProps *shapeprops,
261+
const PHY_ShapeProps& shapeprops,
262262
PHY_IMotionState *motionstate,
263263
int activeLayerBitInfo,
264264
bool isCompoundChild,

source/gameengine/Physics/Common/PHY_IPhysicsEnvironment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class PHY_IPhysicsEnvironment
232232
KX_GameObject *gameobj,
233233
RAS_MeshObject *meshobj,
234234
KX_Scene *kxscene,
235-
PHY_ShapeProps *shapeprops,
235+
const PHY_ShapeProps& shapeprops,
236236
PHY_IMotionState *motionstate,
237237
int activeLayerBitInfo,
238238
bool isCompoundChild,

source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class DummyPhysicsEnvironment : public PHY_IPhysicsEnvironment
122122
KX_GameObject *gameobj,
123123
RAS_MeshObject *meshobj,
124124
KX_Scene *kxscene,
125-
PHY_ShapeProps *shapeprops,
125+
const PHY_ShapeProps& shapeprops,
126126
PHY_IMotionState *motionstate,
127127
int activeLayerBitInfo,
128128
bool isCompoundChild,

0 commit comments

Comments
 (0)