webots icon indicating copy to clipboard operation
webots copied to clipboard

Resolve asset URL only once

Open ad-daniel opened this issue 3 years ago • 0 comments
trafficstars

Describe the Bug

URL fields in classes Background, Motor, ImageTexture, CadShape, ContactProperties, Skin cannot currently be used directly as depending on the format (relative, web, webots://) they need to be resolved first. Since this information often needs to be accessed in multiple functions (a single ImageTexture might require up to 4 resolving calls for example), the same resolving operation is done multiple time. If the URLs are relative this is especially heavy, but the other cases are wasteful too.

A possible improvement could be to have two separate variables, one to hold the raw value (mUrl, that we need to keep unchanged so that it gets saved to file as it was loaded) and one containing the resolved value (mResolvedUrl) so that even if there are multiple calls, the resolving logic is done only once.

ad-daniel avatar Sep 01 '22 08:09 ad-daniel