From e250de4c0c6881e07d17c3ee2e788a3646d77f35 Mon Sep 17 00:00:00 2001 From: youle31 Date: Thu, 13 Feb 2025 19:13:19 +0100 Subject: [PATCH] UPBGE: Remove boost dependancy after libs update boost was removed in last libs update https://projects.blender.org/blender/blender/commit/e94d92593e238d0ac0250fc4dda554e1c72a87b6 I hope i didn't do mistakes --- .../Converter/BL_DataConversion.cpp | 27 +++++++------------ source/gameengine/Converter/CMakeLists.txt | 1 + source/gameengine/Expressions/CMakeLists.txt | 1 + .../Expressions/intern/InputParser.cpp | 22 +++++++-------- .../Expressions/intern/IntValue.cpp | 4 +-- .../GameLogic/SCA_PropertySensor.cpp | 5 ++-- source/gameengine/Ketsji/BL_Shader.cpp | 8 +++--- source/gameengine/Ketsji/CMakeLists.txt | 1 + source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 8 +++--- source/gameengine/Ketsji/KX_PythonProxy.cpp | 6 ++--- source/gameengine/Ketsji/KX_VertexProxy.cpp | 6 ++--- 11 files changed, 41 insertions(+), 48 deletions(-) diff --git a/source/gameengine/Converter/BL_DataConversion.cpp b/source/gameengine/Converter/BL_DataConversion.cpp index 559e53704d71..3938d1492f3c 100644 --- a/source/gameengine/Converter/BL_DataConversion.cpp +++ b/source/gameengine/Converter/BL_DataConversion.cpp @@ -51,6 +51,8 @@ #include "BL_DataConversion.h" +#include + /* This little block needed for linking to Blender... */ #ifdef WIN32 # include "BLI_winstuff.h" @@ -105,8 +107,6 @@ # include "CcdPhysicsEnvironment.h" #endif -#include - using namespace blender; using namespace blender::bke; @@ -739,7 +739,7 @@ static KX_GameObject *BL_gameobject_from_customobject(Object *ob, bool valid = false; if (mod == NULL) { - std::string msg = (boost::format("Failed to import the module '%s'") % pp->module).str(); + std::string msg = fmt::format("Failed to import the module {}", pp->module); kxscene->LogError(msg); } else { @@ -747,15 +747,11 @@ static KX_GameObject *BL_gameobject_from_customobject(Object *ob, cls = PyObject_GetAttrString(mod, pp->name); if (cls == NULL) { - std::string msg = (boost::format("Python module found, but failed to find the object '%s'") % - pp->name) - .str(); + std::string msg = fmt::format("Python module found, but failed to find the object {}", pp->name); kxscene->LogError(msg); } else if (!PyType_Check(cls) || !PyObject_IsSubclass(cls, (PyObject *)type)) { - std::string msg = (boost::format("%s.%s is not a subclass of %s") % pp->name % pp->name % - type->tp_name) - .str(); + std::string msg = fmt::format("{}.{} is not a subclass of {}", pp->name, pp->name, type->tp_name); kxscene->LogError(msg); } else { @@ -771,7 +767,7 @@ static KX_GameObject *BL_gameobject_from_customobject(Object *ob, if (PyErr_Occurred()) { // The component is invalid, drop it - std::string msg = (boost::format("Failed to instantiate the class '%s'") % pp->name).str(); + std::string msg = fmt::format("Failed to instantiate the class {}", pp->name); kxscene->LogError(msg); } else { @@ -1035,7 +1031,7 @@ static void BL_ConvertComponentsObject(KX_GameObject *gameobj, Object *blenderob mod = PyImport_ImportModule(pp->module); if (mod == NULL) { - std::string msg = (boost::format("Failed to import the module '%s'") % pp->module).str(); + std::string msg = fmt::format("Failed to import the module {}", pp->module); gameobj->LogError(msg); pp = pp->next; @@ -1046,8 +1042,7 @@ static void BL_ConvertComponentsObject(KX_GameObject *gameobj, Object *blenderob cls = PyObject_GetAttrString(mod, pp->name); if (cls == NULL) { std::string msg = - (boost::format("Python module found, but failed to find the component '%s'") % pp->name) - .str(); + fmt::format("Python module found, but failed to find the component {}", pp->name); gameobj->LogError(msg); pp = pp->next; @@ -1056,9 +1051,7 @@ static void BL_ConvertComponentsObject(KX_GameObject *gameobj, Object *blenderob // Lastly make sure we have a class and it's an appropriate sub type if (!PyType_Check(cls) || !PyObject_IsSubclass(cls, (PyObject *)&KX_PythonComponent::Type)) { - std::string msg = (boost::format("%s.%s is not a KX_PythonComponent subclass") % pp->module % - pp->name) - .str(); + std::string msg = fmt::format("{}.{} is not a KX_PythonComponent subclass", pp->module, pp->name); gameobj->LogError(msg); @@ -1072,7 +1065,7 @@ static void BL_ConvertComponentsObject(KX_GameObject *gameobj, Object *blenderob pycomp = PyObject_Call(cls, args, NULL); if (PyErr_Occurred()) { - std::string msg = (boost::format("Failed to instantiate the class '%s'") % pp->name).str(); + std::string msg = fmt::format("Failed to instantiate the class {}", pp->name); gameobj->LogError(msg); } else { diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index db092974fd11..ced9600e5cd0 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -96,6 +96,7 @@ set(LIB PRIVATE bf::depsgraph PRIVATE bf::draw PRIVATE bf::dna + PRIVATE bf::extern::fmtlib PRIVATE bf::gpu PRIVATE bf::imbuf PRIVATE bf::intern::guardedalloc diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt index 7e28a17269e7..da8c3006decd 100644 --- a/source/gameengine/Expressions/CMakeLists.txt +++ b/source/gameengine/Expressions/CMakeLists.txt @@ -76,6 +76,7 @@ set(SRC set(LIB PRIVATE bf::blenlib + PRIVATE bf::extern::fmtlib PRIVATE bf::intern::guardedalloc ) diff --git a/source/gameengine/Expressions/intern/InputParser.cpp b/source/gameengine/Expressions/intern/InputParser.cpp index 6236204e626f..65ffd03a3732 100644 --- a/source/gameengine/Expressions/intern/InputParser.cpp +++ b/source/gameengine/Expressions/intern/InputParser.cpp @@ -17,8 +17,7 @@ #include "EXP_InputParser.h" -#include -#include +#include #include "CM_Message.h" #include "EXP_BoolValue.h" @@ -318,33 +317,34 @@ void EXP_Parser::NextSym() start = chcount; CharRep(); GrabString(start); - if (boost::iequals(const_as_string, "SUM")) { + if (strcasecmp(const_as_string.c_str(), "SUM") == 0) + { sym = sumsym; } - else if (boost::iequals(const_as_string, "NOT")) { + else if (strcasecmp(const_as_string.c_str(), "NOT") == 0) { sym = opsym; opkind = OPnot; } - else if (boost::iequals(const_as_string, "AND")) { + else if (strcasecmp(const_as_string.c_str(), "AND") == 0) { sym = opsym; opkind = OPand; } - else if (boost::iequals(const_as_string, "OR")) { + else if (strcasecmp(const_as_string.c_str(), "OR") == 0) { sym = opsym; opkind = OPor; } - else if (boost::iequals(const_as_string, "IF")) { + else if (strcasecmp(const_as_string.c_str(), "IF") == 0) { sym = ifsym; } - else if (boost::iequals(const_as_string, "WHOMADE")) { + else if (strcasecmp(const_as_string.c_str(), "WHOMADE") == 0) { sym = whocodedsym; } - else if (boost::iequals(const_as_string, "FALSE")) { + else if (strcasecmp(const_as_string.c_str(), "FALSE") == 0) { sym = constsym; constkind = booltype; boolvalue = false; } - else if (boost::iequals(const_as_string, "TRUE")) { + else if (strcasecmp(const_as_string.c_str(), "TRUE") == 0) { sym = constsym; constkind = booltype; boolvalue = true; @@ -354,7 +354,7 @@ void EXP_Parser::NextSym() } } else { - std::string str = (boost::format("Unexpected character '%c'") % ch).str(); + std::string str = fmt::format("Unexpected character {}", ch); NextCh(); ScanError(str); return; diff --git a/source/gameengine/Expressions/intern/IntValue.cpp b/source/gameengine/Expressions/intern/IntValue.cpp index 9d922f936955..18d489e9a348 100644 --- a/source/gameengine/Expressions/intern/IntValue.cpp +++ b/source/gameengine/Expressions/intern/IntValue.cpp @@ -17,7 +17,7 @@ #include "EXP_IntValue.h" -#include +#include #include "CM_Message.h" #include "EXP_BoolValue.h" @@ -270,7 +270,7 @@ int EXP_IntValue::GetValueType() std::string EXP_IntValue::GetText() { - return (boost::format("%lld") % m_int).str(); + return fmt::format("{}", m_int); } EXP_Value *EXP_IntValue::GetReplica() diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index e714418c6862..e94254bb1c69 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -34,8 +34,6 @@ #include "SCA_PropertySensor.h" -#include - #include "CM_Format.h" #include "EXP_FloatValue.h" @@ -127,7 +125,8 @@ bool SCA_PropertySensor::CheckPropertyCondition() // on the way here... if ((testprop == EXP_BoolValue::sTrueString) || (testprop == EXP_BoolValue::sFalseString)) { - boost::to_upper(m_checkpropval); + std::transform( + m_checkpropval.begin(), m_checkpropval.end(), m_checkpropval.begin(), ::toupper); } result = (testprop == m_checkpropval); diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 903a6bd566a6..18125a87c8c0 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -24,7 +24,7 @@ #include "BL_Shader.h" -#include +#include #include "CM_Message.h" #include "KX_GameObject.h" @@ -59,9 +59,9 @@ std::string BL_Shader::GetName() std::string BL_Shader::GetText() { - return (boost::format("BL_Shader\n\tvertex shader:%s\n\n\tfragment shader%s\n\n") % - m_progs[VERTEX_PROGRAM] % m_progs[FRAGMENT_PROGRAM]) - .str(); + return fmt::format("BL_Shader\n\tvertex shader:{}\n\n\tfragment shader{}\n\n", + m_progs[VERTEX_PROGRAM], + m_progs[FRAGMENT_PROGRAM]); } #ifdef WITH_PYTHON diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index d74b239be62e..e1401f5acce0 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -178,6 +178,7 @@ set(LIB PRIVATE bf::depsgraph PRIVATE bf::dna PRIVATE bf::draw + PRIVATE bf::extern::fmtlib PRIVATE bf::gpu PRIVATE bf::imbuf PRIVATE bf::intern::clog diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 171a41c997f6..10a1e97aea93 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -36,7 +36,7 @@ #include "KX_KetsjiEngine.h" -#include +#include #include "BKE_context.hh" #include "BLI_rect.h" @@ -1285,7 +1285,7 @@ void KX_KetsjiEngine::RenderDebugProperties() if (m_flags & SHOW_FRAMERATE) { debugDraw.RenderText2D("Frametime:", MT_Vector2(xcoord + const_xindent, ycoord), white); - debugtxt = (boost::format("%5.2fms (%.1ffps)") % (tottime * 1000.0f) % (1.0f / tottime)).str(); + debugtxt = fmt::format("{:>5.2f}ms ({:.1f}fps)", (tottime * 1000.0f), (1.0f / tottime)); debugDraw.RenderText2D( debugtxt, MT_Vector2(xcoord + const_xindent + profile_indent, ycoord), white); // Increase the indent by default increase @@ -1300,9 +1300,7 @@ void KX_KetsjiEngine::RenderDebugProperties() double time = m_logger.GetAverage((KX_TimeCategory)j); - debugtxt = (boost::format("%5.2fms | %d%%") % (time * 1000.f) % - (int)(time / tottime * 100.f)) - .str(); + debugtxt = fmt::format("{:>5.2f}ms | {}%", (time * 1000.f), (int)(time / tottime * 100.f)); debugDraw.RenderText2D( debugtxt, MT_Vector2(xcoord + const_xindent + profile_indent, ycoord), white); diff --git a/source/gameengine/Ketsji/KX_PythonProxy.cpp b/source/gameengine/Ketsji/KX_PythonProxy.cpp index d9b34c016918..6a640b48c618 100644 --- a/source/gameengine/Ketsji/KX_PythonProxy.cpp +++ b/source/gameengine/Ketsji/KX_PythonProxy.cpp @@ -22,12 +22,12 @@ #include "KX_PythonProxy.h" +#include + #include "BKE_python_proxy.hh" #include "CM_Message.h" #include "DNA_python_proxy_types.h" -#include - KX_PythonProxy::KX_PythonProxy() : EXP_Value(), m_init(false), @@ -236,7 +236,7 @@ PyObject *KX_PythonProxy::pyattr_get_logger_name(EXP_PyObjectPlus *self_v, { KX_PythonProxy *self = static_cast(self_v); - std::string repr = (boost::format("%s[%s]") % self->GetType()->tp_name % self->GetText()).str(); + std::string repr = fmt::format("{}[{}]", self->GetType()->tp_name, self->GetText()); return PyUnicode_FromStdString(repr); } diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index dbbdf9409896..4268824b6766 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -33,7 +33,7 @@ # include "KX_VertexProxy.h" -# include +#include # include "EXP_ListWrapper.h" # include "KX_MeshProxy.h" @@ -542,7 +542,7 @@ int KX_VertexProxy::pyattr_set_uvs(EXP_PyObjectPlus *self_v, } else { PyErr_SetString(PyExc_AttributeError, - ((boost::format("list[%d] was not a vector") % i).str().c_str())); + (fmt::format("list[{}] was not a vector", i).c_str())); return PY_SET_ATTR_FAIL; } } @@ -582,7 +582,7 @@ int KX_VertexProxy::pyattr_set_colors(EXP_PyObjectPlus *self_v, } else { PyErr_SetString(PyExc_AttributeError, - ((boost::format("list[%d] was not a vector") % i).str().c_str())); + (fmt::format("list[{}] was not a vector", i).c_str())); return PY_SET_ATTR_FAIL; } }