+1 vote

I already know how to use `Mesh.PRIMITIVE_TRIANGLES`, but I don't know what `Mesh.PRIMITIVE_TRIANGLE_STRIP` does and how to use it.

The documentation is very poor: `Render array as triangle strips`

Godot version Godot 3.5
in Engine

+1 vote

In a triangle strip, vertices are shared between triangles. As opposed to an un-indexed triangle list, where each triangle must be specified with 3 vertices each.

For example, lets say you want to create a rectangle from 4 vertices, A, B, C and D. Using an un-indexed triangle list (i.e. PRIMITIVE_TRIANGLES) you would have to specify the 3 vertices for each of the two triangles like this: ABC and *** (apparently you are not allowed to write C-B-D)

But using a triangle strip (i.e. PRIMITIVE_TRIANGLE_STRIP), you only need to specify the 4 vertices that form the two triangles like this: ABCD

The main benefit is that triangle strips are more memory efficient. Speed-wise there should'nt be much of a different.

If you are intrested in trying triangle strips, just be aware that some collision (specifically trimesh collision) could be trickier to achieve.

by (1,083 points)
selected

So let's say I use ABCDE, so it takes ABC for the first triangle and then drops the first point and adds the next, that is BCD (order may change to make this triangle face the same direccion as the first), and then CDE.

In my case, I want to build a hexagon:

``````# Vertices position
#   4
#  / \
# 3   5
# | 0 |
# 2   6
#  \ /
#   1
``````

I would say 0123456, but since 0 is dropped first, it doesn't work. I could try 1203456, but 0 is dropped later. So I guess I can't create a hexagon with `PRIMITIVE_TRIANGLES`.

As conclusion I would say that you can't use `PRIMITIVE_TRIANGLE_STRIP` if a vertex is shared between all the triangles.

Edit: see comment below

I answer my own comment, sorry. You must rethink the problem. I have to divide the hexagon in different triangles than in the `PRIMITIVE_TRIANGLES` case, 126354 works!

Another comment, if I use a convex collision shape, it works fine. With a trimesh shape, the behavior is not right.