Pignon
April 4, 2021, 12:32pm
1
When I do this:
for x in range(1, 10):
hex_2 = base.loader.loadModel("../models/grass_hex2")
hex_2.getChild(0).setPos(x*10, 0, 0)
hex_2.getChild(0).reparentTo(tiles)
tiles.flatten_strong()
I get still 9 geoms but without setting the position it works. Of course then all the models are in one place… how can I do this with setting position for each geom?
rdb
April 4, 2021, 12:52pm
2
You can’t move the individual parts of something that has been flattened. You can use the RigidBodyCombiner to automatically manage reflattening after moving something (but it will have significant performance penalties), or use an alternative method, such as hardware instancing.
Note that the grass isn’t all flattened together yet unless you also call hex_2.clearModelNodes()
after loading.
Pignon
April 4, 2021, 12:59pm
3
I am changing position of the models before flatten.
If I dont ‘setPos’, then it results desirably in only 1 Geom. So I think, I dont need to do hex_2.clearModelNodes()
.(edit:) It doesnt change anything.
If I understand it correctly, I dont need to do it because I reparent the Geoms NP and not the Model NP.
Basically, you are combining the geometry into a single node. This is an irreversible action.
Pignon
April 4, 2021, 1:19pm
5
I dont think you get what the problem is guys. I dont want to move them after flatten. If I do it before flatten, flatten doesnt work.
Hmm for me it works as expected, it looks like I really did not understand you.
from panda3d.core import NodePath
from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
all_node = NodePath('all')
for i in range(0, 10):
for j in range(0, 10):
model = loader.load_model("panda")
model.clear_model_nodes()
model.set_pos(i*10, j*10, 0)
model.reparent_to(all_node)
all_node.flatten_strong()
all_node.reparent_to(render)
print(all_node.ls())
app = MyApp()
app.run()
Pignon
April 4, 2021, 1:29pm
7
GeomNode (3200 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
It should be 1, right?
How does it generate 3200 geoms? It completely freezeed my pc when I moved the cam, lol.
Geometry is not nodes, consider the geom as a mesh.
Pignon
April 4, 2021, 1:31pm
9
Hm does panda do flatten automatically? I didnt notice any performance difference then.
It doesn’t flatten them automatically.
use flatten_strong()
Character panda.egg
GeomNode (115 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
None
not use flatten_strong()
PandaNode all
ModelRoot panda.egg
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 0 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 10 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 20 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 30 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 40 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 50 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 60 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 70 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 80 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 0 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 10 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 20 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 30 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 40 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 50 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 60 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 70 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 80 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
ModelRoot panda.egg T:(pos 90 90 0)
Character panda_soft
GeomNode (10 geoms: S:(ColorAttrib TextureAttrib TransparencyAttrib))
None
In the second case, there will be more calls for the video card. Try creating a really large amount of geometry to compare performance with and without flatten_strong ().
Pignon
April 4, 2021, 1:40pm
11
Thats what I did and I got confused. 200 pandas with flatten 35fps, 200 without flatten still 35fps.
rdb
April 4, 2021, 1:41pm
12
What’s the result of analyze()
and ls()
on the resulting flattened node? Did you use clearModelNodes()?
200 this is not enough, you need 10 000 and also disable vertical synchronization.
Pignon
April 4, 2021, 1:45pm
14
3 total nodes (including 0 instances); 0 LODNodes.
0 transforms; 0% of nodes have some render attribute.
1600 Geoms, with 1000 GeomVertexDatas and 3 GeomVertexFormats, appear on 1 GeomNodes.
2449000 vertices, 2449000 normals, 2449000 colors, 846400 texture coordinates.
GeomVertexData arrays occupy 132074K memory.
GeomPrimitive arrays occupy 6285K memory.
1602600 vertices are unreferenced by any GeomPrimitives.
2392 GeomVertexArrayDatas are redundant, wasting 82084K.
1393 GeomPrimitive arrays are redundant, wasting 6246K.
1334400 triangles:
0 of these are on 0 tristrips.
1334400 of these are independent triangles.
4 textures, estimated minimum 1200K texture memory required.
edit:
This is the serega-kkz example with 200 pandas btw.
Could it be because of old GPU or drivers? 2600XT
Im gonna try the same thing on W7 with Dx9.
The driver has nothing to do with it, it’s a function of the panda.
Pignon
April 4, 2021, 2:17pm
16
Well, on W7 dx9, the same thing. Fps stayed the same with and without flatten. The only difference was that the number of geoms was 16 on W7/dx9 and 399 on Ubuntu/opengl.
You’re not doing everything right.
Off sync video
Add more nodes.
Try to capture all the objects in the camera.
Pignon
April 4, 2021, 2:28pm
18
Whats the point of adding more nodes? It would crash my pc. There should be a difference once you get below 60. I had Vsync off on W7. Obviously I did it correctly when it shrunk the number of geoms to 16.
The point is that you won’t see a performance difference with a small number of nodes. What do you expect from using flatten_strong ()?
Pignon
April 4, 2021, 2:36pm
20
Might be my CPU fast enough for flatten to make no difference? I guess that might be it. If it only saves CPU?