How does RID obtain Transform through Rendering Server?

Godot Version

Godot-4.2.1-Mono

Question

I create a CanvasItem through RenderingServer. CanvasItemCreate() and RenderingServer has a method called CanvasItemSetTransform(), but it doesn’t have a method called CanvasItemGetTransform(). How can I get the Transform for this RID?

If you have just created a CanvasItem through the rendering server, the transform will be equals to Transform2D.Identity until you call the set transform method.

I mean that I have cached a large number of RIDs. How can I obtain Transform2D through these RIDs?

If you create a CanvasItem-derived Node, then you can access the transform as the transform property. Otherwise you have to set the transform manually from the RenderingServer, so you must have had it at some point. You just have to keep track of that manually if it’s that important. I cannot conceive a use case for this, tho. You’re omitting crucial details about your intent.

	private Texture2D _texture1;
		private Texture2D _texture2;
		private Vector2I _size;
		private int _culls;
		private Rid[] _rids;
		private Rid[] _chunks;

		public override void _Ready() {
			_culls = 16;
			_size = new Vector2I(16, 16);
			_rids = new Rid[_size.X * _size.Y];
			_chunks = new Rid[_size.X * _size.Y / _culls];
			_texture1 = GD.Load<Texture2D>("res://texture/tile/tile-1.png");
			_texture2 = GD.Load<Texture2D>("res://texture/tile/tile-2.png");
			int index = 0;
			for (int i = 0; i < _size.X; i++) {
				for (int j = 0; j < _size.Y; j++) {
					_rids[index] = RenderingServer.CanvasItemCreate();
					RenderingServer.CanvasItemAddTextureRect(_rids[index],
						new Rect2(_texture1.GetSize(), _texture1.GetSize()),
						_texture1.GetRid());
					Transform2D transform = Transform2D.Identity.Translated(new Vector2(i * 32, j * 32));
					RenderingServer.CanvasItemSetTransform(_rids[index], transform);
					index += 1;
				}
			}

			int width = 4;

			for (int i = 0, v = 0; i < _chunks.Length; i++) {
				int x = i % width;
				int y = i / width;
				_chunks[i] = RenderingServer.CanvasItemCreate();
				RenderingServer.CanvasItemSetParent(_chunks[i], GetCanvasItem());
				for (int j = 0; j < (_size.X * _size.Y / _culls); j++) {
					RenderingServer.CanvasItemSetParent(_rids[j * (_size.X * _size.Y / _culls) + v], _chunks[i]);
				}
				v += 1;
			}
		}

		public override void _PhysicsProcess(double delta) {
			Task.Run(() => {
				Parallel.ForEach(_chunks, (rid) => {
				});
			});
		}

This is my code, I don’t know how to get the Transform for each RID

Why would you need it? You can just render the CanvasItem and it will use its transform.

Yes, you are right. I may have lost my head mable😫

All I have is a “Mabel”, sorry.
image