Skip to content

Commit

Permalink
UPBGE: Cleanup prefix in Converter/.
Browse files Browse the repository at this point in the history
Previously two prefixes were used in Converter/ part, BL_ and KX_.
But some classes using KX_ prefix needed the other prefix because
they heavilly manipulate blender data for operation like conversion
or library loading.
In consideration all the classes in Convert/ who used the prefix KX_
excepted for KX_SoftBodyDeformer and KX_LibLoadStatus change to BL_
prefix. The two exception are moved into Ketsji/ part.
  • Loading branch information
panzergame committed Aug 23, 2017
1 parent a18be87 commit a01ec70
Show file tree
Hide file tree
Showing 41 changed files with 172 additions and 172 deletions.
4 changes: 2 additions & 2 deletions source/gameengine/Converter/BL_ArmatureObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" {
#include "BL_ArmatureObject.h"
#include "BL_ActionActuator.h"
#include "BL_Action.h"
#include "KX_BlenderSceneConverter.h"
#include "BL_BlenderSceneConverter.h"
#include "KX_Globals.h"
#include "KX_KetsjiEngine.h"

Expand Down Expand Up @@ -244,7 +244,7 @@ BL_ArmatureObject::~BL_ArmatureObject()
}
}

void BL_ArmatureObject::LoadConstraints(KX_BlenderSceneConverter& converter)
void BL_ArmatureObject::LoadConstraints(BL_BlenderSceneConverter& converter)
{
// first delete any existing constraint (should not have any)
m_controlledConstraints->ReleaseAndRemoveAll();
Expand Down
4 changes: 2 additions & 2 deletions source/gameengine/Converter/BL_ArmatureObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct bPose;
struct bConstraint;
struct Object;
class MT_Matrix4x4;
class KX_BlenderSceneConverter;
class BL_BlenderSceneConverter;
class RAS_DebugDraw;

class BL_ArmatureObject : public KX_GameObject
Expand Down Expand Up @@ -111,7 +111,7 @@ class BL_ArmatureObject : public KX_GameObject
void DrawDebug(RAS_DebugDraw& debugDraw);

// for constraint python API
void LoadConstraints(KX_BlenderSceneConverter& converter);
void LoadConstraints(BL_BlenderSceneConverter& converter);
size_t GetConstraintNumber() const;
BL_ArmatureConstraint *GetConstraint(const std::string& posechannel, const std::string& constraint);
BL_ArmatureConstraint *GetConstraint(const std::string& posechannelconstraint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ***** END GPL LICENSE BLOCK *****
*/

/** \file gameengine/Converter/KX_BlenderConverter.cpp
/** \file gameengine/Converter/BL_BlenderConverter.cpp
* \ingroup bgeconv
*/

Expand All @@ -42,9 +42,9 @@
#include "KX_KetsjiEngine.h"
#include "KX_PythonInit.h" // So we can handle adding new text datablocks for Python to import
#include "KX_LibLoadStatus.h"
#include "KX_BlenderScalarInterpolator.h"
#include "KX_BlenderConverter.h"
#include "KX_BlenderSceneConverter.h"
#include "BL_BlenderScalarInterpolator.h"
#include "BL_BlenderConverter.h"
#include "BL_BlenderSceneConverter.h"
#include "BL_BlenderDataConversion.h"
#include "BL_ActionActuator.h"
#include "KX_BlenderMaterial.h"
Expand Down Expand Up @@ -86,16 +86,16 @@ extern "C" {

#include <cstring>

KX_BlenderConverter::SceneSlot::SceneSlot() = default;
BL_BlenderConverter::SceneSlot::SceneSlot() = default;

KX_BlenderConverter::SceneSlot::SceneSlot(const KX_BlenderSceneConverter& converter)
BL_BlenderConverter::SceneSlot::SceneSlot(const BL_BlenderSceneConverter& converter)
{
Merge(converter);
}

KX_BlenderConverter::SceneSlot::~SceneSlot() = default;
BL_BlenderConverter::SceneSlot::~SceneSlot() = default;

void KX_BlenderConverter::SceneSlot::Merge(KX_BlenderConverter::SceneSlot& other)
void BL_BlenderConverter::SceneSlot::Merge(BL_BlenderConverter::SceneSlot& other)
{
m_interpolators.insert(m_interpolators.begin(),
std::make_move_iterator(other.m_interpolators.begin()),
Expand All @@ -109,7 +109,7 @@ void KX_BlenderConverter::SceneSlot::Merge(KX_BlenderConverter::SceneSlot& other
m_actionToInterp.insert(other.m_actionToInterp.begin(), other.m_actionToInterp.end());
}

void KX_BlenderConverter::SceneSlot::Merge(const KX_BlenderSceneConverter& converter)
void BL_BlenderConverter::SceneSlot::Merge(const BL_BlenderSceneConverter& converter)
{
for (KX_BlenderMaterial *mat : converter.m_materials) {
m_materials.emplace_back(mat);
Expand All @@ -119,7 +119,7 @@ void KX_BlenderConverter::SceneSlot::Merge(const KX_BlenderSceneConverter& conve
}
}

KX_BlenderConverter::KX_BlenderConverter(Main *maggie, KX_KetsjiEngine *engine)
BL_BlenderConverter::BL_BlenderConverter(Main *maggie, KX_KetsjiEngine *engine)
:m_maggie(maggie),
m_ketsjiEngine(engine),
m_alwaysUseExpandFraming(false)
Expand All @@ -128,7 +128,7 @@ KX_BlenderConverter::KX_BlenderConverter(Main *maggie, KX_KetsjiEngine *engine)
m_threadinfo.m_pool = BLI_task_pool_create(engine->GetTaskScheduler(), nullptr);
}

KX_BlenderConverter::~KX_BlenderConverter()
BL_BlenderConverter::~BL_BlenderConverter()
{
// free any data that was dynamically loaded
while (m_DynamicMaggie.size() != 0) {
Expand All @@ -143,7 +143,7 @@ KX_BlenderConverter::~KX_BlenderConverter()
BLI_task_pool_free(m_threadinfo.m_pool);
}

Scene *KX_BlenderConverter::GetBlenderSceneForName(const std::string &name)
Scene *BL_BlenderConverter::GetBlenderSceneForName(const std::string &name)
{
Scene *sce;

Expand All @@ -161,7 +161,7 @@ Scene *KX_BlenderConverter::GetBlenderSceneForName(const std::string &name)
return nullptr;
}

CListValue<CStringValue> *KX_BlenderConverter::GetInactiveSceneNames()
CListValue<CStringValue> *BL_BlenderConverter::GetInactiveSceneNames()
{
CListValue<CStringValue> *list = new CListValue<CStringValue>();

Expand All @@ -177,7 +177,7 @@ CListValue<CStringValue> *KX_BlenderConverter::GetInactiveSceneNames()
return list;
}

void KX_BlenderConverter::ConvertScene(KX_Scene *destinationscene, RAS_Rasterizer *rasty, RAS_ICanvas *canvas, bool libloading)
void BL_BlenderConverter::ConvertScene(KX_Scene *destinationscene, RAS_Rasterizer *rasty, RAS_ICanvas *canvas, bool libloading)
{

// Find out which physics engine
Expand Down Expand Up @@ -216,7 +216,7 @@ void KX_BlenderConverter::ConvertScene(KX_Scene *destinationscene, RAS_Rasterize

destinationscene->SetPhysicsEnvironment(phy_env);

KX_BlenderSceneConverter sceneConverter;
BL_BlenderSceneConverter sceneConverter;

BL_ConvertBlenderObjects(
m_maggie,
Expand All @@ -237,9 +237,9 @@ void KX_BlenderConverter::ConvertScene(KX_Scene *destinationscene, RAS_Rasterize
* Note that there was some provision for sharing entities (meshes...) between
* scenes but that is now disabled so all scene will have their own copy
* and we can delete them here. If the sharing is reactivated, change this code too..
* (see KX_BlenderConverter::ConvertScene)
* (see BL_BlenderConverter::ConvertScene)
*/
void KX_BlenderConverter::RemoveScene(KX_Scene *scene)
void BL_BlenderConverter::RemoveScene(KX_Scene *scene)
{
KX_WorldInfo *world = scene->GetWorldInfo();
if (world) {
Expand All @@ -263,24 +263,24 @@ void KX_BlenderConverter::RemoveScene(KX_Scene *scene)
m_sceneSlots.erase(scene);
}

void KX_BlenderConverter::SetAlwaysUseExpandFraming(bool to_what)
void BL_BlenderConverter::SetAlwaysUseExpandFraming(bool to_what)
{
m_alwaysUseExpandFraming = to_what;
}

void KX_BlenderConverter::RegisterInterpolatorList(KX_Scene *scene, BL_InterpolatorList *interpolator, bAction *for_act)
void BL_BlenderConverter::RegisterInterpolatorList(KX_Scene *scene, BL_InterpolatorList *interpolator, bAction *for_act)
{
SceneSlot& sceneSlot = m_sceneSlots[scene];
sceneSlot.m_interpolators.emplace_back(interpolator);
sceneSlot.m_actionToInterp[for_act] = interpolator;
}

BL_InterpolatorList *KX_BlenderConverter::FindInterpolatorList(KX_Scene *scene, bAction *for_act)
BL_InterpolatorList *BL_BlenderConverter::FindInterpolatorList(KX_Scene *scene, bAction *for_act)
{
return m_sceneSlots[scene].m_actionToInterp[for_act];
}

Main *KX_BlenderConverter::CreateMainDynamic(const std::string& path)
Main *BL_BlenderConverter::CreateMainDynamic(const std::string& path)
{
Main *maggie = BKE_main_new();
strncpy(maggie->name, path.c_str(), sizeof(maggie->name) - 1);
Expand All @@ -289,12 +289,12 @@ Main *KX_BlenderConverter::CreateMainDynamic(const std::string& path)
return maggie;
}

const std::vector<Main *> &KX_BlenderConverter::GetMainDynamic() const
const std::vector<Main *> &BL_BlenderConverter::GetMainDynamic() const
{
return m_DynamicMaggie;
}

Main *KX_BlenderConverter::GetMainDynamicPath(const std::string& path) const
Main *BL_BlenderConverter::GetMainDynamicPath(const std::string& path) const
{
for (Main *maggie : m_DynamicMaggie) {
if (BLI_path_cmp(maggie->name, path.c_str()) == 0) {
Expand All @@ -305,7 +305,7 @@ Main *KX_BlenderConverter::GetMainDynamicPath(const std::string& path) const
return nullptr;
}

void KX_BlenderConverter::MergeAsyncLoads()
void BL_BlenderConverter::MergeAsyncLoads()
{
std::vector<KX_Scene *> *merge_scenes;

Expand Down Expand Up @@ -333,15 +333,15 @@ void KX_BlenderConverter::MergeAsyncLoads()
m_threadinfo.m_mutex.Unlock();
}

void KX_BlenderConverter::FinalizeAsyncLoads()
void BL_BlenderConverter::FinalizeAsyncLoads()
{
// Finish all loading libraries.
BLI_task_pool_work_and_wait(m_threadinfo.m_pool);
// Merge all libraries data in the current scene, to avoid memory leak of unmerged scenes.
MergeAsyncLoads();
}

void KX_BlenderConverter::AddScenesToMergeQueue(KX_LibLoadStatus *status)
void BL_BlenderConverter::AddScenesToMergeQueue(KX_LibLoadStatus *status)
{
m_threadinfo.m_mutex.Lock();
m_mergequeue.push_back(status);
Expand Down Expand Up @@ -371,15 +371,15 @@ static void async_convert(TaskPool *pool, void *ptr, int UNUSED(threadid))
status->GetConverter()->AddScenesToMergeQueue(status);
}

KX_LibLoadStatus *KX_BlenderConverter::LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options)
KX_LibLoadStatus *BL_BlenderConverter::LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options)
{
BlendHandle *bpy_openlib = BLO_blendhandle_from_memory(data, length);

// Error checking is done in LinkBlendFile
return LinkBlendFile(bpy_openlib, path, group, scene_merge, err_str, options);
}

KX_LibLoadStatus *KX_BlenderConverter::LinkBlendFilePath(const char *filepath, char *group, KX_Scene *scene_merge, char **err_str, short options)
KX_LibLoadStatus *BL_BlenderConverter::LinkBlendFilePath(const char *filepath, char *group, KX_Scene *scene_merge, char **err_str, short options)
{
BlendHandle *bpy_openlib = BLO_blendhandle_from_file(filepath, nullptr);

Expand All @@ -404,7 +404,7 @@ static void load_datablocks(Main *main_tmp, BlendHandle *bpy_openlib, const char
BLI_linklist_free(names, free); // free linklist *and* each node's data
}

KX_LibLoadStatus *KX_BlenderConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options)
KX_LibLoadStatus *BL_BlenderConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options)
{
Main *main_newlib; // stored as a dynamic 'main' until we free it
const int idcode = BKE_idcode_from_name(group);
Expand Down Expand Up @@ -470,7 +470,7 @@ KX_LibLoadStatus *KX_BlenderConverter::LinkBlendFile(BlendHandle *bpy_openlib, c
// Convert all new meshes into BGE meshes
ID *mesh;

KX_BlenderSceneConverter sceneConverter;
BL_BlenderSceneConverter sceneConverter;
for (mesh = (ID *)main_newlib->mesh.first; mesh; mesh = (ID *)mesh->next) {
if (options & LIB_LOAD_VERBOSE) {
CM_Debug("mesh name: " << mesh->name + 2);
Expand Down Expand Up @@ -550,7 +550,7 @@ KX_LibLoadStatus *KX_BlenderConverter::LinkBlendFile(BlendHandle *bpy_openlib, c

/** Note m_map_*** are all ok and don't need to be freed
* most are temp and NewRemoveObject frees m_map_gameobject_to_blender */
bool KX_BlenderConverter::FreeBlendFile(Main *maggie)
bool BL_BlenderConverter::FreeBlendFile(Main *maggie)
{
if (maggie == nullptr) {
return false;
Expand Down Expand Up @@ -730,12 +730,12 @@ bool KX_BlenderConverter::FreeBlendFile(Main *maggie)
return true;
}

bool KX_BlenderConverter::FreeBlendFile(const std::string& path)
bool BL_BlenderConverter::FreeBlendFile(const std::string& path)
{
return FreeBlendFile(GetMainDynamicPath(path));
}

void KX_BlenderConverter::MergeScene(KX_Scene *to, KX_Scene *from)
void BL_BlenderConverter::MergeScene(KX_Scene *to, KX_Scene *from)
{
SceneSlot& sceneSlotFrom = m_sceneSlots[from];

Expand All @@ -757,7 +757,7 @@ void KX_BlenderConverter::MergeScene(KX_Scene *to, KX_Scene *from)

/** This function merges a mesh from the current scene into another main
* it does not convert */
RAS_MeshObject *KX_BlenderConverter::ConvertMeshSpecial(KX_Scene *kx_scene, Main *maggie, const std::string& name)
RAS_MeshObject *BL_BlenderConverter::ConvertMeshSpecial(KX_Scene *kx_scene, Main *maggie, const std::string& name)
{
// Find a mesh in the current main */
ID *me = static_cast<ID *>(BLI_findstring(&m_maggie->mesh, name.c_str(), offsetof(ID, name) + 2));
Expand Down Expand Up @@ -830,7 +830,7 @@ RAS_MeshObject *KX_BlenderConverter::ConvertMeshSpecial(KX_Scene *kx_scene, Main
}
}

KX_BlenderSceneConverter sceneConverter;
BL_BlenderSceneConverter sceneConverter;

RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)me, nullptr, kx_scene, sceneConverter, false);
kx_scene->GetLogicManager()->RegisterMeshName(meshobj->GetName(), meshobj);
Expand All @@ -840,7 +840,7 @@ RAS_MeshObject *KX_BlenderConverter::ConvertMeshSpecial(KX_Scene *kx_scene, Main
return meshobj;
}

void KX_BlenderConverter::PrintStats()
void BL_BlenderConverter::PrintStats()
{
CM_Message("BGE STATS");
CM_Message(std::endl << "Assets:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ***** END GPL LICENSE BLOCK *****
*/

/** \file KX_BlenderConverter.h
/** \file BL_BlenderConverter.h
* \ingroup bgeconv
*/

Expand All @@ -39,13 +39,13 @@
# include "KX_BlenderMaterial.h"
# include "RAS_MeshObject.h"

# include "KX_BlenderScalarInterpolator.h"
# include "BL_BlenderScalarInterpolator.h"
#endif

#include "CM_Thread.h"

class CStringValue;
class KX_BlenderSceneConverter;
class BL_BlenderSceneConverter;
class KX_KetsjiEngine;
class KX_LibLoadStatus;
class KX_BlenderMaterial;
Expand All @@ -67,7 +67,7 @@ struct TaskPool;
template<class Value>
using UniquePtrList = std::vector<std::unique_ptr<Value> >;

class KX_BlenderConverter
class BL_BlenderConverter
{
private:
class SceneSlot
Expand All @@ -80,11 +80,11 @@ class KX_BlenderConverter
std::map<bAction *, BL_InterpolatorList *> m_actionToInterp;

SceneSlot();
SceneSlot(const KX_BlenderSceneConverter& converter);
SceneSlot(const BL_BlenderSceneConverter& converter);
~SceneSlot();

void Merge(SceneSlot& other);
void Merge(const KX_BlenderSceneConverter& converter);
void Merge(const BL_BlenderSceneConverter& converter);
};

std::map<KX_Scene *, SceneSlot> m_sceneSlots;
Expand All @@ -105,8 +105,8 @@ class KX_BlenderConverter
bool m_alwaysUseExpandFraming;

public:
KX_BlenderConverter(Main *maggie, KX_KetsjiEngine *engine);
virtual ~KX_BlenderConverter();
BL_BlenderConverter(Main *maggie, KX_KetsjiEngine *engine);
virtual ~BL_BlenderConverter();

/** \param Scenename name of the scene to be converted.
* \param destinationscene pass an empty scene, everything goes into this
Expand Down
Loading

0 comments on commit a01ec70

Please sign in to comment.