From 154c6790ff6de12bfaf055766c907430f8d57e39 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 11:00:51 +0100 Subject: [PATCH 01/19] First commit --- .../qt_utils/motion_editor/AddStateDialog.cpp | 2 +- .../projects/libraries/qt_utils/motion_editor/Pose.cpp | 2 +- .../libraries/qt_utils/motion_editor/PoseEditor.cpp | 2 +- src/controller/c/g_image.c | 2 +- src/controller/c/supervisor.c | 6 +++--- src/webots/app/WbApplication.cpp | 2 +- src/webots/control/WbControlledWorld.cpp | 4 ++-- src/webots/core/WbTelemetry.cpp | 2 +- src/webots/core/WbWebotsUpdateManager.cpp | 2 +- src/webots/engine/WbSimulationWorld.cpp | 4 ++-- src/webots/gui/WbNewProjectWizard.cpp | 2 +- src/webots/gui/WbNewVersionDialog.cpp | 2 +- src/webots/gui/WbWebotsUpdateDialog.cpp | 2 +- src/webots/nodes/WbCadShape.cpp | 2 +- src/webots/nodes/WbHinge2Joint.cpp | 2 +- src/webots/nodes/WbJoint.cpp | 2 +- src/webots/nodes/WbLed.cpp | 4 ++-- src/webots/nodes/WbMatter.cpp | 4 ++-- src/webots/nodes/WbRobot.cpp | 10 +++++----- src/webots/nodes/WbSolid.cpp | 2 +- src/webots/nodes/WbTrack.cpp | 8 ++++---- src/webots/nodes/utils/WbNodeOperations.cpp | 6 +++--- src/webots/scene_tree/WbSceneTree.cpp | 2 +- src/webots/user_commands/WbActionManager.cpp | 2 +- src/webots/vrml/WbField.cpp | 4 ++-- src/webots/vrml/WbNode.cpp | 4 ++-- src/wren/Node.cpp | 2 +- 27 files changed, 44 insertions(+), 44 deletions(-) diff --git a/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp b/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp index 2704342e381..97836770700 100644 --- a/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp +++ b/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp @@ -32,7 +32,7 @@ AddStateDialog::AddStateDialog(Motion *motion, QWidget *parent) : QDialog(parent populateListWidget(); QWidget *buttonsWidget = new QWidget(this); - QPushButton *cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); + QPushButton *const cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); QPushButton *okButton = new QPushButton(tr("Ok"), buttonsWidget); QHBoxLayout *hBoxLayout = new QHBoxLayout(buttonsWidget); hBoxLayout->addStretch(); diff --git a/resources/projects/libraries/qt_utils/motion_editor/Pose.cpp b/resources/projects/libraries/qt_utils/motion_editor/Pose.cpp index 9b01fecdf8f..af35550680b 100644 --- a/resources/projects/libraries/qt_utils/motion_editor/Pose.cpp +++ b/resources/projects/libraries/qt_utils/motion_editor/Pose.cpp @@ -17,7 +17,7 @@ Pose::Pose(const Pose &other) : mName(other.mName), mTime(other.mTime), mIsValid int size = other.mStates.size(); mStates.reserve(size); foreach (const MotorTargetState *item, other.mStates) { - MotorTargetState *state = new MotorTargetState(*item); + MotorTargetState *const state = new MotorTargetState(*item); mStates.append(state); connect(state, SIGNAL(updated()), this, SLOT(propagateStateUpdate())); connect(state, SIGNAL(validChanged()), this, SLOT(updateIsValid())); diff --git a/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp b/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp index da9419e3ed8..d18c496e907 100644 --- a/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp +++ b/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp @@ -36,7 +36,7 @@ PoseEditor::PoseEditor(Pose *pose, Pose *previousPose, Pose *nextPose, bool fixe formLayout->addRow(tr("&Milliseconds:"), mMilliSecondsSpinBox); QWidget *buttonsWidget = new QWidget(this); - QPushButton *cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); + QPushButton *const cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); QPushButton *okButton = new QPushButton(tr("Ok"), buttonsWidget); QHBoxLayout *hBoxLayout = new QHBoxLayout(buttonsWidget); hBoxLayout->addStretch(); diff --git a/src/controller/c/g_image.c b/src/controller/c/g_image.c index 54c3a7b7db0..92c20a32b86 100644 --- a/src/controller/c/g_image.c +++ b/src/controller/c/g_image.c @@ -224,7 +224,7 @@ struct ImageData { unsigned long *target_data_size; }; -void g_image_save_to_jpeg_buffer_callback(void *context, void *data, int size) { +void g_image_save_to_jpeg_buffer_callback(void *context, const void *data, int size) { if (!*(((struct ImageData *)context)->target_data)) *(((struct ImageData *)context)->target_data) = (unsigned char *)malloc(size); else diff --git a/src/controller/c/supervisor.c b/src/controller/c/supervisor.c index e7a6dc47a19..74c1f42fb1c 100644 --- a/src/controller/c/supervisor.c +++ b/src/controller/c/supervisor.c @@ -1814,7 +1814,7 @@ static WbNodeRef node_get_from_id(int id, const char *function) { WbNodeRef result = find_node_by_id(id); if (!result) { - WbNodeRef node_list_before = node_list; + WbNodeRef *const node_list_before = node_list; node_id = id; wb_robot_flush_unlocked(function); if (node_list != node_list_before) @@ -2313,7 +2313,7 @@ WbFieldRef wb_supervisor_node_get_field_by_index(WbNodeRef node, int index) { WbFieldRef result = find_field_by_id(node->id, index, false); if (!result) { // otherwise: need to talk to Webots - WbFieldRef field_list_before = field_list; + WbFieldRef *const field_list_before = field_list; requested_field_index = index; node_ref = node->id; wb_robot_flush_unlocked(__FUNCTION__); @@ -2349,7 +2349,7 @@ WbFieldRef wb_supervisor_node_get_proto_field_by_index(WbNodeRef node, int index WbFieldRef result = find_field_by_id(node->id, index, true); if (!result) { // otherwise: need to talk to Webots - WbFieldRef field_list_before = field_list; + WbFieldRef *const field_list_before = field_list; requested_field_index = index; node_ref = node->id; allow_search_in_proto = true; diff --git a/src/webots/app/WbApplication.cpp b/src/webots/app/WbApplication.cpp index 57a933f59e0..4dab5fd6b8d 100644 --- a/src/webots/app/WbApplication.cpp +++ b/src/webots/app/WbApplication.cpp @@ -122,7 +122,7 @@ WbApplication::~WbApplication() { } void WbApplication::setup() { - WbNodeOperations *nodeOperations = WbNodeOperations::instance(); + WbNodeOperations *const nodeOperations = WbNodeOperations::instance(); // create and connect WbAnimationRecorder WbAnimationRecorder *recorder = WbAnimationRecorder::instance(); diff --git a/src/webots/control/WbControlledWorld.cpp b/src/webots/control/WbControlledWorld.cpp index 1407c608a6f..656ce2c89a9 100644 --- a/src/webots/control/WbControlledWorld.cpp +++ b/src/webots/control/WbControlledWorld.cpp @@ -46,7 +46,7 @@ WbControlledWorld::WbControlledWorld(WbTokenizer *tokenizer) : return; mNeedToYield = false; - foreach (WbRobot *const robot, robots()) + foreach (const WbRobot *robot, robots()) { connect(robot, &WbRobot::startControllerRequest, this, &WbControlledWorld::startController); } @@ -195,7 +195,7 @@ void WbControlledWorld::checkIfReadRequestCompleted() { void WbControlledWorld::step() { if (mFirstStep && !mRetryEnabled) { - foreach (WbRobot *const robot, robots()) { + foreach (const WbRobot *robot, robots()) { if (!robot->isControllerStarted()) startController(robot); } diff --git a/src/webots/core/WbTelemetry.cpp b/src/webots/core/WbTelemetry.cpp index ce66721ebb4..736c466551e 100644 --- a/src/webots/core/WbTelemetry.cpp +++ b/src/webots/core/WbTelemetry.cpp @@ -71,7 +71,7 @@ void WbTelemetry::sendRequest(const QString &operation) { data.append("&build="); data.append(QString::number(UNIX_TIMESTAMP).toUtf8()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); - QNetworkReply *reply = WbNetwork::instance()->networkAccessManager()->post(request, data); + QNetworkReply *const reply = WbNetwork::instance()->networkAccessManager()->post(request, data); if (id == 0) { QEventLoop loop; QTimer timer; diff --git a/src/webots/core/WbWebotsUpdateManager.cpp b/src/webots/core/WbWebotsUpdateManager.cpp index 6adc7484e2a..4d25a293213 100644 --- a/src/webots/core/WbWebotsUpdateManager.cpp +++ b/src/webots/core/WbWebotsUpdateManager.cpp @@ -50,7 +50,7 @@ void WbWebotsUpdateManager::cleanup() { void WbWebotsUpdateManager::sendRequest() { QNetworkRequest request; request.setUrl(QUrl("https://api.github.com/repos/cyberbotics/webots/releases/latest")); - QNetworkReply *reply = WbNetwork::instance()->networkAccessManager()->get(request); + QNetworkReply *const reply = WbNetwork::instance()->networkAccessManager()->get(request); connect(reply, &QNetworkReply::finished, this, &WbWebotsUpdateManager::downloadReplyFinished, Qt::UniqueConnection); } diff --git a/src/webots/engine/WbSimulationWorld.cpp b/src/webots/engine/WbSimulationWorld.cpp index 102d670b3ce..8e50d10819b 100644 --- a/src/webots/engine/WbSimulationWorld.cpp +++ b/src/webots/engine/WbSimulationWorld.cpp @@ -226,7 +226,7 @@ void WbSimulationWorld::step() { dImmersionOutlineDestroy(mImmersionGeoms.at(i).outline); mImmersionGeoms.clear(); - foreach (WbRobot *const robot, robots()) { + foreach (const WbRobot *robot, robots()) { if (robots().contains(robot)) // the 'processImmediateMessages' of another robot may have removed/regenerated this robot robot->processImmediateMessages(); } @@ -400,7 +400,7 @@ void WbSimulationWorld::reset(bool restartControllers) { dImmersionLinkGroupEmpty(mCluster->immersionLinkGroup()); WbSoundEngine::stopAllSources(); if (restartControllers) { - foreach (WbRobot *const robot, robots()) { + foreach (const WbRobot *robot, robots()) { if (robot->isControllerStarted()) robot->restartController(); } diff --git a/src/webots/gui/WbNewProjectWizard.cpp b/src/webots/gui/WbNewProjectWizard.cpp index 78504ed4417..f285612c55d 100644 --- a/src/webots/gui/WbNewProjectWizard.cpp +++ b/src/webots/gui/WbNewProjectWizard.cpp @@ -124,7 +124,7 @@ QWizardPage *WbNewProjectWizard::createDirectoryPage() { page->setTitle(tr("Directory selection")); page->setSubTitle(tr("Please choose a directory for your new project:")); mDirEdit = new WbLineEdit(page); - QPushButton *chooseButton = new QPushButton(tr("Choose"), page); + QPushButton *const chooseButton = new QPushButton(tr("Choose"), page); connect(chooseButton, &QPushButton::pressed, this, &WbNewProjectWizard::chooseDirectory); QHBoxLayout *layout = new QHBoxLayout(page); layout->addWidget(mDirEdit); diff --git a/src/webots/gui/WbNewVersionDialog.cpp b/src/webots/gui/WbNewVersionDialog.cpp index e212ac8a4e3..84d32982185 100644 --- a/src/webots/gui/WbNewVersionDialog.cpp +++ b/src/webots/gui/WbNewVersionDialog.cpp @@ -132,7 +132,7 @@ WbNewVersionDialog::WbNewVersionDialog() { vBoxLayout->addWidget(telemetryBox); // main button - QPushButton *startButton = new QPushButton(tr("Start Webots with the selected theme.")); + QPushButton *const startButton = new QPushButton(tr("Start Webots with the selected theme.")); vBoxLayout->addWidget(startButton); setLayout(vBoxLayout); diff --git a/src/webots/gui/WbWebotsUpdateDialog.cpp b/src/webots/gui/WbWebotsUpdateDialog.cpp index 75b2c1a88d3..2141101e277 100644 --- a/src/webots/gui/WbWebotsUpdateDialog.cpp +++ b/src/webots/gui/WbWebotsUpdateDialog.cpp @@ -25,7 +25,7 @@ WbWebotsUpdateDialog::WbWebotsUpdateDialog(bool displayCheckBox, QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Check for updates")); - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this); + QDialogButtonBox *const buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this); connect(buttonBox, &QDialogButtonBox::accepted, this, &WbWebotsUpdateDialog::accept); mLabel = new QLabel(tr("Check for updates..."), this); diff --git a/src/webots/nodes/WbCadShape.cpp b/src/webots/nodes/WbCadShape.cpp index 3302d430992..9a419ae83a0 100644 --- a/src/webots/nodes/WbCadShape.cpp +++ b/src/webots/nodes/WbCadShape.cpp @@ -118,7 +118,7 @@ void WbCadShape::retrieveMaterials() { if (!newUrl.isEmpty()) { mObjMaterials.insert(material, newUrl); // prepare a downloader - WbDownloader *downloader = WbDownloadManager::instance()->createDownloader(QUrl(newUrl), this); + WbDownloader *const downloader = WbDownloadManager::instance()->createDownloader(QUrl(newUrl), this); connect(downloader, &WbDownloader::complete, this, &WbCadShape::materialDownloadTracker); mMaterialDownloaders.push_back(downloader); } diff --git a/src/webots/nodes/WbHinge2Joint.cpp b/src/webots/nodes/WbHinge2Joint.cpp index 70df89bd0da..7bf402a1ba8 100644 --- a/src/webots/nodes/WbHinge2Joint.cpp +++ b/src/webots/nodes/WbHinge2Joint.cpp @@ -582,7 +582,7 @@ void WbHinge2Joint::addDevice2(int index) { WbBaseNode *decendant = dynamic_cast(mDevice2->item(index)); r->descendantNodeInserted(decendant); } - WbBrake *brake = dynamic_cast(mDevice2->item(index)); + WbBrake *const brake = dynamic_cast(mDevice2->item(index)); if (brake) connect(brake, &WbBrake::brakingChanged, this, &WbHinge2Joint::updateSpringAndDampingConstants, Qt::UniqueConnection); } diff --git a/src/webots/nodes/WbJoint.cpp b/src/webots/nodes/WbJoint.cpp index d3b64982677..cb14980d813 100644 --- a/src/webots/nodes/WbJoint.cpp +++ b/src/webots/nodes/WbJoint.cpp @@ -152,7 +152,7 @@ void WbJoint::addDevice(int index) { WbBaseNode *decendant = dynamic_cast(mDevice->item(index)); r->descendantNodeInserted(decendant); } - WbBrake *b = dynamic_cast(mDevice->item(index)); + WbBrake *const b = dynamic_cast(mDevice->item(index)); if (b) connect(b, &WbBrake::brakingChanged, this, &WbJoint::updateSpringAndDampingConstants, Qt::UniqueConnection); } diff --git a/src/webots/nodes/WbLed.cpp b/src/webots/nodes/WbLed.cpp index ce81dce6bad..e7ef797f9fe 100644 --- a/src/webots/nodes/WbLed.cpp +++ b/src/webots/nodes/WbLed.cpp @@ -107,7 +107,7 @@ void WbLed::findMaterialsAndLights(const WbGroup *group) { WbBaseNode *const n = group->child(i); // cppcheck-suppress constVariablePointer WbLight *lightChild = dynamic_cast(n); - WbGroup *groupChild = dynamic_cast(n); + WbGroup *const groupChild = dynamic_cast(n); if (n->nodeType() == WB_NODE_SHAPE) { const WbAppearance *appearance = dynamic_cast(n)->appearance(); @@ -120,7 +120,7 @@ void WbLed::findMaterialsAndLights(const WbGroup *group) { connect(appearance, &WbAppearance::fieldChanged, this, &WbLed::updateIfNeeded, Qt::UniqueConnection); connect(appearance->parentNode(), &WbShape::fieldChanged, this, &WbLed::updateIfNeeded, Qt::UniqueConnection); } else { - WbPbrAppearance *pbrAppearance = dynamic_cast(n)->pbrAppearance(); + WbPbrAppearance *const pbrAppearance = dynamic_cast(n)->pbrAppearance(); if (pbrAppearance) { mPbrAppearances.append(pbrAppearance); diff --git a/src/webots/nodes/WbMatter.cpp b/src/webots/nodes/WbMatter.cpp index 6e158b98485..c039bcdd996 100644 --- a/src/webots/nodes/WbMatter.cpp +++ b/src/webots/nodes/WbMatter.cpp @@ -361,12 +361,12 @@ void WbMatter::createOdeGeomFromInsertedShapeItem() { if (insertedGeom) setGeomMatter(insertedGeom); } else { // no Pose in the boundingObject is a parent of this Shape - WbIndexedFaceSet *const ifs = dynamic_cast(geometry); + const WbIndexedFaceSet *const ifs = dynamic_cast(geometry); if (ifs) connect(ifs, &WbIndexedFaceSet::validIndexedFaceSetInserted, shape, &WbShape::geometryInShapeInserted, Qt::UniqueConnection); - WbElevationGrid *const eg = dynamic_cast(geometry); + const WbElevationGrid *const eg = dynamic_cast(geometry); if (eg) connect(eg, &WbElevationGrid::validElevationGridInserted, shape, &WbShape::geometryInShapeInserted, Qt::UniqueConnection); diff --git a/src/webots/nodes/WbRobot.cpp b/src/webots/nodes/WbRobot.cpp index 821ba012c9a..202416ceb36 100644 --- a/src/webots/nodes/WbRobot.cpp +++ b/src/webots/nodes/WbRobot.cpp @@ -286,7 +286,7 @@ void WbRobot::addDevices(WbNode *node) { if (renderingDevice) { connect(renderingDevice, &WbBaseNode::isBeingDestroyed, this, &WbRobot::removeRenderingDevice, Qt::UniqueConnection); mRenderingDevices.append(renderingDevice); - WbAbstractCamera *camera = dynamic_cast(renderingDevice); + WbAbstractCamera *const camera = dynamic_cast(renderingDevice); if (camera) { connect(camera, &WbAbstractCamera::enabled, this, &WbRobot::updateActiveCameras, Qt::UniqueConnection); if (camera->isEnabled()) @@ -311,7 +311,7 @@ void WbRobot::addDevices(WbNode *node) { return; } - WbSkin *const skin = dynamic_cast(node); + const WbSkin *skin = dynamic_cast(node); if (skin) { mDevices.append(skin); connect(static_cast(skin), &WbBaseNode::destroyed, this, &WbRobot::updateDevicesAfterDestruction, @@ -330,7 +330,7 @@ void WbRobot::addDevices(WbNode *node) { const WbJoint *const joint = dynamic_cast(basicJoint); if (joint) { const QVector &jointDevices = joint->devices(); - foreach (WbLogicalDevice *const jointDevice, jointDevices) { + foreach (const WbLogicalDevice *jointDevice, jointDevices) { if (jointDevice == NULL) continue; mDevices.append(jointDevice); @@ -343,9 +343,9 @@ void WbRobot::addDevices(WbNode *node) { return; } - WbPropeller *const propeller = dynamic_cast(node); + const WbPropeller *propeller = dynamic_cast(node); if (propeller) { - WbLogicalDevice *const propellerDevice = propeller->device(); + const WbLogicalDevice *propellerDevice = propeller->device(); if (propellerDevice) { mDevices.append(propellerDevice); connect(static_cast(propellerDevice), &WbBaseNode::destroyed, this, &WbRobot::updateDevicesAfterDestruction, diff --git a/src/webots/nodes/WbSolid.cpp b/src/webots/nodes/WbSolid.cpp index 68f2e10a20f..5efa6637e03 100644 --- a/src/webots/nodes/WbSolid.cpp +++ b/src/webots/nodes/WbSolid.cpp @@ -1580,7 +1580,7 @@ void WbSolid::updateChildren() { connect(solid, &WbSolid::destroyed, this, &WbSolid::refreshPhysicsRepresentation, Qt::UniqueConnection); connect(solid, &WbSolid::physicsPropertiesChanged, this, &WbSolid::refreshPhysicsRepresentation, Qt::UniqueConnection); } - foreach (WbBasicJoint *const jointChild, mJointChildren) + foreach (const WbBasicJoint *jointChild, mJointChildren) connect(jointChild, &WbBasicJoint::endPointChanged, this, &WbSolid::updateChildrenAfterJointEndPointChange, Qt::UniqueConnection); } diff --git a/src/webots/nodes/WbTrack.cpp b/src/webots/nodes/WbTrack.cpp index 39a87c3563d..9f21c65ca8b 100644 --- a/src/webots/nodes/WbTrack.cpp +++ b/src/webots/nodes/WbTrack.cpp @@ -132,7 +132,7 @@ void WbTrack::postFinalize() { connect(mDeviceField, &WbMFNode::itemInserted, this, &WbTrack::addDevice); if (childCount() > 0) { - WbGroup *group = dynamic_cast(child(0)); + WbGroup *const group = dynamic_cast(child(0)); if (group) connect(group, &WbGroup::childrenChanged, this, &WbTrack::updateChildren); if (mShape) @@ -235,7 +235,7 @@ bool WbTrack::findAndConnectAnimatedGeometries(bool connectSignals, QList(node); + WbShape *const s = dynamic_cast(node); if (s) { if (connectSignals) { // material automatically updated @@ -259,7 +259,7 @@ bool WbTrack::findAndConnectAnimatedGeometries(bool connectSignals, QListchildCount(); ++j) geometryNodes.append(g->child(j)); - WbPose *t = dynamic_cast(g); + WbPose *const t = dynamic_cast(g); if (t) { t->enablePoseChangedSignal(); connect(t, &WbPose::poseChanged, this, &WbTrack::updateAnimatedGeometries, Qt::UniqueConnection); @@ -951,7 +951,7 @@ void WbTrack::exportNodeSubNodes(WbWriter &writer) const { // write animated geometries if (!writer.isW3d() && !writer.isUrdf() && !isEmpty) writer << "\n"; - isEmpty |= mAnimatedObjectList.isEmpty(); + isEmpty || mAnimatedObjectList.isEmpty(); exportAnimatedGeometriesMesh(writer); diff --git a/src/webots/nodes/utils/WbNodeOperations.cpp b/src/webots/nodes/utils/WbNodeOperations.cpp index 1d96c7c8d0b..4931d4aa735 100644 --- a/src/webots/nodes/utils/WbNodeOperations.cpp +++ b/src/webots/nodes/utils/WbNodeOperations.cpp @@ -112,9 +112,9 @@ WbNodeOperations::OperationResult WbNodeOperations::importNode(WbNode *parentNod bool avoidIntersections) { setFromSupervisor(origin == FROM_SUPERVISOR); - WbSFNode *sfnode = dynamic_cast(field->value()); + const WbSFNode *sfnode = dynamic_cast(field->value()); #ifndef NDEBUG - WbMFNode *mfnode = dynamic_cast(field->value()); + const WbMFNode *mfnode = dynamic_cast(field->value()); assert(mfnode || sfnode); // index value is assumed to be in range [0, mfnode->size()] // user input checked in wb_supervisor_field_import_mf_node_from_string or WbSceneTree @@ -309,7 +309,7 @@ bool WbNodeOperations::deleteNode(WbNode *node, bool fromSupervisor) { setFromSupervisor(fromSupervisor); - if (dynamic_cast(node)) + if (node && dynamic_cast(node)) WbWorld::instance()->awake(); const bool dictionaryNeedsUpdate = WbVrmlNodeUtilities::hasAreferredDefNodeDescendant(node); diff --git a/src/webots/scene_tree/WbSceneTree.cpp b/src/webots/scene_tree/WbSceneTree.cpp index 2448eb46774..b7a1c0e5c8c 100644 --- a/src/webots/scene_tree/WbSceneTree.cpp +++ b/src/webots/scene_tree/WbSceneTree.cpp @@ -1125,7 +1125,7 @@ void WbSceneTree::updateSelection() { // quitting Webots return; - WbNodeOperations *nodeOperations = WbNodeOperations::instance(); + WbNodeOperations *const nodeOperations = WbNodeOperations::instance(); if (nodeOperations->isFromSupervisor()) // do not update selection if change come from supervisor return; diff --git a/src/webots/user_commands/WbActionManager.cpp b/src/webots/user_commands/WbActionManager.cpp index a452434fffc..91e7c85e568 100644 --- a/src/webots/user_commands/WbActionManager.cpp +++ b/src/webots/user_commands/WbActionManager.cpp @@ -1134,7 +1134,7 @@ void WbActionManager::populateActions() { } void WbActionManager::connectActions() { - WbSimulationState *state = WbSimulationState::instance(); + WbSimulationState *const state = WbSimulationState::instance(); connect(state, &WbSimulationState::enabledChanged, this, &WbActionManager::updateEnabled); } diff --git a/src/webots/vrml/WbField.cpp b/src/webots/vrml/WbField.cpp index 23838c6ec6b..8404354e016 100644 --- a/src/webots/vrml/WbField.cpp +++ b/src/webots/vrml/WbField.cpp @@ -81,7 +81,7 @@ WbField::~WbField() { void WbField::listenToValueSizeChanges() const { if (singleType() == WB_SF_NODE) { - WbSFNode *sfnode = static_cast(mValue); + const WbSFNode *sfnode = static_cast(mValue); connect(sfnode, &WbSFNode::changed, this, &WbField::valueSizeChanged, Qt::UniqueConnection); return; } @@ -362,7 +362,7 @@ void WbField::redirectTo(WbField *parameter, bool skipCopy) { if (!skipCopy) mValue->copyFrom(mParameter->value()); - WbMFNode *mfnode = dynamic_cast(mParameter->value()); + const WbMFNode *mfnode = dynamic_cast(mParameter->value()); if (mfnode) { connect(mfnode, &WbMFNode::itemChanged, mParameter, &WbField::parameterNodeChanged, Qt::UniqueConnection); connect(mfnode, &WbMFNode::itemInserted, mParameter, &WbField::parameterNodeInserted, Qt::UniqueConnection); diff --git a/src/webots/vrml/WbNode.cpp b/src/webots/vrml/WbNode.cpp index 96cb4cce56b..4dcdb81a370 100644 --- a/src/webots/vrml/WbNode.cpp +++ b/src/webots/vrml/WbNode.cpp @@ -208,7 +208,7 @@ WbNode::WbNode(const WbNode &other) : // copy fields foreach (const WbField *f, other.fields()) { - WbField *copy = new WbField(*f, this); + WbField *const copy = new WbField(*f, this); mFields.append(copy); connect(copy, &WbField::valueChanged, this, &WbNode::notifyFieldChanged); } @@ -216,7 +216,7 @@ WbNode::WbNode(const WbNode &other) : // copy parameters if (other.mProto) { foreach (const WbField *parameter, other.parameters()) { - WbField *copy = new WbField(*parameter, this); + WbField *const copy = new WbField(*parameter, this); mParameters.append(copy); connect(copy, &WbField::valueChanged, this, &WbNode::notifyParameterChanged); } diff --git a/src/wren/Node.cpp b/src/wren/Node.cpp index b9c9846edb1..c9aa6693291 100644 --- a/src/wren/Node.cpp +++ b/src/wren/Node.cpp @@ -61,7 +61,7 @@ namespace wren { Node::Node() : mIsVisible(true), mIsAabbDirty(true), mIsBoundingSphereDirty(true), mParent(NULL) { } - Node::Node(Node *source) : + Node::Node(const Node *source) : mIsVisible(source->mIsVisible), mIsAabbDirty(source->mIsAabbDirty), mIsBoundingSphereDirty(source->mIsBoundingSphereDirty), From 839b60994344e982e5a623a906db92460ef1ad86 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 11:33:36 +0100 Subject: [PATCH 02/19] Fix --- src/webots/control/WbControlledWorld.cpp | 2 +- src/webots/nodes/WbTrack.cpp | 2 +- src/webots/nodes/utils/WbNodeOperations.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/webots/control/WbControlledWorld.cpp b/src/webots/control/WbControlledWorld.cpp index 656ce2c89a9..4742d2909b6 100644 --- a/src/webots/control/WbControlledWorld.cpp +++ b/src/webots/control/WbControlledWorld.cpp @@ -46,7 +46,7 @@ WbControlledWorld::WbControlledWorld(WbTokenizer *tokenizer) : return; mNeedToYield = false; - foreach (const WbRobot *robot, robots()) { + foreach (const WbRobot *robot, robots()) connect(robot, &WbRobot::startControllerRequest, this, &WbControlledWorld::startController); } diff --git a/src/webots/nodes/WbTrack.cpp b/src/webots/nodes/WbTrack.cpp index 9f21c65ca8b..7fccecfc106 100644 --- a/src/webots/nodes/WbTrack.cpp +++ b/src/webots/nodes/WbTrack.cpp @@ -951,7 +951,7 @@ void WbTrack::exportNodeSubNodes(WbWriter &writer) const { // write animated geometries if (!writer.isW3d() && !writer.isUrdf() && !isEmpty) writer << "\n"; - isEmpty || mAnimatedObjectList.isEmpty(); + isEmpty =| mAnimatedObjectList.isEmpty(); exportAnimatedGeometriesMesh(writer); diff --git a/src/webots/nodes/utils/WbNodeOperations.cpp b/src/webots/nodes/utils/WbNodeOperations.cpp index 4931d4aa735..7e81a488ae0 100644 --- a/src/webots/nodes/utils/WbNodeOperations.cpp +++ b/src/webots/nodes/utils/WbNodeOperations.cpp @@ -309,7 +309,7 @@ bool WbNodeOperations::deleteNode(WbNode *node, bool fromSupervisor) { setFromSupervisor(fromSupervisor); - if (node && dynamic_cast(node)) + if (dynamic_cast(node)) WbWorld::instance()->awake(); const bool dictionaryNeedsUpdate = WbVrmlNodeUtilities::hasAreferredDefNodeDescendant(node); From d6f5fa47cfd478db2636c07fc04085decf6f457e Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 11:45:03 +0100 Subject: [PATCH 03/19] Fix --- src/webots/nodes/WbTrack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webots/nodes/WbTrack.cpp b/src/webots/nodes/WbTrack.cpp index 7fccecfc106..c4fed8595dd 100644 --- a/src/webots/nodes/WbTrack.cpp +++ b/src/webots/nodes/WbTrack.cpp @@ -951,7 +951,7 @@ void WbTrack::exportNodeSubNodes(WbWriter &writer) const { // write animated geometries if (!writer.isW3d() && !writer.isUrdf() && !isEmpty) writer << "\n"; - isEmpty =| mAnimatedObjectList.isEmpty(); + isEmpty |= mAnimatedObjectList.isEmpty(); exportAnimatedGeometriesMesh(writer); From 45fd4c6e67e35247aef9a33087d9928c201b4fb8 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 12:29:28 +0100 Subject: [PATCH 04/19] Add test with latest cppcheck --- .github/workflows/tests_sources_with_latest_cppcheck.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests_sources_with_latest_cppcheck.yml b/.github/workflows/tests_sources_with_latest_cppcheck.yml index fbef60e4d70..3f2365acc13 100644 --- a/.github/workflows/tests_sources_with_latest_cppcheck.yml +++ b/.github/workflows/tests_sources_with_latest_cppcheck.yml @@ -1,6 +1,10 @@ name: Test Sources with Latest Cppcheck on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + branches-ignore: + - 'released' schedule: - cron: '0 22 * * *' From bbdfd0c545d0b9334440170db36d81bef7ca133b Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 12:53:40 +0100 Subject: [PATCH 05/19] Macos fix --- projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c | 2 +- projects/robots/gctronic/elisa/controllers/elisa3/elisa3.c | 2 +- .../darwin-op/transfer/keyboard/keyboardInterface.cpp | 2 -- .../nao/controllers/nao_soccer_player/nao_soccer_player.c | 1 - projects/samples/demos/controllers/moon/moon.c | 2 +- .../devices/controllers/distance_sensor/distance_sensor.c | 2 +- projects/samples/devices/controllers/lidar/lidar.c | 2 +- .../devices/controllers/spherical_camera/spherical_camera.c | 2 +- .../epuck_avoid_collision/epuck_avoid_collision.c | 5 +++-- src/webots/gui/WbMainWindow.cpp | 4 ++-- src/webots/gui/WbView3D.cpp | 4 ++-- src/webots/nodes/WbLightSensor.cpp | 2 +- src/webots/nodes/utils/WbSupervisorUtilities.cpp | 2 +- src/webots/scene_tree/WbAddNodeDialog.cpp | 2 +- src/wren/Scene.cpp | 4 ++-- 15 files changed, 18 insertions(+), 20 deletions(-) diff --git a/projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c b/projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c index fa15a8f12d6..d90956f5b9d 100644 --- a/projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c +++ b/projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) { int i, j; double speed[2]; double sensors_value[8]; - double braitenberg_coefficients[8][2] = {{0.942, -0.22}, {0.63, -0.1}, {0.5, -0.06}, {-0.06, -0.06}, + const double braitenberg_coefficients[8][2] = {{0.942, -0.22}, {0.63, -0.1}, {0.5, -0.06}, {-0.06, -0.06}, {-0.06, -0.06}, {-0.06, 0.5}, {-0.19, 0.63}, {-0.13, 0.942}}; int time_step; int camera_time_step; diff --git a/projects/robots/gctronic/elisa/controllers/elisa3/elisa3.c b/projects/robots/gctronic/elisa/controllers/elisa3/elisa3.c index 33891c528b4..8e3ac38aec2 100644 --- a/projects/robots/gctronic/elisa/controllers/elisa3/elisa3.c +++ b/projects/robots/gctronic/elisa/controllers/elisa3/elisa3.c @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) { int i, j; double speed[2] = {0, 0}; double sensors_value[8]; - double braitenberg_coefficients[8][2] = {{10, 8}, {7, -1.5}, {5, -1}, {-1, -1}, {-1, -1}, {-1, -1}, {-1, 5}, {-1.5, 7}}; + const double braitenberg_coefficients[8][2] = {{10, 8}, {7, -1.5}, {5, -1}, {-1, -1}, {-1, -1}, {-1, -1}, {-1, 5}, {-1.5, 7}}; /* initialize Webots */ wb_robot_init(); diff --git a/projects/robots/robotis/darwin-op/transfer/keyboard/keyboardInterface.cpp b/projects/robots/robotis/darwin-op/transfer/keyboard/keyboardInterface.cpp index 9f4bd243c22..443fb035575 100644 --- a/projects/robots/robotis/darwin-op/transfer/keyboard/keyboardInterface.cpp +++ b/projects/robots/robotis/darwin-op/transfer/keyboard/keyboardInterface.cpp @@ -207,8 +207,6 @@ void KeyboardInterface::startListenKeyboard() { void KeyboardInterface::setKeyPressed(int key) { if (mKeyPressed[key] == VALIDATED) mKeyPressed[key] = VALIDATED_STILL_PRESSED; - else if (mKeyPressed[key] == VALIDATED_STILL_PRESSED) - mKeyPressed[key] = VALIDATED_STILL_PRESSED; else mKeyPressed[key] = PRESSED; } diff --git a/projects/robots/softbank/nao/controllers/nao_soccer_player/nao_soccer_player.c b/projects/robots/softbank/nao/controllers/nao_soccer_player/nao_soccer_player.c index 0ea689c41df..90daad3eb25 100644 --- a/projects/robots/softbank/nao/controllers/nao_soccer_player/nao_soccer_player.c +++ b/projects/robots/softbank/nao/controllers/nao_soccer_player/nao_soccer_player.c @@ -165,7 +165,6 @@ static struct Sequence *read_sequence(char color, char number) { sequence->next = new_sequence; sequence = new_sequence; sequence->next = new_sequence; - sequence = new_sequence; sequence->time = time; sequence->action = (char *)malloc(strlen(action) + 1); strcpy(sequence->action, action); diff --git a/projects/samples/demos/controllers/moon/moon.c b/projects/samples/demos/controllers/moon/moon.c index ef4a2c92aa9..04e1984e6f5 100644 --- a/projects/samples/demos/controllers/moon/moon.c +++ b/projects/samples/demos/controllers/moon/moon.c @@ -36,7 +36,7 @@ int main() { double speed[2]; double sensor_value[16]; double kUnit = 8.24; - double matrix[2][16] = {{3, -18, -15, -15, -5, -5, 4, 4, 6, 6, 4, 4, 4, 4, 3, -18}, + const double matrix[2][16] = {{3, -18, -15, -15, -5, -5, 4, 4, 6, 6, 4, 4, 4, 4, 3, -18}, {-18, 3, 4, 4, 4, 4, 6, 6, 4, 4, -5, -5, -15, -15, -18, 3}}; wb_robot_init(); diff --git a/projects/samples/devices/controllers/distance_sensor/distance_sensor.c b/projects/samples/devices/controllers/distance_sensor/distance_sensor.c index 3b935eb88f2..ebeb50ba55f 100644 --- a/projects/samples/devices/controllers/distance_sensor/distance_sensor.c +++ b/projects/samples/devices/controllers/distance_sensor/distance_sensor.c @@ -32,7 +32,7 @@ int main(void) { char name[] = "ds0"; double speed[2]; double sensor_value[NB_SENSORS]; - double matrix[2][NB_SENSORS] = {{11, 12, 8, -2, -3, -5, -7, -9}, {-9, -8, -5, -1, -2, 6, 12, 11}}; + const double matrix[2][NB_SENSORS] = {{11, 12, 8, -2, -3, -5, -7, -9}, {-9, -8, -5, -1, -2, 6, 12, 11}}; wb_robot_init(); diff --git a/projects/samples/devices/controllers/lidar/lidar.c b/projects/samples/devices/controllers/lidar/lidar.c index 728a4a70c05..75f8e356a05 100644 --- a/projects/samples/devices/controllers/lidar/lidar.c +++ b/projects/samples/devices/controllers/lidar/lidar.c @@ -58,7 +58,7 @@ int main(int argc, char **argv) { wb_motor_set_velocity(right_motor, 0.0); // set empirical coefficients for collision avoidance - double coefficients[2][2] = {{12.0, -6.0}, {-10.0, 8.0}}; + const double coefficients[2][2] = {{12.0, -6.0}, {-10.0, 8.0}}; double base_speed = 6.0; // init speed values diff --git a/projects/samples/devices/controllers/spherical_camera/spherical_camera.c b/projects/samples/devices/controllers/spherical_camera/spherical_camera.c index cad22594261..c3aaa6a74d2 100644 --- a/projects/samples/devices/controllers/spherical_camera/spherical_camera.c +++ b/projects/samples/devices/controllers/spherical_camera/spherical_camera.c @@ -73,7 +73,7 @@ int main(int argc, char **argv) { // init distance sensors WbDeviceTag us[2]; double us_values[2]; - double coefficients[2][2] = {{6.0, -3.0}, {-5.0, 4.0}}; + const double coefficients[2][2] = {{6.0, -3.0}, {-5.0, 4.0}}; us[LEFT] = wb_robot_get_device("us0"); us[RIGHT] = wb_robot_get_device("us1"); for (i = 0; i < 2; i++) diff --git a/projects/samples/tutorials/controllers/epuck_avoid_collision/epuck_avoid_collision.c b/projects/samples/tutorials/controllers/epuck_avoid_collision/epuck_avoid_collision.c index a17a1e48c4a..85aa7d865de 100644 --- a/projects/samples/tutorials/controllers/epuck_avoid_collision/epuck_avoid_collision.c +++ b/projects/samples/tutorials/controllers/epuck_avoid_collision/epuck_avoid_collision.c @@ -58,8 +58,9 @@ int main(int argc, char **argv) { bool left_obstacle = ps_values[5] > 80.0 || ps_values[6] > 80.0 || ps_values[7] > 80.0; // initialize motor speeds at 50% of MAX_SPEED. - double left_speed = 0.5 * MAX_SPEED; - double right_speed = 0.5 * MAX_SPEED; + double speed = 0.5 * MAX_SPEED; + double left_speed = speed; + double right_speed = speed; // modify speeds according to obstacles if (left_obstacle) { diff --git a/src/webots/gui/WbMainWindow.cpp b/src/webots/gui/WbMainWindow.cpp index 91638c2a306..c4eda92d3e9 100644 --- a/src/webots/gui/WbMainWindow.cpp +++ b/src/webots/gui/WbMainWindow.cpp @@ -1160,7 +1160,7 @@ void WbMainWindow::savePerspective(bool reloading, bool saveToFile, bool isSaveE perspective->setConsolesSettings(settingsList); // save rendering devices perspective - const QList renderingDevices = WbRenderingDevice::renderingDevices(); + const QList &renderingDevices = WbRenderingDevice::renderingDevices(); foreach (const WbRenderingDevice *device, renderingDevices) { if (device->overlay() != NULL) perspective->setRenderingDevicePerspective(device->computeShortUniqueName(), device->perspective()); @@ -1249,7 +1249,7 @@ void WbMainWindow::restorePerspective(bool reloading, bool firstLoad, bool loadi void WbMainWindow::restoreRenderingDevicesPerspective() { const WbPerspective *perspective = WbWorld::instance()->perspective(); - const QList devices = WbRenderingDevice::renderingDevices(); + const QList &devices = WbRenderingDevice::renderingDevices(); for (int i = 0; i < devices.size(); ++i) { WbRenderingDevice *device = devices[i]; QStringList devicePerspective = perspective->renderingDevicePerspective(device->computeShortUniqueName()); diff --git a/src/webots/gui/WbView3D.cpp b/src/webots/gui/WbView3D.cpp index 5728028f55e..fa1d17b609d 100644 --- a/src/webots/gui/WbView3D.cpp +++ b/src/webots/gui/WbView3D.cpp @@ -1582,7 +1582,7 @@ void WbView3D::mousePressEvent(QMouseEvent *event) { // Overlays come first - special case for overlay resize and close (resize has priority) bool displayOverlayClicked = false; - WbWrenTextureOverlay *overlay = NULL; + const WbWrenTextureOverlay *overlay = nullptr; if (!mDragOverlay) { WbRenderingDevice *renderingDevice = WbRenderingDevice::fromMousePosition(position.x(), position.y()); if (renderingDevice) { @@ -1813,7 +1813,7 @@ void WbView3D::mouseMoveEvent(QMouseEvent *event) { // Drag overlay even if modifier keys are pressed WbRenderingDevice *const renderingDevice = WbRenderingDevice::fromMousePosition(position.x(), position.y()); if (renderingDevice) { - WbWrenTextureOverlay *const overlay = renderingDevice->overlay(); + const WbWrenTextureOverlay *overlay = renderingDevice->overlay(); if (overlay) { overlay->putOnTop(); if (overlay->isInsideResizeArea(position.x(), position.y())) diff --git a/src/webots/nodes/WbLightSensor.cpp b/src/webots/nodes/WbLightSensor.cpp index 95647cf43b4..d0f2ab9d8c3 100644 --- a/src/webots/nodes/WbLightSensor.cpp +++ b/src/webots/nodes/WbLightSensor.cpp @@ -262,7 +262,7 @@ void WbLightSensor::setupRaysAndComputeDirectContributions(bool finalSetup) { const WbVector3 &sensorAxis = matrix().xAxis(); // sensor normal vector (x-axis) const WbVector3 &sensorPos = matrix().translation(); // sensor position (world coordinate) - QList lights = WbLight::lights(); + const QList &lights = WbLight::lights(); foreach (const WbLight *light, lights) { if (light->isOn()) { WbVector3 lightDirection; diff --git a/src/webots/nodes/utils/WbSupervisorUtilities.cpp b/src/webots/nodes/utils/WbSupervisorUtilities.cpp index f929554cd1e..d1c838733d2 100644 --- a/src/webots/nodes/utils/WbSupervisorUtilities.cpp +++ b/src/webots/nodes/utils/WbSupervisorUtilities.cpp @@ -2224,7 +2224,7 @@ void WbSupervisorUtilities::writeAnswer(WbDataStream &stream) { } void WbSupervisorUtilities::writeConfigure(WbDataStream &stream) { - WbNode *selfNode = mRobot; + const WbNode *selfNode = mRobot; while (selfNode->protoParameterNode()) selfNode = selfNode->protoParameterNode(); stream << (short unsigned int)0; diff --git a/src/webots/scene_tree/WbAddNodeDialog.cpp b/src/webots/scene_tree/WbAddNodeDialog.cpp index 7964bffd1b3..8805db48ca0 100644 --- a/src/webots/scene_tree/WbAddNodeDialog.cpp +++ b/src/webots/scene_tree/WbAddNodeDialog.cpp @@ -541,7 +541,7 @@ int WbAddNodeDialog::addProtosFromProtoList(QTreeWidgetItem *parentItem, int typ QStringList protoList; QMapIterator it(WbProtoManager::instance()->protoInfoMap(type)); while (it.hasNext()) { - WbProtoInfo *info = it.next().value(); + const WbProtoInfo *info = it.next().value(); // don't display PROTOs which contain a "hidden" or a "deprecated" tag const QStringList tags = info->tags(); diff --git a/src/wren/Scene.cpp b/src/wren/Scene.cpp index 913277bb3a5..53b69d819e9 100644 --- a/src/wren/Scene.cpp +++ b/src/wren/Scene.cpp @@ -626,11 +626,11 @@ namespace wren { } } - static bool affectedByLight(Renderable *renderable, LightNode *light) { + static bool affectedByLight(const Renderable *renderable, const LightNode *light); bool visible = true; // Light culling if (light->type() != LightNode::TYPE_DIRECTIONAL) { - PositionalLight *positionalLight = static_cast(light); + const PositionalLight *positionalLight = static_cast(light); const primitive::Sphere &boundingSphere = renderable->boundingSphere(); const float distance = glm::distance(boundingSphere.mCenter, positionalLight->position()); const float radius = positionalLight->radius() + boundingSphere.mRadius; From f7626c43baeb4271c50e587c15efbd0fef15f443 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 13:10:22 +0100 Subject: [PATCH 06/19] Fix --- projects/samples/demos/controllers/moon/moon.c | 2 +- .../libraries/qt_utils/motion_editor/AddStateDialog.cpp | 2 +- .../projects/libraries/qt_utils/motion_editor/PoseEditor.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/samples/demos/controllers/moon/moon.c b/projects/samples/demos/controllers/moon/moon.c index 04e1984e6f5..d91fbb92dfd 100644 --- a/projects/samples/demos/controllers/moon/moon.c +++ b/projects/samples/demos/controllers/moon/moon.c @@ -37,7 +37,7 @@ int main() { double sensor_value[16]; double kUnit = 8.24; const double matrix[2][16] = {{3, -18, -15, -15, -5, -5, 4, 4, 6, 6, 4, 4, 4, 4, 3, -18}, - {-18, 3, 4, 4, 4, 4, 6, 6, 4, 4, -5, -5, -15, -15, -18, 3}}; + {-18, 3, 4, 4, 4, 4, 6, 6, 4, 4, -5, -5, -15, -15, -18, 3}}; wb_robot_init(); robot_name = wb_robot_get_name(); diff --git a/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp b/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp index 97836770700..1aa4a83e0ce 100644 --- a/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp +++ b/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp @@ -32,7 +32,7 @@ AddStateDialog::AddStateDialog(Motion *motion, QWidget *parent) : QDialog(parent populateListWidget(); QWidget *buttonsWidget = new QWidget(this); - QPushButton *const cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); + const QPushButton *const cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); QPushButton *okButton = new QPushButton(tr("Ok"), buttonsWidget); QHBoxLayout *hBoxLayout = new QHBoxLayout(buttonsWidget); hBoxLayout->addStretch(); diff --git a/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp b/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp index d18c496e907..98215c0de9b 100644 --- a/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp +++ b/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp @@ -36,7 +36,7 @@ PoseEditor::PoseEditor(Pose *pose, Pose *previousPose, Pose *nextPose, bool fixe formLayout->addRow(tr("&Milliseconds:"), mMilliSecondsSpinBox); QWidget *buttonsWidget = new QWidget(this); - QPushButton *const cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); + const QPushButton *const cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); QPushButton *okButton = new QPushButton(tr("Ok"), buttonsWidget); QHBoxLayout *hBoxLayout = new QHBoxLayout(buttonsWidget); hBoxLayout->addStretch(); From 1d55aa3a79f634b931b710d4ec59ca669c5251b1 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 13:13:35 +0100 Subject: [PATCH 07/19] Fix --- projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c b/projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c index d90956f5b9d..10bee53ae4e 100644 --- a/projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c +++ b/projects/robots/gctronic/e-puck/controllers/e-puck/e-puck.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { double speed[2]; double sensors_value[8]; const double braitenberg_coefficients[8][2] = {{0.942, -0.22}, {0.63, -0.1}, {0.5, -0.06}, {-0.06, -0.06}, - {-0.06, -0.06}, {-0.06, 0.5}, {-0.19, 0.63}, {-0.13, 0.942}}; + {-0.06, -0.06}, {-0.06, 0.5}, {-0.19, 0.63}, {-0.13, 0.942}}; int time_step; int camera_time_step; /* initialize Webots */ From ee41a9f46e3612a51f795457d62dc4329b51701e Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 13:28:28 +0100 Subject: [PATCH 08/19] Fix --- projects/samples/demos/controllers/moon/moon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/samples/demos/controllers/moon/moon.c b/projects/samples/demos/controllers/moon/moon.c index d91fbb92dfd..a52ab28bb9a 100644 --- a/projects/samples/demos/controllers/moon/moon.c +++ b/projects/samples/demos/controllers/moon/moon.c @@ -37,7 +37,7 @@ int main() { double sensor_value[16]; double kUnit = 8.24; const double matrix[2][16] = {{3, -18, -15, -15, -5, -5, 4, 4, 6, 6, 4, 4, 4, 4, 3, -18}, - {-18, 3, 4, 4, 4, 4, 6, 6, 4, 4, -5, -5, -15, -15, -18, 3}}; + {-18, 3, 4, 4, 4, 4, 6, 6, 4, 4, -5, -5, -15, -15, -18, 3}}; wb_robot_init(); robot_name = wb_robot_get_name(); From 9901b205d15d0543f4beba56012ceb2d107d5bbc Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 13:32:06 +0100 Subject: [PATCH 09/19] Fix --- projects/samples/demos/controllers/moon/moon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/samples/demos/controllers/moon/moon.c b/projects/samples/demos/controllers/moon/moon.c index a52ab28bb9a..d91fbb92dfd 100644 --- a/projects/samples/demos/controllers/moon/moon.c +++ b/projects/samples/demos/controllers/moon/moon.c @@ -37,7 +37,7 @@ int main() { double sensor_value[16]; double kUnit = 8.24; const double matrix[2][16] = {{3, -18, -15, -15, -5, -5, 4, 4, 6, 6, 4, 4, 4, 4, 3, -18}, - {-18, 3, 4, 4, 4, 4, 6, 6, 4, 4, -5, -5, -15, -15, -18, 3}}; + {-18, 3, 4, 4, 4, 4, 6, 6, 4, 4, -5, -5, -15, -15, -18, 3}}; wb_robot_init(); robot_name = wb_robot_get_name(); From 954f41aaf58fbf83fd333cd28a9e85d1d1f9dbf3 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 13:36:36 +0100 Subject: [PATCH 10/19] Fix --- src/wren/Scene.cpp | 414 ++++++++++++++++++++++----------------------- 1 file changed, 207 insertions(+), 207 deletions(-) diff --git a/src/wren/Scene.cpp b/src/wren/Scene.cpp index 53b69d819e9..1f0a0bbc5f3 100644 --- a/src/wren/Scene.cpp +++ b/src/wren/Scene.cpp @@ -627,242 +627,242 @@ namespace wren { } static bool affectedByLight(const Renderable *renderable, const LightNode *light); - bool visible = true; - // Light culling + bool visible = true; + // Light culling + if (light->type() != LightNode::TYPE_DIRECTIONAL) { + const PositionalLight *positionalLight = static_cast(light); + const primitive::Sphere &boundingSphere = renderable->boundingSphere(); + const float distance = glm::distance(boundingSphere.mCenter, positionalLight->position()); + const float radius = positionalLight->radius() + boundingSphere.mRadius; + // Check if light is too far away + visible = (distance <= radius && + (distance < boundingSphere.mRadius || // Light is inside the boundingSphere, necessary because pow(distance - + // boundingSphere.mRadius, 2) can be very big in this case. + positionalLight->attenuationConstant() + + (distance - boundingSphere.mRadius) * + (positionalLight->attenuationLinear() + + (distance - boundingSphere.mRadius) * positionalLight->attenuationQuadratic()) < + 2000.0f)); + // In the shaders, the attenuation is used as such: + // attenuationFactor = 1/(attenuation[0] + distanceToLight * (attenuation[1] + distanceToLight * attenuation[2]) + // color = 1/attenuationFactor * color * ... + // Due to this there is no well-defined upper bound for the attenuationFactor. + // 2000 is a trade-off value in which the remaining light is very weak but still visible. The light become really + // invisible around 8000. + } + return visible; +} + +void Scene::renderStencilPerLight(LightNode *light, RenderQueueIterator first, RenderQueueIterator firstShadowReceiver, + RenderQueueIterator last) { + if (light->castShadows()) { + assert(mShadowVolumeProgram); + mShadowVolumeProgram->bind(); + + Camera *camera = mCurrentViewport->camera(); + const primitive::Plane &farPlane = camera->frustum().plane(Frustum::FRUSTUM_PLANE_FAR); + + const primitive::Aabb &cameraAabb = camera->aabb(); + glm::vec3 cameraToLightInv; if (light->type() != LightNode::TYPE_DIRECTIONAL) { const PositionalLight *positionalLight = static_cast(light); - const primitive::Sphere &boundingSphere = renderable->boundingSphere(); - const float distance = glm::distance(boundingSphere.mCenter, positionalLight->position()); - const float radius = positionalLight->radius() + boundingSphere.mRadius; - // Check if light is too far away - visible = (distance <= radius && - (distance < boundingSphere.mRadius || // Light is inside the boundingSphere, necessary because pow(distance - - // boundingSphere.mRadius, 2) can be very big in this case. - positionalLight->attenuationConstant() + - (distance - boundingSphere.mRadius) * - (positionalLight->attenuationLinear() + - (distance - boundingSphere.mRadius) * positionalLight->attenuationQuadratic()) < - 2000.0f)); - // In the shaders, the attenuation is used as such: - // attenuationFactor = 1/(attenuation[0] + distanceToLight * (attenuation[1] + distanceToLight * attenuation[2]) - // color = 1/attenuationFactor * color * ... - // Due to this there is no well-defined upper bound for the attenuationFactor. - // 2000 is a trade-off value in which the remaining light is very weak but still visible. The light become really - // invisible around 8000. + cameraToLightInv = 1.0f / glm::normalize(positionalLight->position() - camera->position()); + } else { + const DirectionalLight *directionalLight = static_cast(light); + cameraToLightInv = 1.0f / -directionalLight->direction(); } - return visible; - } - void Scene::renderStencilPerLight(LightNode *light, RenderQueueIterator first, RenderQueueIterator firstShadowReceiver, - RenderQueueIterator last) { - if (light->castShadows()) { - assert(mShadowVolumeProgram); - mShadowVolumeProgram->bind(); + ShadowVolumeIterator firstInvisibleShadowVolume = + partitionShadowsByVisibility(mShadowVolumeQueue.begin(), mShadowVolumeQueue.end(), light); + for (ShadowVolumeIterator it = mShadowVolumeQueue.begin(); it < firstInvisibleShadowVolume; ++it) { + const primitive::Aabb renderableAabb = (*it)->renderable()->aabb(); - Camera *camera = mCurrentViewport->camera(); - const primitive::Plane &farPlane = camera->frustum().plane(Frustum::FRUSTUM_PLANE_FAR); - - const primitive::Aabb &cameraAabb = camera->aabb(); - glm::vec3 cameraToLightInv; - if (light->type() != LightNode::TYPE_DIRECTIONAL) { - const PositionalLight *positionalLight = static_cast(light); - cameraToLightInv = 1.0f / glm::normalize(positionalLight->position() - camera->position()); - } else { - const DirectionalLight *directionalLight = static_cast(light); - cameraToLightInv = 1.0f / -directionalLight->direction(); - } - - ShadowVolumeIterator firstInvisibleShadowVolume = - partitionShadowsByVisibility(mShadowVolumeQueue.begin(), mShadowVolumeQueue.end(), light); - for (ShadowVolumeIterator it = mShadowVolumeQueue.begin(); it < firstInvisibleShadowVolume; ++it) { - const primitive::Aabb renderableAabb = (*it)->renderable()->aabb(); + // Check if the renderable is affected by current light + if (!affectedByLight((*it)->renderable(), light) || !primitive::isAabbAbovePlane(farPlane, renderableAabb)) + continue; - // Check if the renderable is affected by current light - if (!affectedByLight((*it)->renderable(), light) || !primitive::isAabbAbovePlane(farPlane, renderableAabb)) - continue; + // Use depth fail if camera stands in the shadow volume + if (primitive::aabbCollision(cameraAabb, (*it)->aabb(light)) || + primitive::rayIntersectAabb(camera->position(), cameraToLightInv, renderableAabb, false)) + renderStencilShadowVolumesDepthFail(*it, light); + else + renderStencilShadowVolumesDepthPass(*it, light); - // Use depth fail if camera stands in the shadow volume - if (primitive::aabbCollision(cameraAabb, (*it)->aabb(light)) || - primitive::rayIntersectAabb(camera->position(), cameraToLightInv, renderableAabb, false)) - renderStencilShadowVolumesDepthFail(*it, light); - else - renderStencilShadowVolumesDepthPass(*it, light); - - if (config::showShadowAabbs()) { - config::drawAabb((*it)->aabb(light)); - mShadowVolumeProgram->bind(); - } + if (config::showShadowAabbs()) { + config::drawAabb((*it)->aabb(light)); + mShadowVolumeProgram->bind(); } - - if (first != firstShadowReceiver) - renderStencilDiffuseSpecular(first, firstShadowReceiver, light, false); - renderStencilDiffuseSpecular(firstShadowReceiver, last, light); - - glClear(GL_STENCIL_BUFFER_BIT); - } else - renderStencilDiffuseSpecular(first, last, light, false); - } - - void Scene::renderStencilShadowVolumesDepthPass(ShadowVolumeCaster *shadowVolume, LightNode *light) { - glstate::setDepthClamp(true); - glstate::setDepthMask(false); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LESS); - glstate::setStencilTest(true); - glstate::setStencilFunc(GL_ALWAYS, 0, ~0); - glstate::setCullFace(false); - glstate::setColorMask(false, false, false, false); - - // Special case for cw triangles - if (shadowVolume->renderable()->invertFrontFace()) { - glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_DECR_WRAP); - glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_INCR_WRAP); - } else { - glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_INCR_WRAP); - glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_DECR_WRAP); } - // Compute silhouette without caps - shadowVolume->computeSilhouette(light, false); - - glUniformMatrix4fv(mShadowVolumeProgram->uniformLocation(WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM), 1, false, - glm::value_ptr(shadowVolume->renderable()->parent()->matrix())); - shadowVolume->renderSides(light); - } + if (first != firstShadowReceiver) + renderStencilDiffuseSpecular(first, firstShadowReceiver, light, false); + renderStencilDiffuseSpecular(firstShadowReceiver, last, light); - void Scene::renderStencilShadowVolumesDepthFail(ShadowVolumeCaster *shadowVolume, LightNode *light) { - glstate::setDepthClamp(true); - glstate::setDepthMask(false); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_GEQUAL); - glstate::setStencilTest(true); - glstate::setStencilFunc(GL_ALWAYS, 0, ~0); - glstate::setCullFace(false); - glstate::setColorMask(false, false, false, false); - - // Special case for cw triangles - if (shadowVolume->renderable()->invertFrontFace()) { - glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_INCR_WRAP); - glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_DECR_WRAP); - } else { - glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_DECR_WRAP); - glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_INCR_WRAP); - } - - // Compute silhouette with caps - shadowVolume->computeSilhouette(light, true); + glClear(GL_STENCIL_BUFFER_BIT); + } else + renderStencilDiffuseSpecular(first, last, light, false); +} - glUniformMatrix4fv(mShadowVolumeProgram->uniformLocation(WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM), 1, false, - glm::value_ptr(shadowVolume->renderable()->parent()->matrix())); - shadowVolume->renderSides(light); +void Scene::renderStencilShadowVolumesDepthPass(ShadowVolumeCaster *shadowVolume, LightNode *light) { + glstate::setDepthClamp(true); + glstate::setDepthMask(false); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LESS); + glstate::setStencilTest(true); + glstate::setStencilFunc(GL_ALWAYS, 0, ~0); + glstate::setCullFace(false); + glstate::setColorMask(false, false, false, false); + + // Special case for cw triangles + if (shadowVolume->renderable()->invertFrontFace()) { + glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + } else { + glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + } + + // Compute silhouette without caps + shadowVolume->computeSilhouette(light, false); + + glUniformMatrix4fv(mShadowVolumeProgram->uniformLocation(WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM), 1, false, + glm::value_ptr(shadowVolume->renderable()->parent()->matrix())); + shadowVolume->renderSides(light); +} - shadowVolume->renderCaps(light); - } +void Scene::renderStencilShadowVolumesDepthFail(ShadowVolumeCaster *shadowVolume, LightNode *light) { + glstate::setDepthClamp(true); + glstate::setDepthMask(false); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_GEQUAL); + glstate::setStencilTest(true); + glstate::setStencilFunc(GL_ALWAYS, 0, ~0); + glstate::setCullFace(false); + glstate::setColorMask(false, false, false, false); + + // Special case for cw triangles + if (shadowVolume->renderable()->invertFrontFace()) { + glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + } else { + glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + } + + // Compute silhouette with caps + shadowVolume->computeSilhouette(light, true); + + glUniformMatrix4fv(mShadowVolumeProgram->uniformLocation(WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM), 1, false, + glm::value_ptr(shadowVolume->renderable()->parent()->matrix())); + shadowVolume->renderSides(light); + + shadowVolume->renderCaps(light); +} - void Scene::renderStencilAmbientEmissive(RenderQueueIterator first, RenderQueueIterator last) { - glstate::setBlend(false); - glstate::setDepthClamp(false); - glstate::setDepthMask(true); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LESS); - glstate::setStencilTest(false); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); +void Scene::renderStencilAmbientEmissive(RenderQueueIterator first, RenderQueueIterator last) { + glstate::setBlend(false); + glstate::setDepthClamp(false); + glstate::setDepthMask(true); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LESS); + glstate::setStencilTest(false); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); - for (auto it = first; it < last; ++it) { - assert((*it)->effectiveMaterial()->stencilAmbientEmissiveProgram()); + for (auto it = first; it < last; ++it) { + assert((*it)->effectiveMaterial()->stencilAmbientEmissiveProgram()); - (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_STENCIL_AMBIENT_EMISSIVE); - (*it)->render(); - } + (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_STENCIL_AMBIENT_EMISSIVE); + (*it)->render(); } +} - void Scene::renderStencilDiffuseSpecular(RenderQueueIterator first, RenderQueueIterator last, LightNode *light, - bool applyShadows) { - glstate::setBlend(true); - glstate::setBlendEquation(GL_FUNC_ADD); - glstate::setBlendFunc(GL_ONE, GL_ONE); - glstate::setDepthClamp(false); - glstate::setDepthMask(false); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LEQUAL); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); - - if (applyShadows) { - glstate::setStencilTest(true); - glstate::setStencilFunc(GL_EQUAL, 0, ~0); - glstate::setStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - } else - glstate::setStencilTest(false); +void Scene::renderStencilDiffuseSpecular(RenderQueueIterator first, RenderQueueIterator last, LightNode *light, + bool applyShadows) { + glstate::setBlend(true); + glstate::setBlendEquation(GL_FUNC_ADD); + glstate::setBlendFunc(GL_ONE, GL_ONE); + glstate::setDepthClamp(false); + glstate::setDepthMask(false); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LEQUAL); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); + + if (applyShadows) { + glstate::setStencilTest(true); + glstate::setStencilFunc(GL_EQUAL, 0, ~0); + glstate::setStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + } else + glstate::setStencilTest(false); - for (auto it = first; it < last; ++it) { - if (!affectedByLight(*it, light)) - continue; + for (auto it = first; it < last; ++it) { + if (!affectedByLight(*it, light)) + continue; - assert((*it)->effectiveMaterial()->stencilDiffuseSpecularProgram()); + assert((*it)->effectiveMaterial()->stencilDiffuseSpecularProgram()); - (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_STENCIL_DIFFUSE_SPECULAR); - (*it)->render(); - } + (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_STENCIL_DIFFUSE_SPECULAR); + (*it)->render(); } +} - void Scene::renderStencilFog(RenderQueueIterator first, RenderQueueIterator last) const { - glstate::setBlend(true); - glstate::setBlendEquation(GL_FUNC_ADD); - glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glstate::setDepthClamp(false); - glstate::setDepthMask(false); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LEQUAL); - glstate::setStencilTest(false); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); - - for (auto it = first; it < last; ++it) - (*it)->renderWithoutMaterial(mFogProgram); - } +void Scene::renderStencilFog(RenderQueueIterator first, RenderQueueIterator last) const { + glstate::setBlend(true); + glstate::setBlendEquation(GL_FUNC_ADD); + glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glstate::setDepthClamp(false); + glstate::setDepthMask(false); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LEQUAL); + glstate::setStencilTest(false); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); + + for (auto it = first; it < last; ++it) + (*it)->renderWithoutMaterial(mFogProgram); +} - void Scene::renderStencilWithoutProgram(RenderQueueIterator first, RenderQueueIterator last) { - glstate::setBlend(true); - glstate::setBlendEquation(GL_FUNC_ADD); - glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glstate::setDepthClamp(false); - glstate::setDepthMask(true); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LESS); - glstate::setStencilTest(false); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); +void Scene::renderStencilWithoutProgram(RenderQueueIterator first, RenderQueueIterator last) { + glstate::setBlend(true); + glstate::setBlendEquation(GL_FUNC_ADD); + glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glstate::setDepthClamp(false); + glstate::setDepthMask(true); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LESS); + glstate::setStencilTest(false); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); - for (auto it = first; it < last; ++it) { - assert((*it)->effectiveMaterial()); + for (auto it = first; it < last; ++it) { + assert((*it)->effectiveMaterial()); - (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_DEFAULT); - (*it)->render(); - } + (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_DEFAULT); + (*it)->render(); } +} - void Scene::renderTranslucent(RenderQueueIterator first, RenderQueueIterator last, bool disableDepthTest) { - glstate::setBlend(true); - glstate::setBlendEquation(GL_FUNC_ADD); - glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glstate::setDepthClamp(false); - glstate::setDepthMask(false); - glstate::setDepthTest(!disableDepthTest); - glstate::setDepthFunc(GL_LESS); - glstate::setStencilTest(false); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); - - for (auto it = first; it < last; ++it) { - if (!(*it)->effectiveMaterial()) - continue; - - (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_DEFAULT); - (*it)->render(); - } +void Scene::renderTranslucent(RenderQueueIterator first, RenderQueueIterator last, bool disableDepthTest) { + glstate::setBlend(true); + glstate::setBlendEquation(GL_FUNC_ADD); + glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glstate::setDepthClamp(false); + glstate::setDepthMask(false); + glstate::setDepthTest(!disableDepthTest); + glstate::setDepthFunc(GL_LESS); + glstate::setStencilTest(false); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); + + for (auto it = first; it < last; ++it) { + if (!(*it)->effectiveMaterial()) + continue; + + (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_DEFAULT); + (*it)->render(); } +} } // namespace wren From 28855ec68dde3ae8ee0d2f904ccce248d514791b Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 13:49:26 +0100 Subject: [PATCH 11/19] Fix --- src/wren/Scene.cpp | 416 ++++++++++++++++++++++----------------------- 1 file changed, 208 insertions(+), 208 deletions(-) diff --git a/src/wren/Scene.cpp b/src/wren/Scene.cpp index 1f0a0bbc5f3..92e3c96ab79 100644 --- a/src/wren/Scene.cpp +++ b/src/wren/Scene.cpp @@ -626,243 +626,243 @@ namespace wren { } } - static bool affectedByLight(const Renderable *renderable, const LightNode *light); - bool visible = true; - // Light culling - if (light->type() != LightNode::TYPE_DIRECTIONAL) { - const PositionalLight *positionalLight = static_cast(light); - const primitive::Sphere &boundingSphere = renderable->boundingSphere(); - const float distance = glm::distance(boundingSphere.mCenter, positionalLight->position()); - const float radius = positionalLight->radius() + boundingSphere.mRadius; - // Check if light is too far away - visible = (distance <= radius && - (distance < boundingSphere.mRadius || // Light is inside the boundingSphere, necessary because pow(distance - - // boundingSphere.mRadius, 2) can be very big in this case. - positionalLight->attenuationConstant() + - (distance - boundingSphere.mRadius) * - (positionalLight->attenuationLinear() + - (distance - boundingSphere.mRadius) * positionalLight->attenuationQuadratic()) < - 2000.0f)); - // In the shaders, the attenuation is used as such: - // attenuationFactor = 1/(attenuation[0] + distanceToLight * (attenuation[1] + distanceToLight * attenuation[2]) - // color = 1/attenuationFactor * color * ... - // Due to this there is no well-defined upper bound for the attenuationFactor. - // 2000 is a trade-off value in which the remaining light is very weak but still visible. The light become really - // invisible around 8000. - } - return visible; -} - -void Scene::renderStencilPerLight(LightNode *light, RenderQueueIterator first, RenderQueueIterator firstShadowReceiver, - RenderQueueIterator last) { - if (light->castShadows()) { - assert(mShadowVolumeProgram); - mShadowVolumeProgram->bind(); - - Camera *camera = mCurrentViewport->camera(); - const primitive::Plane &farPlane = camera->frustum().plane(Frustum::FRUSTUM_PLANE_FAR); - - const primitive::Aabb &cameraAabb = camera->aabb(); - glm::vec3 cameraToLightInv; + static bool affectedByLight(const Renderable *renderable, const LightNode *light) { + bool visible = true; + // Light culling if (light->type() != LightNode::TYPE_DIRECTIONAL) { const PositionalLight *positionalLight = static_cast(light); - cameraToLightInv = 1.0f / glm::normalize(positionalLight->position() - camera->position()); - } else { - const DirectionalLight *directionalLight = static_cast(light); - cameraToLightInv = 1.0f / -directionalLight->direction(); + const primitive::Sphere &boundingSphere = renderable->boundingSphere(); + const float distance = glm::distance(boundingSphere.mCenter, positionalLight->position()); + const float radius = positionalLight->radius() + boundingSphere.mRadius; + // Check if light is too far away + visible = (distance <= radius && + (distance < boundingSphere.mRadius || // Light is inside the boundingSphere, necessary because pow(distance - + // boundingSphere.mRadius, 2) can be very big in this case. + positionalLight->attenuationConstant() + + (distance - boundingSphere.mRadius) * + (positionalLight->attenuationLinear() + + (distance - boundingSphere.mRadius) * positionalLight->attenuationQuadratic()) < + 2000.0f)); + // In the shaders, the attenuation is used as such: + // attenuationFactor = 1/(attenuation[0] + distanceToLight * (attenuation[1] + distanceToLight * attenuation[2]) + // color = 1/attenuationFactor * color * ... + // Due to this there is no well-defined upper bound for the attenuationFactor. + // 2000 is a trade-off value in which the remaining light is very weak but still visible. The light become really + // invisible around 8000. } + return visible; + } - ShadowVolumeIterator firstInvisibleShadowVolume = - partitionShadowsByVisibility(mShadowVolumeQueue.begin(), mShadowVolumeQueue.end(), light); - for (ShadowVolumeIterator it = mShadowVolumeQueue.begin(); it < firstInvisibleShadowVolume; ++it) { - const primitive::Aabb renderableAabb = (*it)->renderable()->aabb(); - - // Check if the renderable is affected by current light - if (!affectedByLight((*it)->renderable(), light) || !primitive::isAabbAbovePlane(farPlane, renderableAabb)) - continue; + void Scene::renderStencilPerLight(LightNode *light, RenderQueueIterator first, RenderQueueIterator firstShadowReceiver, + RenderQueueIterator last) { + if (light->castShadows()) { + assert(mShadowVolumeProgram); + mShadowVolumeProgram->bind(); - // Use depth fail if camera stands in the shadow volume - if (primitive::aabbCollision(cameraAabb, (*it)->aabb(light)) || - primitive::rayIntersectAabb(camera->position(), cameraToLightInv, renderableAabb, false)) - renderStencilShadowVolumesDepthFail(*it, light); - else - renderStencilShadowVolumesDepthPass(*it, light); + Camera *camera = mCurrentViewport->camera(); + const primitive::Plane &farPlane = camera->frustum().plane(Frustum::FRUSTUM_PLANE_FAR); - if (config::showShadowAabbs()) { - config::drawAabb((*it)->aabb(light)); - mShadowVolumeProgram->bind(); + const primitive::Aabb &cameraAabb = camera->aabb(); + glm::vec3 cameraToLightInv; + if (light->type() != LightNode::TYPE_DIRECTIONAL) { + const PositionalLight *positionalLight = static_cast(light); + cameraToLightInv = 1.0f / glm::normalize(positionalLight->position() - camera->position()); + } else { + const DirectionalLight *directionalLight = static_cast(light); + cameraToLightInv = 1.0f / -directionalLight->direction(); } - } - if (first != firstShadowReceiver) - renderStencilDiffuseSpecular(first, firstShadowReceiver, light, false); - renderStencilDiffuseSpecular(firstShadowReceiver, last, light); + ShadowVolumeIterator firstInvisibleShadowVolume = + partitionShadowsByVisibility(mShadowVolumeQueue.begin(), mShadowVolumeQueue.end(), light); + for (ShadowVolumeIterator it = mShadowVolumeQueue.begin(); it < firstInvisibleShadowVolume; ++it) { + const primitive::Aabb renderableAabb = (*it)->renderable()->aabb(); - glClear(GL_STENCIL_BUFFER_BIT); - } else - renderStencilDiffuseSpecular(first, last, light, false); -} + // Check if the renderable is affected by current light + if (!affectedByLight((*it)->renderable(), light) || !primitive::isAabbAbovePlane(farPlane, renderableAabb)) + continue; -void Scene::renderStencilShadowVolumesDepthPass(ShadowVolumeCaster *shadowVolume, LightNode *light) { - glstate::setDepthClamp(true); - glstate::setDepthMask(false); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LESS); - glstate::setStencilTest(true); - glstate::setStencilFunc(GL_ALWAYS, 0, ~0); - glstate::setCullFace(false); - glstate::setColorMask(false, false, false, false); - - // Special case for cw triangles - if (shadowVolume->renderable()->invertFrontFace()) { - glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_DECR_WRAP); - glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_INCR_WRAP); - } else { - glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_INCR_WRAP); - glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_DECR_WRAP); - } - - // Compute silhouette without caps - shadowVolume->computeSilhouette(light, false); - - glUniformMatrix4fv(mShadowVolumeProgram->uniformLocation(WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM), 1, false, - glm::value_ptr(shadowVolume->renderable()->parent()->matrix())); - shadowVolume->renderSides(light); -} + // Use depth fail if camera stands in the shadow volume + if (primitive::aabbCollision(cameraAabb, (*it)->aabb(light)) || + primitive::rayIntersectAabb(camera->position(), cameraToLightInv, renderableAabb, false)) + renderStencilShadowVolumesDepthFail(*it, light); + else + renderStencilShadowVolumesDepthPass(*it, light); -void Scene::renderStencilShadowVolumesDepthFail(ShadowVolumeCaster *shadowVolume, LightNode *light) { - glstate::setDepthClamp(true); - glstate::setDepthMask(false); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_GEQUAL); - glstate::setStencilTest(true); - glstate::setStencilFunc(GL_ALWAYS, 0, ~0); - glstate::setCullFace(false); - glstate::setColorMask(false, false, false, false); - - // Special case for cw triangles - if (shadowVolume->renderable()->invertFrontFace()) { - glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_INCR_WRAP); - glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_DECR_WRAP); - } else { - glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_DECR_WRAP); - glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_INCR_WRAP); - } - - // Compute silhouette with caps - shadowVolume->computeSilhouette(light, true); - - glUniformMatrix4fv(mShadowVolumeProgram->uniformLocation(WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM), 1, false, - glm::value_ptr(shadowVolume->renderable()->parent()->matrix())); - shadowVolume->renderSides(light); - - shadowVolume->renderCaps(light); -} + if (config::showShadowAabbs()) { + config::drawAabb((*it)->aabb(light)); + mShadowVolumeProgram->bind(); + } + } + + if (first != firstShadowReceiver) + renderStencilDiffuseSpecular(first, firstShadowReceiver, light, false); + renderStencilDiffuseSpecular(firstShadowReceiver, last, light); -void Scene::renderStencilAmbientEmissive(RenderQueueIterator first, RenderQueueIterator last) { - glstate::setBlend(false); - glstate::setDepthClamp(false); - glstate::setDepthMask(true); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LESS); - glstate::setStencilTest(false); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); + glClear(GL_STENCIL_BUFFER_BIT); + } else + renderStencilDiffuseSpecular(first, last, light, false); + } + + void Scene::renderStencilShadowVolumesDepthPass(ShadowVolumeCaster *shadowVolume, LightNode *light) { + glstate::setDepthClamp(true); + glstate::setDepthMask(false); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LESS); + glstate::setStencilTest(true); + glstate::setStencilFunc(GL_ALWAYS, 0, ~0); + glstate::setCullFace(false); + glstate::setColorMask(false, false, false, false); + + // Special case for cw triangles + if (shadowVolume->renderable()->invertFrontFace()) { + glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + } else { + glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + } - for (auto it = first; it < last; ++it) { - assert((*it)->effectiveMaterial()->stencilAmbientEmissiveProgram()); + // Compute silhouette without caps + shadowVolume->computeSilhouette(light, false); - (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_STENCIL_AMBIENT_EMISSIVE); - (*it)->render(); + glUniformMatrix4fv(mShadowVolumeProgram->uniformLocation(WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM), 1, false, + glm::value_ptr(shadowVolume->renderable()->parent()->matrix())); + shadowVolume->renderSides(light); } -} -void Scene::renderStencilDiffuseSpecular(RenderQueueIterator first, RenderQueueIterator last, LightNode *light, - bool applyShadows) { - glstate::setBlend(true); - glstate::setBlendEquation(GL_FUNC_ADD); - glstate::setBlendFunc(GL_ONE, GL_ONE); - glstate::setDepthClamp(false); - glstate::setDepthMask(false); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LEQUAL); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); - - if (applyShadows) { + void Scene::renderStencilShadowVolumesDepthFail(ShadowVolumeCaster *shadowVolume, LightNode *light) { + glstate::setDepthClamp(true); + glstate::setDepthMask(false); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_GEQUAL); glstate::setStencilTest(true); - glstate::setStencilFunc(GL_EQUAL, 0, ~0); - glstate::setStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - } else + glstate::setStencilFunc(GL_ALWAYS, 0, ~0); + glstate::setCullFace(false); + glstate::setColorMask(false, false, false, false); + + // Special case for cw triangles + if (shadowVolume->renderable()->invertFrontFace()) { + glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + } else { + glstate::setStencilOpFront(GL_KEEP, GL_KEEP, GL_DECR_WRAP); + glstate::setStencilOpBack(GL_KEEP, GL_KEEP, GL_INCR_WRAP); + } + + // Compute silhouette with caps + shadowVolume->computeSilhouette(light, true); + + glUniformMatrix4fv(mShadowVolumeProgram->uniformLocation(WR_GLSL_LAYOUT_UNIFORM_MODEL_TRANSFORM), 1, false, + glm::value_ptr(shadowVolume->renderable()->parent()->matrix())); + shadowVolume->renderSides(light); + + shadowVolume->renderCaps(light); + } + + void Scene::renderStencilAmbientEmissive(RenderQueueIterator first, RenderQueueIterator last) { + glstate::setBlend(false); + glstate::setDepthClamp(false); + glstate::setDepthMask(true); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LESS); glstate::setStencilTest(false); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); - for (auto it = first; it < last; ++it) { - if (!affectedByLight(*it, light)) - continue; + for (auto it = first; it < last; ++it) { + assert((*it)->effectiveMaterial()->stencilAmbientEmissiveProgram()); - assert((*it)->effectiveMaterial()->stencilDiffuseSpecularProgram()); + (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_STENCIL_AMBIENT_EMISSIVE); + (*it)->render(); + } + } - (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_STENCIL_DIFFUSE_SPECULAR); - (*it)->render(); + void Scene::renderStencilDiffuseSpecular(RenderQueueIterator first, RenderQueueIterator last, LightNode *light, + bool applyShadows) { + glstate::setBlend(true); + glstate::setBlendEquation(GL_FUNC_ADD); + glstate::setBlendFunc(GL_ONE, GL_ONE); + glstate::setDepthClamp(false); + glstate::setDepthMask(false); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LEQUAL); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); + + if (applyShadows) { + glstate::setStencilTest(true); + glstate::setStencilFunc(GL_EQUAL, 0, ~0); + glstate::setStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + } else + glstate::setStencilTest(false); + + for (auto it = first; it < last; ++it) { + if (!affectedByLight(*it, light)) + continue; + + assert((*it)->effectiveMaterial()->stencilDiffuseSpecularProgram()); + + (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_STENCIL_DIFFUSE_SPECULAR); + (*it)->render(); + } } -} -void Scene::renderStencilFog(RenderQueueIterator first, RenderQueueIterator last) const { - glstate::setBlend(true); - glstate::setBlendEquation(GL_FUNC_ADD); - glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glstate::setDepthClamp(false); - glstate::setDepthMask(false); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LEQUAL); - glstate::setStencilTest(false); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); - - for (auto it = first; it < last; ++it) - (*it)->renderWithoutMaterial(mFogProgram); -} + void Scene::renderStencilFog(RenderQueueIterator first, RenderQueueIterator last) const { + glstate::setBlend(true); + glstate::setBlendEquation(GL_FUNC_ADD); + glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glstate::setDepthClamp(false); + glstate::setDepthMask(false); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LEQUAL); + glstate::setStencilTest(false); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); -void Scene::renderStencilWithoutProgram(RenderQueueIterator first, RenderQueueIterator last) { - glstate::setBlend(true); - glstate::setBlendEquation(GL_FUNC_ADD); - glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glstate::setDepthClamp(false); - glstate::setDepthMask(true); - glstate::setDepthTest(true); - glstate::setDepthFunc(GL_LESS); - glstate::setStencilTest(false); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); + for (auto it = first; it < last; ++it) + (*it)->renderWithoutMaterial(mFogProgram); + } + + void Scene::renderStencilWithoutProgram(RenderQueueIterator first, RenderQueueIterator last) { + glstate::setBlend(true); + glstate::setBlendEquation(GL_FUNC_ADD); + glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glstate::setDepthClamp(false); + glstate::setDepthMask(true); + glstate::setDepthTest(true); + glstate::setDepthFunc(GL_LESS); + glstate::setStencilTest(false); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); - for (auto it = first; it < last; ++it) { - assert((*it)->effectiveMaterial()); + for (auto it = first; it < last; ++it) { + assert((*it)->effectiveMaterial()); - (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_DEFAULT); - (*it)->render(); + (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_DEFAULT); + (*it)->render(); + } } -} -void Scene::renderTranslucent(RenderQueueIterator first, RenderQueueIterator last, bool disableDepthTest) { - glstate::setBlend(true); - glstate::setBlendEquation(GL_FUNC_ADD); - glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glstate::setDepthClamp(false); - glstate::setDepthMask(false); - glstate::setDepthTest(!disableDepthTest); - glstate::setDepthFunc(GL_LESS); - glstate::setStencilTest(false); - glstate::setCullFace(true); - glstate::setColorMask(true, true, true, true); - - for (auto it = first; it < last; ++it) { - if (!(*it)->effectiveMaterial()) - continue; - - (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_DEFAULT); - (*it)->render(); + void Scene::renderTranslucent(RenderQueueIterator first, RenderQueueIterator last, bool disableDepthTest) { + glstate::setBlend(true); + glstate::setBlendEquation(GL_FUNC_ADD); + glstate::setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glstate::setDepthClamp(false); + glstate::setDepthMask(false); + glstate::setDepthTest(!disableDepthTest); + glstate::setDepthFunc(GL_LESS); + glstate::setStencilTest(false); + glstate::setCullFace(true); + glstate::setColorMask(true, true, true, true); + + for (auto it = first; it < last; ++it) { + if (!(*it)->effectiveMaterial()) + continue; + + (*it)->effectiveMaterial()->setEffectiveProgram(Material::MATERIAL_PROGRAM_DEFAULT); + (*it)->render(); + } } -} } // namespace wren From d5f03b29545cddc5e809d2145b745c7cc491bbc3 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 14:01:13 +0100 Subject: [PATCH 12/19] Fix --- src/wren/Scene.cpp | 2 +- src/wren/Scene.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wren/Scene.cpp b/src/wren/Scene.cpp index 92e3c96ab79..38f94a336b8 100644 --- a/src/wren/Scene.cpp +++ b/src/wren/Scene.cpp @@ -777,7 +777,7 @@ namespace wren { } } - void Scene::renderStencilDiffuseSpecular(RenderQueueIterator first, RenderQueueIterator last, LightNode *light, + void Scene::renderStencilDiffuseSpecular(RenderQueueIterator first, RenderQueueIterator last, const LightNode *light, bool applyShadows) { glstate::setBlend(true); glstate::setBlendEquation(GL_FUNC_ADD); diff --git a/src/wren/Scene.hpp b/src/wren/Scene.hpp index 5e8b4ea032b..0cf43b3d141 100644 --- a/src/wren/Scene.hpp +++ b/src/wren/Scene.hpp @@ -125,7 +125,7 @@ namespace wren { void renderStencilShadowVolumesDepthPass(ShadowVolumeCaster *shadowVolume, LightNode *light); void renderStencilShadowVolumesDepthFail(ShadowVolumeCaster *shadowVolume, LightNode *light); static void renderStencilAmbientEmissive(RenderQueueIterator first, RenderQueueIterator last); - static void renderStencilDiffuseSpecular(RenderQueueIterator first, RenderQueueIterator last, LightNode *light, + static void renderStencilDiffuseSpecular(RenderQueueIterator first, RenderQueueIterator last, const LightNode *light, bool applyShadows = true); void renderStencilFog(RenderQueueIterator first, RenderQueueIterator last) const; static void renderStencilWithoutProgram(RenderQueueIterator first, RenderQueueIterator last); From 1cdcc95c91178b6aa1a6976023185c6c82a3bbf5 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 14:57:24 +0100 Subject: [PATCH 13/19] Fix windows test --- .../projects/libraries/qt_utils/motion_editor/Pose.cpp | 2 +- src/webots/app/WbApplication.cpp | 2 +- src/webots/control/WbControlledWorld.cpp | 2 +- src/webots/core/WbGuiRefreshOracle.cpp | 2 +- src/webots/core/WbTelemetry.cpp | 2 +- src/webots/core/WbWebotsUpdateManager.cpp | 2 +- src/webots/engine/WbAnimationRecorder.cpp | 2 +- src/webots/gui/WbGuidedTour.cpp | 2 +- src/webots/gui/WbMainWindow.cpp | 2 +- src/webots/gui/WbNewProjectWizard.cpp | 2 +- src/webots/gui/WbNewVersionDialog.cpp | 2 +- src/webots/gui/WbWebotsUpdateDialog.cpp | 2 +- src/webots/nodes/WbBaseNode.cpp | 5 +++-- src/webots/nodes/WbBasicJoint.cpp | 2 +- src/webots/nodes/WbCadShape.cpp | 2 +- src/webots/nodes/WbHinge2Joint.cpp | 2 +- src/webots/nodes/WbJoint.cpp | 2 +- src/webots/nodes/WbLed.cpp | 4 ++-- src/webots/nodes/WbPose.cpp | 3 ++- src/webots/nodes/WbRobot.cpp | 5 +++-- src/webots/nodes/WbSolid.cpp | 2 +- src/webots/nodes/WbTrack.cpp | 8 ++++---- src/webots/nodes/utils/WbNodeOperations.cpp | 3 +-- src/webots/nodes/utils/WbNodeUtilities.cpp | 9 ++++++--- src/webots/scene_tree/WbSceneTreeModel.cpp | 2 +- src/webots/vrml/WbNode.cpp | 4 ++-- 26 files changed, 41 insertions(+), 36 deletions(-) diff --git a/resources/projects/libraries/qt_utils/motion_editor/Pose.cpp b/resources/projects/libraries/qt_utils/motion_editor/Pose.cpp index af35550680b..5ec92709b18 100644 --- a/resources/projects/libraries/qt_utils/motion_editor/Pose.cpp +++ b/resources/projects/libraries/qt_utils/motion_editor/Pose.cpp @@ -17,7 +17,7 @@ Pose::Pose(const Pose &other) : mName(other.mName), mTime(other.mTime), mIsValid int size = other.mStates.size(); mStates.reserve(size); foreach (const MotorTargetState *item, other.mStates) { - MotorTargetState *const state = new MotorTargetState(*item); + const MotorTargetState *state = new MotorTargetState(*item); mStates.append(state); connect(state, SIGNAL(updated()), this, SLOT(propagateStateUpdate())); connect(state, SIGNAL(validChanged()), this, SLOT(updateIsValid())); diff --git a/src/webots/app/WbApplication.cpp b/src/webots/app/WbApplication.cpp index 4dab5fd6b8d..f95aaf5ed9a 100644 --- a/src/webots/app/WbApplication.cpp +++ b/src/webots/app/WbApplication.cpp @@ -122,7 +122,7 @@ WbApplication::~WbApplication() { } void WbApplication::setup() { - WbNodeOperations *const nodeOperations = WbNodeOperations::instance(); + const WbNodeOperations *nodeOperations = WbNodeOperations::instance(); // create and connect WbAnimationRecorder WbAnimationRecorder *recorder = WbAnimationRecorder::instance(); diff --git a/src/webots/control/WbControlledWorld.cpp b/src/webots/control/WbControlledWorld.cpp index 4742d2909b6..58b9a0eb368 100644 --- a/src/webots/control/WbControlledWorld.cpp +++ b/src/webots/control/WbControlledWorld.cpp @@ -145,7 +145,7 @@ void WbControlledWorld::retryStepLater() { emit stepBlocked(true); } // call the step() function again when a WbController received some data from the libController - foreach (WbController *const controller, mControllers) + foreach (const WbController *const controller, mControllers) connect(controller, &WbController::requestReceived, this, &WbControlledWorld::step, Qt::UniqueConnection); } diff --git a/src/webots/core/WbGuiRefreshOracle.cpp b/src/webots/core/WbGuiRefreshOracle.cpp index b70a7151514..a08ad21a49e 100644 --- a/src/webots/core/WbGuiRefreshOracle.cpp +++ b/src/webots/core/WbGuiRefreshOracle.cpp @@ -35,7 +35,7 @@ void WbGuiRefreshOracle::cleanup() { WbGuiRefreshOracle::WbGuiRefreshOracle() : mCanRefreshNow(true) { qAddPostRoutine(WbGuiRefreshOracle::cleanup); - WbSimulationState *state = WbSimulationState::instance(); + const WbSimulationState *state = WbSimulationState::instance(); connect(state, &WbSimulationState::modeChanged, this, &WbGuiRefreshOracle::updateFlags); connect(state, &WbSimulationState::controllerReadRequestsCompleted, this, &WbGuiRefreshOracle::updateFlags); connect(&mGlobalRefreshTimer, &QTimer::timeout, this, &WbGuiRefreshOracle::updateFlags); diff --git a/src/webots/core/WbTelemetry.cpp b/src/webots/core/WbTelemetry.cpp index 736c466551e..daeca551030 100644 --- a/src/webots/core/WbTelemetry.cpp +++ b/src/webots/core/WbTelemetry.cpp @@ -71,7 +71,7 @@ void WbTelemetry::sendRequest(const QString &operation) { data.append("&build="); data.append(QString::number(UNIX_TIMESTAMP).toUtf8()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); - QNetworkReply *const reply = WbNetwork::instance()->networkAccessManager()->post(request, data); + const QNetworkReply *reply = WbNetwork::instance()->networkAccessManager()->post(request, data); if (id == 0) { QEventLoop loop; QTimer timer; diff --git a/src/webots/core/WbWebotsUpdateManager.cpp b/src/webots/core/WbWebotsUpdateManager.cpp index 4d25a293213..88da9b94858 100644 --- a/src/webots/core/WbWebotsUpdateManager.cpp +++ b/src/webots/core/WbWebotsUpdateManager.cpp @@ -50,7 +50,7 @@ void WbWebotsUpdateManager::cleanup() { void WbWebotsUpdateManager::sendRequest() { QNetworkRequest request; request.setUrl(QUrl("https://api.github.com/repos/cyberbotics/webots/releases/latest")); - QNetworkReply *const reply = WbNetwork::instance()->networkAccessManager()->get(request); + const QNetworkReply *reply = WbNetwork::instance()->networkAccessManager()->get(request); connect(reply, &QNetworkReply::finished, this, &WbWebotsUpdateManager::downloadReplyFinished, Qt::UniqueConnection); } diff --git a/src/webots/engine/WbAnimationRecorder.cpp b/src/webots/engine/WbAnimationRecorder.cpp index 7716a49d7d9..37c574e64ce 100644 --- a/src/webots/engine/WbAnimationRecorder.cpp +++ b/src/webots/engine/WbAnimationRecorder.cpp @@ -272,7 +272,7 @@ void WbAnimationRecorder::populateCommands() { } } - foreach (WbAnimationCommand *command, mCommands) { + foreach (const WbAnimationCommand *command, mCommands) { connect(command, &WbAnimationCommand::changed, this, &WbAnimationRecorder::addChangedCommandToList); // support node deletions connect(command->node(), &WbNode::destroyed, this, &WbAnimationRecorder::updateCommandsAfterNodeDeletion); diff --git a/src/webots/gui/WbGuidedTour.cpp b/src/webots/gui/WbGuidedTour.cpp index d7e5ab12b36..c87c0d39cc2 100644 --- a/src/webots/gui/WbGuidedTour.cpp +++ b/src/webots/gui/WbGuidedTour.cpp @@ -97,7 +97,7 @@ WbGuidedTour::WbGuidedTour(QWidget *parent) : mNextButton = new QPushButton(tr("Next"), this); mNextButton->setDefault(true); mNextButton->setAutoDefault(true); - QPushButton *closeButton = new QPushButton(tr("Close"), this); + const QPushButton *closeButton = new QPushButton(tr("Close"), this); connect(closeButton, &QPushButton::pressed, this, &WbGuidedTour::close); connect(mPrevButton, &QPushButton::pressed, this, &WbGuidedTour::prev); diff --git a/src/webots/gui/WbMainWindow.cpp b/src/webots/gui/WbMainWindow.cpp index c4eda92d3e9..f6e4371e1de 100644 --- a/src/webots/gui/WbMainWindow.cpp +++ b/src/webots/gui/WbMainWindow.cpp @@ -196,7 +196,7 @@ WbMainWindow::WbMainWindow(bool minimizedOnStart, WbTcpServer *tcpServer, QWidge connect(mAnimationRecordingTimer, &QTimer::timeout, this, &WbMainWindow::toggleAnimationIcon); toggleAnimationAction(false); - WbAnimationRecorder *recorder = WbAnimationRecorder::instance(); + const WbAnimationRecorder *recorder = WbAnimationRecorder::instance(); connect(recorder, &WbAnimationRecorder::initalizedFromStreamingServer, this, &WbMainWindow::disableAnimationAction); connect(recorder, &WbAnimationRecorder::cleanedUpFromStreamingServer, this, &WbMainWindow::enableAnimationAction); connect(recorder, &WbAnimationRecorder::requestOpenUrl, this, diff --git a/src/webots/gui/WbNewProjectWizard.cpp b/src/webots/gui/WbNewProjectWizard.cpp index f285612c55d..97930ab9e67 100644 --- a/src/webots/gui/WbNewProjectWizard.cpp +++ b/src/webots/gui/WbNewProjectWizard.cpp @@ -124,7 +124,7 @@ QWizardPage *WbNewProjectWizard::createDirectoryPage() { page->setTitle(tr("Directory selection")); page->setSubTitle(tr("Please choose a directory for your new project:")); mDirEdit = new WbLineEdit(page); - QPushButton *const chooseButton = new QPushButton(tr("Choose"), page); + const QPushButton *chooseButton = new QPushButton(tr("Choose"), page); connect(chooseButton, &QPushButton::pressed, this, &WbNewProjectWizard::chooseDirectory); QHBoxLayout *layout = new QHBoxLayout(page); layout->addWidget(mDirEdit); diff --git a/src/webots/gui/WbNewVersionDialog.cpp b/src/webots/gui/WbNewVersionDialog.cpp index 84d32982185..f1c75eebdaf 100644 --- a/src/webots/gui/WbNewVersionDialog.cpp +++ b/src/webots/gui/WbNewVersionDialog.cpp @@ -132,7 +132,7 @@ WbNewVersionDialog::WbNewVersionDialog() { vBoxLayout->addWidget(telemetryBox); // main button - QPushButton *const startButton = new QPushButton(tr("Start Webots with the selected theme.")); + const QPushButton *startButton = new QPushButton(tr("Start Webots with the selected theme.")); vBoxLayout->addWidget(startButton); setLayout(vBoxLayout); diff --git a/src/webots/gui/WbWebotsUpdateDialog.cpp b/src/webots/gui/WbWebotsUpdateDialog.cpp index 2141101e277..0ad31023993 100644 --- a/src/webots/gui/WbWebotsUpdateDialog.cpp +++ b/src/webots/gui/WbWebotsUpdateDialog.cpp @@ -25,7 +25,7 @@ WbWebotsUpdateDialog::WbWebotsUpdateDialog(bool displayCheckBox, QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Check for updates")); - QDialogButtonBox *const buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this); + const QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this); connect(buttonBox, &QDialogButtonBox::accepted, this, &WbWebotsUpdateDialog::accept); mLabel = new QLabel(tr("Check for updates..."), this); diff --git a/src/webots/nodes/WbBaseNode.cpp b/src/webots/nodes/WbBaseNode.cpp index a6fe8ac7e0d..caeb12cc3ba 100644 --- a/src/webots/nodes/WbBaseNode.cpp +++ b/src/webots/nodes/WbBaseNode.cpp @@ -285,7 +285,7 @@ bool WbBaseNode::isUrdfRootLink() const { } void WbBaseNode::exportUrdfJoint(WbWriter &writer) const { - if (!parentNode() || dynamic_cast(parentNode())) + if (dynamic_cast(parentNode())) return; WbVector3 translation; @@ -293,7 +293,8 @@ void WbBaseNode::exportUrdfJoint(WbWriter &writer) const { const WbNode *const upperLinkRoot = findUrdfLinkRoot(); assert(upperLinkRoot); - if (dynamic_cast(this) && dynamic_cast(upperLinkRoot)) { + const WbPose *pose = dynamic_cast(this); + if (pose && dynamic_cast(upperLinkRoot)) { const WbPose *const upperLinkRootPose = static_cast(this); translation = upperLinkRootPose->translationFrom(upperLinkRoot); eulerRotation = urdfRotation(upperLinkRootPose->rotationMatrixFrom(upperLinkRoot)); diff --git a/src/webots/nodes/WbBasicJoint.cpp b/src/webots/nodes/WbBasicJoint.cpp index 93d914a8fcd..0a6f8400450 100644 --- a/src/webots/nodes/WbBasicJoint.cpp +++ b/src/webots/nodes/WbBasicJoint.cpp @@ -129,7 +129,7 @@ void WbBasicJoint::postFinalize() { } connect(mParameters, &WbSFNode::changed, this, &WbBasicJoint::updateParameters); - WbSolid *const s = solidEndPoint(); + const WbSolid *const s = solidEndPoint(); if (s) { connect(s, &WbSolid::positionChangedArtificially, this, &WbBasicJoint::updateEndPointPosition); updateEndPointPosition(); diff --git a/src/webots/nodes/WbCadShape.cpp b/src/webots/nodes/WbCadShape.cpp index 9a419ae83a0..16674f5442b 100644 --- a/src/webots/nodes/WbCadShape.cpp +++ b/src/webots/nodes/WbCadShape.cpp @@ -118,7 +118,7 @@ void WbCadShape::retrieveMaterials() { if (!newUrl.isEmpty()) { mObjMaterials.insert(material, newUrl); // prepare a downloader - WbDownloader *const downloader = WbDownloadManager::instance()->createDownloader(QUrl(newUrl), this); + const WbDownloader *downloader = WbDownloadManager::instance()->createDownloader(QUrl(newUrl), this); connect(downloader, &WbDownloader::complete, this, &WbCadShape::materialDownloadTracker); mMaterialDownloaders.push_back(downloader); } diff --git a/src/webots/nodes/WbHinge2Joint.cpp b/src/webots/nodes/WbHinge2Joint.cpp index 7bf402a1ba8..3e7d674727d 100644 --- a/src/webots/nodes/WbHinge2Joint.cpp +++ b/src/webots/nodes/WbHinge2Joint.cpp @@ -582,7 +582,7 @@ void WbHinge2Joint::addDevice2(int index) { WbBaseNode *decendant = dynamic_cast(mDevice2->item(index)); r->descendantNodeInserted(decendant); } - WbBrake *const brake = dynamic_cast(mDevice2->item(index)); + const WbBrake *brake = dynamic_cast(mDevice2->item(index)); if (brake) connect(brake, &WbBrake::brakingChanged, this, &WbHinge2Joint::updateSpringAndDampingConstants, Qt::UniqueConnection); } diff --git a/src/webots/nodes/WbJoint.cpp b/src/webots/nodes/WbJoint.cpp index cb14980d813..39d355a50aa 100644 --- a/src/webots/nodes/WbJoint.cpp +++ b/src/webots/nodes/WbJoint.cpp @@ -152,7 +152,7 @@ void WbJoint::addDevice(int index) { WbBaseNode *decendant = dynamic_cast(mDevice->item(index)); r->descendantNodeInserted(decendant); } - WbBrake *const b = dynamic_cast(mDevice->item(index)); + const WbBrake *b = dynamic_cast(mDevice->item(index)); if (b) connect(b, &WbBrake::brakingChanged, this, &WbJoint::updateSpringAndDampingConstants, Qt::UniqueConnection); } diff --git a/src/webots/nodes/WbLed.cpp b/src/webots/nodes/WbLed.cpp index e7ef797f9fe..e2ac96a9ea1 100644 --- a/src/webots/nodes/WbLed.cpp +++ b/src/webots/nodes/WbLed.cpp @@ -107,7 +107,7 @@ void WbLed::findMaterialsAndLights(const WbGroup *group) { WbBaseNode *const n = group->child(i); // cppcheck-suppress constVariablePointer WbLight *lightChild = dynamic_cast(n); - WbGroup *const groupChild = dynamic_cast(n); + const WbGroup *groupChild = dynamic_cast(n); if (n->nodeType() == WB_NODE_SHAPE) { const WbAppearance *appearance = dynamic_cast(n)->appearance(); @@ -120,7 +120,7 @@ void WbLed::findMaterialsAndLights(const WbGroup *group) { connect(appearance, &WbAppearance::fieldChanged, this, &WbLed::updateIfNeeded, Qt::UniqueConnection); connect(appearance->parentNode(), &WbShape::fieldChanged, this, &WbLed::updateIfNeeded, Qt::UniqueConnection); } else { - WbPbrAppearance *const pbrAppearance = dynamic_cast(n)->pbrAppearance(); + const WbPbrAppearance *pbrAppearance = dynamic_cast(n)->pbrAppearance(); if (pbrAppearance) { mPbrAppearances.append(pbrAppearance); diff --git a/src/webots/nodes/WbPose.cpp b/src/webots/nodes/WbPose.cpp index 6fbd3fab1d7..6b1151854a5 100644 --- a/src/webots/nodes/WbPose.cpp +++ b/src/webots/nodes/WbPose.cpp @@ -60,7 +60,8 @@ void WbPose::reset(const QString &id) { WbGroup::reset(id); // note: for solids, the set of these parameters has to occur only if mJointParents.size() == 0 and it is handled in // WbSolid::reset, otherwise it breaks the reset of hinge based joints - if (nodeType() != WB_NODE_TRACK_WHEEL && !dynamic_cast(this)) { + const WbSolid *solid = dynamic_cast(this); + if (nodeType() != WB_NODE_TRACK_WHEEL && !solid) { setTranslation(mSavedTranslations[id]); setRotation(mSavedRotations[id]); } diff --git a/src/webots/nodes/WbRobot.cpp b/src/webots/nodes/WbRobot.cpp index 202416ceb36..f04bd4537f1 100644 --- a/src/webots/nodes/WbRobot.cpp +++ b/src/webots/nodes/WbRobot.cpp @@ -270,7 +270,8 @@ void WbRobot::addDevices(WbNode *node) { if (!node) return; - if (node != this && dynamic_cast(node)) + const WbRobot *robotNode = dynamic_cast(node); + if (node != this && robrobotNodeot) return; // do not recurse through child robots, their devices are hidden WbGroup *group = dynamic_cast(node); @@ -286,7 +287,7 @@ void WbRobot::addDevices(WbNode *node) { if (renderingDevice) { connect(renderingDevice, &WbBaseNode::isBeingDestroyed, this, &WbRobot::removeRenderingDevice, Qt::UniqueConnection); mRenderingDevices.append(renderingDevice); - WbAbstractCamera *const camera = dynamic_cast(renderingDevice); + const WbAbstractCamera *camera = dynamic_cast(renderingDevice); if (camera) { connect(camera, &WbAbstractCamera::enabled, this, &WbRobot::updateActiveCameras, Qt::UniqueConnection); if (camera->isEnabled()) diff --git a/src/webots/nodes/WbSolid.cpp b/src/webots/nodes/WbSolid.cpp index 5efa6637e03..c41315900ae 100644 --- a/src/webots/nodes/WbSolid.cpp +++ b/src/webots/nodes/WbSolid.cpp @@ -1575,7 +1575,7 @@ void WbSolid::updateChildren() { mPropellerChildren.clear(); collectSolidChildren(this, true, mSolidChildren, mJointChildren, mPropellerChildren); - foreach (WbSolid *const solid, mSolidChildren) { + foreach (const WbSolid *const solid, mSolidChildren) { connect(solid, &WbSolid::destroyed, this, &WbSolid::updateChildren, Qt::UniqueConnection); connect(solid, &WbSolid::destroyed, this, &WbSolid::refreshPhysicsRepresentation, Qt::UniqueConnection); connect(solid, &WbSolid::physicsPropertiesChanged, this, &WbSolid::refreshPhysicsRepresentation, Qt::UniqueConnection); diff --git a/src/webots/nodes/WbTrack.cpp b/src/webots/nodes/WbTrack.cpp index c4fed8595dd..87fc7f1e838 100644 --- a/src/webots/nodes/WbTrack.cpp +++ b/src/webots/nodes/WbTrack.cpp @@ -132,7 +132,7 @@ void WbTrack::postFinalize() { connect(mDeviceField, &WbMFNode::itemInserted, this, &WbTrack::addDevice); if (childCount() > 0) { - WbGroup *const group = dynamic_cast(child(0)); + const WbGroup *group = dynamic_cast(child(0)); if (group) connect(group, &WbGroup::childrenChanged, this, &WbTrack::updateChildren); if (mShape) @@ -235,7 +235,7 @@ bool WbTrack::findAndConnectAnimatedGeometries(bool connectSignals, QList(node); + const WbShape *s = dynamic_cast(node); if (s) { if (connectSignals) { // material automatically updated @@ -259,7 +259,7 @@ bool WbTrack::findAndConnectAnimatedGeometries(bool connectSignals, QListchildCount(); ++j) geometryNodes.append(g->child(j)); - WbPose *const t = dynamic_cast(g); + const WbPose *t = dynamic_cast(g); if (t) { t->enablePoseChangedSignal(); connect(t, &WbPose::poseChanged, this, &WbTrack::updateAnimatedGeometries, Qt::UniqueConnection); @@ -951,7 +951,7 @@ void WbTrack::exportNodeSubNodes(WbWriter &writer) const { // write animated geometries if (!writer.isW3d() && !writer.isUrdf() && !isEmpty) writer << "\n"; - isEmpty |= mAnimatedObjectList.isEmpty(); + isEmpty ||= mAnimatedObjectList.isEmpty(); exportAnimatedGeometriesMesh(writer); diff --git a/src/webots/nodes/utils/WbNodeOperations.cpp b/src/webots/nodes/utils/WbNodeOperations.cpp index 7e81a488ae0..91107ec55e7 100644 --- a/src/webots/nodes/utils/WbNodeOperations.cpp +++ b/src/webots/nodes/utils/WbNodeOperations.cpp @@ -309,8 +309,7 @@ bool WbNodeOperations::deleteNode(WbNode *node, bool fromSupervisor) { setFromSupervisor(fromSupervisor); - if (dynamic_cast(node)) - WbWorld::instance()->awake(); + WbWorld::instance()->awake(); const bool dictionaryNeedsUpdate = WbVrmlNodeUtilities::hasAreferredDefNodeDescendant(node); WbField *parentField = node->parentField(); diff --git a/src/webots/nodes/utils/WbNodeUtilities.cpp b/src/webots/nodes/utils/WbNodeUtilities.cpp index bc92a156b77..b66eafb651d 100644 --- a/src/webots/nodes/utils/WbNodeUtilities.cpp +++ b/src/webots/nodes/utils/WbNodeUtilities.cpp @@ -1226,7 +1226,8 @@ dBodyID WbNodeUtilities::findBodyMerger(const WbNode *node) { const WbSolid *s = dynamic_cast(n); if (s && s->bodyMerger()) return s->bodyMerger(); - if (dynamic_cast(n)) + const WbBasicJoint *joint = dynamic_cast(n); + if (joint) break; n = n->parentNode(); } @@ -1726,8 +1727,10 @@ bool WbNodeUtilities::hasASolidDescendant(const WbNode *node) { // cppcheck-suppress knownConditionTrueFalse if (slot) { WbNode *endPoint = slot->endPoint(); - if (endPoint) - return dynamic_cast(endPoint) || hasASolidDescendant(endPoint); + if (endPoint) { + const WbSolid *solid = dynamic_cast(endPoint); + return solid || hasASolidDescendant(endPoint); + } return false; } diff --git a/src/webots/scene_tree/WbSceneTreeModel.cpp b/src/webots/scene_tree/WbSceneTreeModel.cpp index a4559f2a333..5ab3c66f1b3 100644 --- a/src/webots/scene_tree/WbSceneTreeModel.cpp +++ b/src/webots/scene_tree/WbSceneTreeModel.cpp @@ -304,7 +304,7 @@ bool WbSceneTreeModel::insertRows(int row, int count, const QModelIndex &parent) const WbSFNode *const sfnode = dynamic_cast(parentItem->field()->value()); if (sfnode) { - WbNode *const node = sfnode->value(); + const WbNode *node = sfnode->value(); if (node) { if (!node->isUseNode()) { const int n = node->numFields(); diff --git a/src/webots/vrml/WbNode.cpp b/src/webots/vrml/WbNode.cpp index 4dcdb81a370..a0ad4322a49 100644 --- a/src/webots/vrml/WbNode.cpp +++ b/src/webots/vrml/WbNode.cpp @@ -208,7 +208,7 @@ WbNode::WbNode(const WbNode &other) : // copy fields foreach (const WbField *f, other.fields()) { - WbField *const copy = new WbField(*f, this); + const WbField *copy = new WbField(*f, this); mFields.append(copy); connect(copy, &WbField::valueChanged, this, &WbNode::notifyFieldChanged); } @@ -216,7 +216,7 @@ WbNode::WbNode(const WbNode &other) : // copy parameters if (other.mProto) { foreach (const WbField *parameter, other.parameters()) { - WbField *const copy = new WbField(*parameter, this); + const WbField *copy = new WbField(*parameter, this); mParameters.append(copy); connect(copy, &WbField::valueChanged, this, &WbNode::notifyParameterChanged); } From ec5aeddb6f2be3f7d6591ededb68729118a0c0a0 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 15:15:46 +0100 Subject: [PATCH 14/19] Fix --- src/webots/nodes/WbTrack.cpp | 2 +- src/webots/user_commands/WbActionManager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webots/nodes/WbTrack.cpp b/src/webots/nodes/WbTrack.cpp index 87fc7f1e838..544e287bbe4 100644 --- a/src/webots/nodes/WbTrack.cpp +++ b/src/webots/nodes/WbTrack.cpp @@ -951,7 +951,7 @@ void WbTrack::exportNodeSubNodes(WbWriter &writer) const { // write animated geometries if (!writer.isW3d() && !writer.isUrdf() && !isEmpty) writer << "\n"; - isEmpty ||= mAnimatedObjectList.isEmpty(); + isEmpty |= mAnimatedObjectList.isEmpty(); exportAnimatedGeometriesMesh(writer); diff --git a/src/webots/user_commands/WbActionManager.cpp b/src/webots/user_commands/WbActionManager.cpp index 91e7c85e568..bc98b6f2822 100644 --- a/src/webots/user_commands/WbActionManager.cpp +++ b/src/webots/user_commands/WbActionManager.cpp @@ -1134,7 +1134,7 @@ void WbActionManager::populateActions() { } void WbActionManager::connectActions() { - WbSimulationState *const state = WbSimulationState::instance(); + const WbSimulationState *state = WbSimulationState::instance(); connect(state, &WbSimulationState::enabledChanged, this, &WbActionManager::updateEnabled); } From b3a07306e5b440cf9800bd8124bf1ef83bd6e024 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 15:48:53 +0100 Subject: [PATCH 15/19] Fix --- .../libraries/qt_utils/motion_editor/AddStateDialog.cpp | 2 +- .../libraries/qt_utils/motion_editor/PoseEditor.cpp | 2 +- src/webots/control/WbControlledWorld.cpp | 4 ++-- src/webots/engine/WbSimulationWorld.cpp | 4 ++-- src/webots/gui/WbView3D.cpp | 2 +- src/webots/nodes/WbRobot.cpp | 6 +++--- src/webots/nodes/WbSolid.cpp | 2 +- src/webots/nodes/WbTrack.cpp | 2 +- src/webots/nodes/utils/WbNodeOperations.cpp | 4 +++- src/webots/scene_tree/WbSceneTree.cpp | 2 +- src/webots/scene_tree/WbSceneTreeModel.cpp | 2 +- 11 files changed, 17 insertions(+), 15 deletions(-) diff --git a/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp b/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp index 1aa4a83e0ce..2f016e2e7d0 100644 --- a/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp +++ b/resources/projects/libraries/qt_utils/motion_editor/AddStateDialog.cpp @@ -32,7 +32,7 @@ AddStateDialog::AddStateDialog(Motion *motion, QWidget *parent) : QDialog(parent populateListWidget(); QWidget *buttonsWidget = new QWidget(this); - const QPushButton *const cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); + const QPushButton *cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); QPushButton *okButton = new QPushButton(tr("Ok"), buttonsWidget); QHBoxLayout *hBoxLayout = new QHBoxLayout(buttonsWidget); hBoxLayout->addStretch(); diff --git a/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp b/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp index 98215c0de9b..cfcc3eef9df 100644 --- a/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp +++ b/resources/projects/libraries/qt_utils/motion_editor/PoseEditor.cpp @@ -36,7 +36,7 @@ PoseEditor::PoseEditor(Pose *pose, Pose *previousPose, Pose *nextPose, bool fixe formLayout->addRow(tr("&Milliseconds:"), mMilliSecondsSpinBox); QWidget *buttonsWidget = new QWidget(this); - const QPushButton *const cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); + const QPushButton *cancelButton = new QPushButton(tr("Cancel"), buttonsWidget); QPushButton *okButton = new QPushButton(tr("Ok"), buttonsWidget); QHBoxLayout *hBoxLayout = new QHBoxLayout(buttonsWidget); hBoxLayout->addStretch(); diff --git a/src/webots/control/WbControlledWorld.cpp b/src/webots/control/WbControlledWorld.cpp index 58b9a0eb368..1ba705ba44b 100644 --- a/src/webots/control/WbControlledWorld.cpp +++ b/src/webots/control/WbControlledWorld.cpp @@ -46,7 +46,7 @@ WbControlledWorld::WbControlledWorld(WbTokenizer *tokenizer) : return; mNeedToYield = false; - foreach (const WbRobot *robot, robots()) + foreach (const WbRobot *const robot, robots()) connect(robot, &WbRobot::startControllerRequest, this, &WbControlledWorld::startController); } @@ -195,7 +195,7 @@ void WbControlledWorld::checkIfReadRequestCompleted() { void WbControlledWorld::step() { if (mFirstStep && !mRetryEnabled) { - foreach (const WbRobot *robot, robots()) { + foreach (const WbRobot *const robot, robots()) { if (!robot->isControllerStarted()) startController(robot); } diff --git a/src/webots/engine/WbSimulationWorld.cpp b/src/webots/engine/WbSimulationWorld.cpp index 8e50d10819b..57540dd3933 100644 --- a/src/webots/engine/WbSimulationWorld.cpp +++ b/src/webots/engine/WbSimulationWorld.cpp @@ -226,7 +226,7 @@ void WbSimulationWorld::step() { dImmersionOutlineDestroy(mImmersionGeoms.at(i).outline); mImmersionGeoms.clear(); - foreach (const WbRobot *robot, robots()) { + foreach (const WbRobot *const robot, robots()) { if (robots().contains(robot)) // the 'processImmediateMessages' of another robot may have removed/regenerated this robot robot->processImmediateMessages(); } @@ -400,7 +400,7 @@ void WbSimulationWorld::reset(bool restartControllers) { dImmersionLinkGroupEmpty(mCluster->immersionLinkGroup()); WbSoundEngine::stopAllSources(); if (restartControllers) { - foreach (const WbRobot *robot, robots()) { + foreach (const WbRobot *const robot, robots()) { if (robot->isControllerStarted()) robot->restartController(); } diff --git a/src/webots/gui/WbView3D.cpp b/src/webots/gui/WbView3D.cpp index fa1d17b609d..6ac20c3985c 100644 --- a/src/webots/gui/WbView3D.cpp +++ b/src/webots/gui/WbView3D.cpp @@ -1813,7 +1813,7 @@ void WbView3D::mouseMoveEvent(QMouseEvent *event) { // Drag overlay even if modifier keys are pressed WbRenderingDevice *const renderingDevice = WbRenderingDevice::fromMousePosition(position.x(), position.y()); if (renderingDevice) { - const WbWrenTextureOverlay *overlay = renderingDevice->overlay(); + const WbWrenTextureOverlay *const overlay = renderingDevice->overlay(); if (overlay) { overlay->putOnTop(); if (overlay->isInsideResizeArea(position.x(), position.y())) diff --git a/src/webots/nodes/WbRobot.cpp b/src/webots/nodes/WbRobot.cpp index f04bd4537f1..68c51162d55 100644 --- a/src/webots/nodes/WbRobot.cpp +++ b/src/webots/nodes/WbRobot.cpp @@ -331,7 +331,7 @@ void WbRobot::addDevices(WbNode *node) { const WbJoint *const joint = dynamic_cast(basicJoint); if (joint) { const QVector &jointDevices = joint->devices(); - foreach (const WbLogicalDevice *jointDevice, jointDevices) { + foreach (const WbLogicalDevice *const jointDevice, jointDevices) { if (jointDevice == NULL) continue; mDevices.append(jointDevice); @@ -344,9 +344,9 @@ void WbRobot::addDevices(WbNode *node) { return; } - const WbPropeller *propeller = dynamic_cast(node); + const WbPropeller *const propeller = dynamic_cast(node); if (propeller) { - const WbLogicalDevice *propellerDevice = propeller->device(); + const WbLogicalDevice *const propellerDevice = propeller->device(); if (propellerDevice) { mDevices.append(propellerDevice); connect(static_cast(propellerDevice), &WbBaseNode::destroyed, this, &WbRobot::updateDevicesAfterDestruction, diff --git a/src/webots/nodes/WbSolid.cpp b/src/webots/nodes/WbSolid.cpp index c41315900ae..4c89da92050 100644 --- a/src/webots/nodes/WbSolid.cpp +++ b/src/webots/nodes/WbSolid.cpp @@ -1580,7 +1580,7 @@ void WbSolid::updateChildren() { connect(solid, &WbSolid::destroyed, this, &WbSolid::refreshPhysicsRepresentation, Qt::UniqueConnection); connect(solid, &WbSolid::physicsPropertiesChanged, this, &WbSolid::refreshPhysicsRepresentation, Qt::UniqueConnection); } - foreach (const WbBasicJoint *jointChild, mJointChildren) + foreach (const WbBasicJoint *const jointChild, mJointChildren) connect(jointChild, &WbBasicJoint::endPointChanged, this, &WbSolid::updateChildrenAfterJointEndPointChange, Qt::UniqueConnection); } diff --git a/src/webots/nodes/WbTrack.cpp b/src/webots/nodes/WbTrack.cpp index 544e287bbe4..326d709d5a1 100644 --- a/src/webots/nodes/WbTrack.cpp +++ b/src/webots/nodes/WbTrack.cpp @@ -951,7 +951,7 @@ void WbTrack::exportNodeSubNodes(WbWriter &writer) const { // write animated geometries if (!writer.isW3d() && !writer.isUrdf() && !isEmpty) writer << "\n"; - isEmpty |= mAnimatedObjectList.isEmpty(); + isEmpty = isEmpty || mAnimatedObjectList.isEmpty(); exportAnimatedGeometriesMesh(writer); diff --git a/src/webots/nodes/utils/WbNodeOperations.cpp b/src/webots/nodes/utils/WbNodeOperations.cpp index 91107ec55e7..25150ecfaf3 100644 --- a/src/webots/nodes/utils/WbNodeOperations.cpp +++ b/src/webots/nodes/utils/WbNodeOperations.cpp @@ -309,7 +309,9 @@ bool WbNodeOperations::deleteNode(WbNode *node, bool fromSupervisor) { setFromSupervisor(fromSupervisor); - WbWorld::instance()->awake(); + const WbSolid *solidNode = dynamic_cast(node); + if (solidNode) + WbWorld::instance()->awake(); const bool dictionaryNeedsUpdate = WbVrmlNodeUtilities::hasAreferredDefNodeDescendant(node); WbField *parentField = node->parentField(); diff --git a/src/webots/scene_tree/WbSceneTree.cpp b/src/webots/scene_tree/WbSceneTree.cpp index b7a1c0e5c8c..670635b3e5e 100644 --- a/src/webots/scene_tree/WbSceneTree.cpp +++ b/src/webots/scene_tree/WbSceneTree.cpp @@ -1125,7 +1125,7 @@ void WbSceneTree::updateSelection() { // quitting Webots return; - WbNodeOperations *const nodeOperations = WbNodeOperations::instance(); + const WbNodeOperations *nodeOperations = WbNodeOperations::instance(); if (nodeOperations->isFromSupervisor()) // do not update selection if change come from supervisor return; diff --git a/src/webots/scene_tree/WbSceneTreeModel.cpp b/src/webots/scene_tree/WbSceneTreeModel.cpp index 5ab3c66f1b3..5e0754188bb 100644 --- a/src/webots/scene_tree/WbSceneTreeModel.cpp +++ b/src/webots/scene_tree/WbSceneTreeModel.cpp @@ -304,7 +304,7 @@ bool WbSceneTreeModel::insertRows(int row, int count, const QModelIndex &parent) const WbSFNode *const sfnode = dynamic_cast(parentItem->field()->value()); if (sfnode) { - const WbNode *node = sfnode->value(); + const WbNode *const node = sfnode->value(); if (node) { if (!node->isUseNode()) { const int n = node->numFields(); From 2e8a1137c9944bb84d81a3ea22fcbb139eb4cd51 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Tue, 10 Dec 2024 16:14:50 +0100 Subject: [PATCH 16/19] Revert test_sources_with_latest_cppcheck.yml --- .github/workflows/tests_sources_with_latest_cppcheck.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/tests_sources_with_latest_cppcheck.yml b/.github/workflows/tests_sources_with_latest_cppcheck.yml index 3f2365acc13..fbef60e4d70 100644 --- a/.github/workflows/tests_sources_with_latest_cppcheck.yml +++ b/.github/workflows/tests_sources_with_latest_cppcheck.yml @@ -1,10 +1,6 @@ name: Test Sources with Latest Cppcheck on: - pull_request: - types: [opened, synchronize, reopened, labeled, unlabeled] - branches-ignore: - - 'released' schedule: - cron: '0 22 * * *' From c3555eb137055d06b5d1085d7b9d5c34f0428c21 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Wed, 11 Dec 2024 13:15:28 +0100 Subject: [PATCH 17/19] Fix --- .github/workflows/tests_sources_with_latest_cppcheck.yml | 4 ++++ src/webots/nodes/WbRobot.cpp | 2 +- src/wren/Node.hpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_sources_with_latest_cppcheck.yml b/.github/workflows/tests_sources_with_latest_cppcheck.yml index fbef60e4d70..3f2365acc13 100644 --- a/.github/workflows/tests_sources_with_latest_cppcheck.yml +++ b/.github/workflows/tests_sources_with_latest_cppcheck.yml @@ -1,6 +1,10 @@ name: Test Sources with Latest Cppcheck on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + branches-ignore: + - 'released' schedule: - cron: '0 22 * * *' diff --git a/src/webots/nodes/WbRobot.cpp b/src/webots/nodes/WbRobot.cpp index 68c51162d55..4bf24b65483 100644 --- a/src/webots/nodes/WbRobot.cpp +++ b/src/webots/nodes/WbRobot.cpp @@ -271,7 +271,7 @@ void WbRobot::addDevices(WbNode *node) { return; const WbRobot *robotNode = dynamic_cast(node); - if (node != this && robrobotNodeot) + if (node != this && robotNode) return; // do not recurse through child robots, their devices are hidden WbGroup *group = dynamic_cast(node); diff --git a/src/wren/Node.hpp b/src/wren/Node.hpp index 810bab04678..63779814fda 100644 --- a/src/wren/Node.hpp +++ b/src/wren/Node.hpp @@ -55,7 +55,7 @@ namespace wren { protected: Node(); - explicit Node(Node *source); + explicit Node(const Node *source); virtual ~Node() {} virtual void recomputeAabb() const; From 49b1db91ba2ea0ed83d3a7e706f6023ebf9bf550 Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Wed, 11 Dec 2024 14:09:22 +0100 Subject: [PATCH 18/19] Fix --- src/wren/DirectionalLight.hpp | 2 +- src/wren/LightNode.hpp | 2 +- src/wren/PointLight.hpp | 2 +- src/wren/Scene.cpp | 2 +- src/wren/SpotLight.hpp | 2 +- src/wren/Transform.hpp | 4 ++-- src/wren/TransformNode.cpp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wren/DirectionalLight.hpp b/src/wren/DirectionalLight.hpp index 0b4c5748809..e19e19adce3 100644 --- a/src/wren/DirectionalLight.hpp +++ b/src/wren/DirectionalLight.hpp @@ -31,7 +31,7 @@ namespace wren { void setDirection(const glm::vec3 &direction); - LightNode::Type type() override { return TYPE_DIRECTIONAL; } + LightNode::Type type() const override { return TYPE_DIRECTIONAL; } private: DirectionalLight(); diff --git a/src/wren/LightNode.hpp b/src/wren/LightNode.hpp index b2afc36106e..d2f2603c09e 100644 --- a/src/wren/LightNode.hpp +++ b/src/wren/LightNode.hpp @@ -65,7 +65,7 @@ namespace wren { bool on() const { return mOn; } bool castShadows() const { return mCastShadows; } - virtual LightNode::Type type() = 0; + virtual LightNode::Type type() const = 0; protected: LightNode(); diff --git a/src/wren/PointLight.hpp b/src/wren/PointLight.hpp index 8386cdc301d..b338a811031 100644 --- a/src/wren/PointLight.hpp +++ b/src/wren/PointLight.hpp @@ -26,7 +26,7 @@ namespace wren { // Encapsulate memory management static PointLight *createPointLight() { return new PointLight(); } - LightNode::Type type() override { return TYPE_POINT; } + LightNode::Type type() const override { return TYPE_POINT; } private: PointLight(); diff --git a/src/wren/Scene.cpp b/src/wren/Scene.cpp index 38f94a336b8..be7689a9487 100644 --- a/src/wren/Scene.cpp +++ b/src/wren/Scene.cpp @@ -630,7 +630,7 @@ namespace wren { bool visible = true; // Light culling if (light->type() != LightNode::TYPE_DIRECTIONAL) { - const PositionalLight *positionalLight = static_cast(light); + const PositionalLight *positionalLight = static_cast(light); const primitive::Sphere &boundingSphere = renderable->boundingSphere(); const float distance = glm::distance(boundingSphere.mCenter, positionalLight->position()); const float radius = positionalLight->radius() + boundingSphere.mRadius; diff --git a/src/wren/SpotLight.hpp b/src/wren/SpotLight.hpp index 67eb39da84e..32d1849e851 100644 --- a/src/wren/SpotLight.hpp +++ b/src/wren/SpotLight.hpp @@ -49,7 +49,7 @@ namespace wren { mIsDirectionDirty = true; } - LightNode::Type type() override { return TYPE_SPOT; } + LightNode::Type type() const override { return TYPE_SPOT; } void update() const override { PositionalLight::update(); diff --git a/src/wren/Transform.hpp b/src/wren/Transform.hpp index 1337e092eb2..82d20d4b12f 100644 --- a/src/wren/Transform.hpp +++ b/src/wren/Transform.hpp @@ -27,7 +27,7 @@ namespace wren { public: // Encapsulate memory management static Transform *createTransform() { return new Transform(); } - static Transform *copyTransform(Transform *source) { return new Transform(source); } + static Transform *copyTransform(const Transform *source) { return new Transform(source); } void attachChild(Node *child); void detachChild(Node *child); @@ -51,7 +51,7 @@ namespace wren { protected: Transform(); - explicit Transform(Transform *source); + explicit Transform(const Transform *source); virtual ~Transform() override; private: diff --git a/src/wren/TransformNode.cpp b/src/wren/TransformNode.cpp index 36e556c0602..02a015e1a3b 100644 --- a/src/wren/TransformNode.cpp +++ b/src/wren/TransformNode.cpp @@ -105,7 +105,7 @@ namespace wren { mScaleRelative(glm::vec3(1.0)) { } - TransformNode::TransformNode(TransformNode *source) : + TransformNode::TransformNode(const TransformNode *source) : Node(source), mIsMatrixDirty(source->mIsMatrixDirty), mPositionRelative(source->mPositionRelative), From b5ee1343e91d4fe040100149330b791adab218ef Mon Sep 17 00:00:00 2001 From: MNikoliCC Date: Thu, 12 Dec 2024 10:09:28 +0100 Subject: [PATCH 19/19] Fix --- src/webots/control/WbControlledWorld.cpp | 2 +- src/webots/control/WbControlledWorld.hpp | 2 +- src/webots/control/WbController.hpp | 2 +- src/webots/nodes/WbCadShape.cpp | 4 ++-- src/webots/nodes/WbCadShape.hpp | 2 +- src/wren/Transform.cpp | 2 +- src/wren/TransformNode.hpp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/webots/control/WbControlledWorld.cpp b/src/webots/control/WbControlledWorld.cpp index 1ba705ba44b..c9ecc6f418f 100644 --- a/src/webots/control/WbControlledWorld.cpp +++ b/src/webots/control/WbControlledWorld.cpp @@ -76,7 +76,7 @@ void WbControlledWorld::setUpControllerForNewRobot(WbRobot *robot) { connect(robot, &WbRobot::controllerChanged, this, &WbControlledWorld::updateCurrentRobotController, Qt::UniqueConnection); } -void WbControlledWorld::startController(WbRobot *robot) { +void WbControlledWorld::startController(const WbRobot *robot) { if (robot->controllerName() == "") { connect(robot, &WbRobot::controllerChanged, this, &WbControlledWorld::updateCurrentRobotController, Qt::UniqueConnection); return; diff --git a/src/webots/control/WbControlledWorld.hpp b/src/webots/control/WbControlledWorld.hpp index 010461a747c..429105e1794 100644 --- a/src/webots/control/WbControlledWorld.hpp +++ b/src/webots/control/WbControlledWorld.hpp @@ -31,7 +31,7 @@ class WbControlledWorld : public WbSimulationWorld { explicit WbControlledWorld(WbTokenizer *tokenizer = NULL); virtual ~WbControlledWorld() override; - void startController(WbRobot *robot); + void startController(const WbRobot *robot); void externConnection(WbController *controller, bool connect); QStringList activeControllersNames() const; bool needToWait(bool *waitForExternControllerStart = NULL); diff --git a/src/webots/control/WbController.hpp b/src/webots/control/WbController.hpp index f6a132889ff..e484af3c26c 100644 --- a/src/webots/control/WbController.hpp +++ b/src/webots/control/WbController.hpp @@ -32,7 +32,7 @@ class WbController : public QObject { // constructor & destructor // name: controller name as in Robot.controller, e.g. "" // arguments: controller arguments as in Robot.controllerArgs - explicit WbController(WbRobot *robot); + explicit WbController(const WbRobot *robot); virtual ~WbController(); // start the controller diff --git a/src/webots/nodes/WbCadShape.cpp b/src/webots/nodes/WbCadShape.cpp index 16674f5442b..6b6a9f05b55 100644 --- a/src/webots/nodes/WbCadShape.cpp +++ b/src/webots/nodes/WbCadShape.cpp @@ -126,8 +126,8 @@ void WbCadShape::retrieveMaterials() { // start all downloads only when the vector is entirely populated (to avoid racing conditions) assert(mMaterialDownloaders.size() == mObjMaterials.size()); - foreach (WbDownloader *downloader, mMaterialDownloaders) - downloader->download(); + foreach (const WbDownloader *downloader, mMaterialDownloaders) + const_cast(downloader)->download(); } void WbCadShape::materialDownloadTracker() { diff --git a/src/webots/nodes/WbCadShape.hpp b/src/webots/nodes/WbCadShape.hpp index 98bc5a13abe..d43349fcc89 100644 --- a/src/webots/nodes/WbCadShape.hpp +++ b/src/webots/nodes/WbCadShape.hpp @@ -96,7 +96,7 @@ private slots: // methods and variables to handle obj materials QMap mObjMaterials; // maps materials as referenced in the obj to their remote counterpart - QVector mMaterialDownloaders; + QVector mMaterialDownloaders; QStringList objMaterialList(const QString &url) const; bool areMaterialAssetsAvailable(const QString &url); void retrieveMaterials(); diff --git a/src/wren/Transform.cpp b/src/wren/Transform.cpp index d572e089af8..a7685044d98 100644 --- a/src/wren/Transform.cpp +++ b/src/wren/Transform.cpp @@ -58,7 +58,7 @@ namespace wren { Transform::Transform() { } - Transform::Transform(Transform *source) : TransformNode(source) { + Transform::Transform(const Transform *source) : TransformNode(source) { } Transform::~Transform() { diff --git a/src/wren/TransformNode.hpp b/src/wren/TransformNode.hpp index 7810898c8fc..24e66d9a90b 100644 --- a/src/wren/TransformNode.hpp +++ b/src/wren/TransformNode.hpp @@ -120,7 +120,7 @@ namespace wren { protected: TransformNode(); - explicit TransformNode(TransformNode *source); + explicit TransformNode(const TransformNode *source); virtual ~TransformNode() override {} private: