Skip to content

Commit

Permalink
UPBGE: Remove boost dependancy after libs update
Browse files Browse the repository at this point in the history
boost was removed in last libs update

https://projects.blender.org/blender/blender/commit/e94d92593e238d0ac0250fc4dda554e1c72a87b6

I hope i didn't do mistakes
  • Loading branch information
youle31 committed Feb 13, 2025
1 parent e9b7c5a commit e250de4
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 48 deletions.
27 changes: 10 additions & 17 deletions source/gameengine/Converter/BL_DataConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

#include "BL_DataConversion.h"

#include <fmt/format.h>

/* This little block needed for linking to Blender... */
#ifdef WIN32
# include "BLI_winstuff.h"
Expand Down Expand Up @@ -105,8 +107,6 @@
# include "CcdPhysicsEnvironment.h"
#endif

#include <boost/format.hpp>

using namespace blender;
using namespace blender::bke;

Expand Down Expand Up @@ -739,23 +739,19 @@ 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 {
// Grab the class object
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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);

Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions source/gameengine/Converter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions source/gameengine/Expressions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ set(SRC

set(LIB
PRIVATE bf::blenlib
PRIVATE bf::extern::fmtlib
PRIVATE bf::intern::guardedalloc
)

Expand Down
22 changes: 11 additions & 11 deletions source/gameengine/Expressions/intern/InputParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

#include "EXP_InputParser.h"

#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <fmt/format.h>

#include "CM_Message.h"
#include "EXP_BoolValue.h"
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions source/gameengine/Expressions/intern/IntValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "EXP_IntValue.h"

#include <boost/format.hpp>
#include <fmt/format.h>

#include "CM_Message.h"
#include "EXP_BoolValue.h"
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions source/gameengine/GameLogic/SCA_PropertySensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

#include "SCA_PropertySensor.h"

#include <boost/algorithm/string.hpp>

#include "CM_Format.h"
#include "EXP_FloatValue.h"

Expand Down Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions source/gameengine/Ketsji/BL_Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "BL_Shader.h"

#include <boost/format.hpp>
#include <fmt/format.h>

#include "CM_Message.h"
#include "KX_GameObject.h"
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions source/gameengine/Ketsji/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions source/gameengine/Ketsji/KX_KetsjiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "KX_KetsjiEngine.h"

#include <boost/format.hpp>
#include <fmt/format.h>

#include "BKE_context.hh"
#include "BLI_rect.h"
Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions source/gameengine/Ketsji/KX_PythonProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

#include "KX_PythonProxy.h"

#include <fmt/format.h>

#include "BKE_python_proxy.hh"
#include "CM_Message.h"
#include "DNA_python_proxy_types.h"

#include <boost/format.hpp>

KX_PythonProxy::KX_PythonProxy()
: EXP_Value(),
m_init(false),
Expand Down Expand Up @@ -236,7 +236,7 @@ PyObject *KX_PythonProxy::pyattr_get_logger_name(EXP_PyObjectPlus *self_v,
{
KX_PythonProxy *self = static_cast<KX_PythonProxy *>(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);
}
Expand Down
6 changes: 3 additions & 3 deletions source/gameengine/Ketsji/KX_VertexProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

# include "KX_VertexProxy.h"

# include <boost/format.hpp>
#include <fmt/format.h>

# include "EXP_ListWrapper.h"
# include "KX_MeshProxy.h"
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit e250de4

Please sign in to comment.