Skip to content

Commit 3c4a3c0

Browse files
authored
Fix crash when using muscles and animatedGeometry in sequential worlds. (#6661)
* Fix crash when using muscles and animatedGeometry in sequential worlds. The issue was that WbWrenVertexArrayFrameListener thought that the frame had already been handled because it had been handled in the previous world. * Add test case.
1 parent 34dfe53 commit 3c4a3c0

File tree

7 files changed

+82
-1
lines changed

7 files changed

+82
-1
lines changed

src/webots/nodes/utils/WbWorld.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "WbWorldInfo.hpp"
5858
#include "WbWrenOpenGlContext.hpp"
5959
#include "WbWrenRenderingContext.hpp"
60+
#include "WbWrenVertexArrayFrameListener.hpp"
6061
#include "WbWriter.hpp"
6162

6263
#include <wren/scene.h>
@@ -92,6 +93,7 @@ WbWorld::WbWorld(WbTokenizer *tokenizer) :
9293
mIsLoading(true),
9394
mIsCleaning(false),
9495
mIsVideoRecording(false) {
96+
WbWrenVertexArrayFrameListener::resetLastUpdateTime();
9597
gInstance = this;
9698
WbNode::setInstantiateMode(true);
9799
WbNode::setGlobalParentNode(NULL);

src/webots/nodes/utils/WbWrenVertexArrayFrameListener.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@
2121
#include <wren/scene.h>
2222

2323
WbWrenVertexArrayFrameListener *WbWrenVertexArrayFrameListener::cInstance = NULL;
24+
static double lastUpdateTime = -1.0;
25+
26+
void WbWrenVertexArrayFrameListener::resetLastUpdateTime() {
27+
lastUpdateTime = -1.0;
28+
}
2429

2530
static void processEvent() {
26-
static double lastUpdateTime = -1.0;
2731
const double currentTime = WbSimulationState::instance()->time();
2832
if (currentTime == lastUpdateTime)
2933
return;

src/webots/nodes/utils/WbWrenVertexArrayFrameListener.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class WbWrenVertexArrayFrameListener {
2424
public:
2525
static WbWrenVertexArrayFrameListener *instance();
2626
static void clear();
27+
static void resetLastUpdateTime();
2728

2829
void subscribeTrack(WbTrack *track);
2930
void unsubscribeTrack(WbTrack *track);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/track_animated_geometry_muscles
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 1996-2023 Cyberbotics Ltd.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Webots Makefile system
16+
#
17+
# You may add some variable definitions hereafter to customize the build process
18+
# See documentation in $(WEBOTS_HOME_PATH)/resources/Makefile.include
19+
20+
21+
# Do not modify the following: this includes Webots global Makefile.include
22+
null :=
23+
space := $(null) $(null)
24+
WEBOTS_HOME_PATH?=$(subst $(space),\ ,$(strip $(subst \,/,$(WEBOTS_HOME))))
25+
include $(WEBOTS_HOME_PATH)/resources/Makefile.include
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <stdio.h>
2+
#include <webots/brake.h>
3+
#include <webots/motor.h>
4+
#include <webots/position_sensor.h>
5+
#include <webots/robot.h>
6+
#include <webots/supervisor.h>
7+
8+
#include "../../../lib/ts_assertion.h"
9+
#include "../../../lib/ts_utils.h"
10+
11+
#define TIME_STEP 32
12+
13+
int main(int argc, char **argv) {
14+
ts_setup(argv[0]);
15+
wb_robot_step(TIME_STEP);
16+
// Test that a world with a Muscle node will load. See issue #6659.
17+
wb_supervisor_world_load("../../worlds/supervisor_set_hinge_position_dynamic.wbt");
18+
19+
ts_send_success();
20+
return EXIT_SUCCESS;
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#VRML_SIM R2024a utf8
2+
3+
EXTERNPROTO "webots://tests/default/protos/TestSuiteEmitter.proto"
4+
EXTERNPROTO "webots://tests/default/protos/TestSuiteSupervisor.proto"
5+
6+
WorldInfo {
7+
}
8+
Viewpoint {
9+
}
10+
Background {
11+
}
12+
Robot {
13+
children [
14+
Track {
15+
children [
16+
TrackWheel {
17+
}
18+
]
19+
animatedGeometry Shape {
20+
}
21+
}
22+
]
23+
controller "track_animated_geometry_muscles"
24+
supervisor TRUE
25+
}
26+
TestSuiteSupervisor {
27+
}

0 commit comments

Comments
 (0)