Hi,
I am writing a simple simulation where, i spread over 400 sheeps in a geomipmapped terrain and around 30 shepherds, the job of the shepherds is to walk around and tag the sheep.
I am using the ralph model as the shepherd and the panda as the sheep for now. One problem i am running into is my frame rate drops drastically as I zoom out and see more of the terrain.
I am pasting below what the text-pstats shows me
Draw = 74.0662 ms
Flush = 0 ms
Clear = 0.198364 ms
Transfer data = 0.167847 ms
Texture = 0 ms
Index buffer = 0 ms
Vertex buffer = 0.167847 ms
Make current = 4.32587 ms
window1 = 69.3741 ms
dr_0 = 69.0384 ms
transparent = 0.488281 ms
opaque = 68.4967 ms
dr_1 = 0.0457764 ms
unsorted = 0 ms
dr_2 = 0.0152588 ms
dr_3 = 0.0991821 ms
transparent = 0.0915527 ms
Cull = 2.02942 ms
Sort = 0.0152588 ms
transparent = 0 ms
opaque = 0.00762939 ms
Setup = 0.0457764 ms
window1 = 1.96838 ms
dr_0 = 1.6861 ms
dr_1 = 0.038147 ms
dr_2 = 0.0152588 ms
dr_3 = 0.0152588 ms
App = 41.7175 ms
Show code = -0.495911 ms
General = -3.24249 ms
ivalLoop = 0.801086 ms
pandaPace = 0 ms
LerpPosInterval = 0 ms
LerpHprInterval = 0 ms
LerpHprInterval = 0.717163 ms
DIRECTContextTask = 0.0228882 ms
audioLoop = 0.0228882 ms
igLoop = 1.69373 ms
collisionLoop = 0.0228882 ms
dataLoop = 0.0534058 ms
resetPrevTransform = 0.00762939 ms
eventManager = 0.0610352 ms
SpinCameraTask = 0 ms
gameLoop = 0.0152588 ms
updateTerrain = 0.00762939 ms
dragTask = 0.038147 ms
renderStats = 0 ms
Collisions = 6.75201 ms
Reset = 0.343323 ms
ctrav = 6.40869 ms
pass1 = 6.19507 ms
DirectSelection = 0 ms
pass1 = 0 ms
render_frame = 1.91498 ms
Yield = 0 ms
World = 11.6425 ms
update = 11.5204 ms
handleCollisions = 0.12207 ms
Terrain = 3.92151 ms
clampToValidPos = 3.92151 ms
sheep = 17.1585 ms
doAutoMove = 11.6043 ms
doAutoFollow = 1.2207 ms
move = 4.3335 ms
shepherd = 0.823975 ms
move = 0.823975 ms
Wait = 0.900269 ms
Flip = 0 ms
Thread sync = 0 ms
Thread block = 0.900269 ms
* = 12.6877 ms
Animation = 0.892639 ms
panda_walk_character = 0.534058 ms
Joints = 0.137329 ms
Skinning = 0.221252 ms
Ralph = 0.358582 ms
Joints = 0.0839233 ms
Skinning = 0.198364 ms
PStats = 0.686646 ms
Munge = 9.25446 ms
Geom = 9.25446 ms
Show fps = 0.038147 ms
Bounds = 1.64032 ms
do_frame = 0.175476 ms
Premunge = 0 ms
Generate Text = 0 ms
Nodes = 169
GeomNodes = 69
Geoms = 73
SW Sprites = 0 K
RenderStates = 66
Cached = 17
On nodes = 13
TransformStates = 949
Cached = 249
On nodes = 697
Occlusion results = 0
Not tested = 0
Visible = 0
Occluded = 0
Occlusion tests = 0
System memory = 76.7745 MB
MMap = 14.125 MB
NeverFree = 9.16952 MB
Unused = 0.0671616 MB
Active = 9.10236 MB
GLVertexBufferContext = 0.114609 MB
GLIndexBufferContext = 0.0602913 MB
PythonTask = 0.00196838 MB
NodePathComponent = 0.0588608 MB
CullableObject = 0.0030632 MB
GeomTextGlyph = 0.0105057 MB
BoundingSphere = 0.233459 MB
GeomVertexData = 0.321316 MB
GeomVertexArrayData = 0.386505 MB
GeomPrimitive = 0.0951309 MB
Geom = 0.199013 MB
= 0.0856018 MB
CacheEntry = 0.0856018 MB
TransformState = 0.220829 MB
RenderState = 0.0256805 MB
CopyOnWriteObj<7pvectorIN8GeomNode9GeomEntryEE> = 0.103203 MB
CopyOnWriteObj1<6ov_setIN9PandaNode12UpConnectionESt4lessIS1_EE> = 0.313545 MB
CopyOnWriteObj1<11ov_multisetIN9PandaNode14DownConnectionESt4lessIS1_EE> = 0.62709 MB
pset = 0.103157 MB
pmap = 6.14476 MB
NodeReferenceCount = 0.0389328 MB
Other = 0.0179787 MB
LVecBase3f = 0.0149689 MB
GLGeomMunger = 0.00508881 MB
GLTextureContext = 0.00240326 MB
Inactive = 0 MB
Other = 0 MB
Heap = 62.6495 MB
External = 0 MB
Array = 52.0351 MB
Other = 0.00133514 MB
pvector = 21.7857 MB
ov_set = 5.86221 MB
Texture = 0.0944452 MB
AnimChannelMatrixXfmTable = 0.0372505 MB
VertexDataBuffer = 23.6103 MB
int = 0.0301857 MB
pdeque = 0.00786209 MB
PandaNode = 0.0498695 MB
PartGroup = 0.131023 MB
Single = 10.6145 MB
Other = 0 MB
Overhead = 0 MB
Collision Volumes = 12120
CollisionGeom = 0
CollisionInvSphere = 0
PandaNode = 12120
CollisionPlane = 0
CollisionPolygon = 0
CollisionSolid = 0
CollisionSphere = 0
CollisionNode = 0
GeomNode = 0
Geom = 0
CollisionTube = 0
Collision Tests = 0
CollisionGeom = 0
CollisionInvSphere = 0
CollisionPlane = 0
CollisionPolygon = 0
CollisionSolid = 0
CollisionSphere = 0
CollisionTube = 0
Vertex Data = 23.6103 MB
Disk = 0 MB
Used = 0 MB
Unused = 0 MB
Compressed = 0 MB
Resident = 0 MB
Pending = 0 MB
Small = 0.0289268 MB
Independent = 23.5814 MB
Vertex buffer switch = 0
Index = 0
Vertex = 0
Data transferred = 0.239166 MB
Primitive batches = 0
Display lists = 0
Triangle strips = 248
Triangle fans = 0
Triangles = 39
Other = 0
Vertices = 228.204 K
Immediate mode = 0 K
Display lists = 0 K
Triangle strips = 10.014 K
Triangle fans = 0 K
Triangles = 218.19 K
Other = 0 K
State changes = 145
Textures = 24
Transforms = 69
Graphics memory = 31.1806 MB
context1 = 31.1806 MB
Active = 6.90921 MB
texture = 5.13118 MB
vbuffer = 1.63936 MB
ibuffer = 0.138668 MB
Thrashing = 0 MB
texture = 0 MB
vbuffer = 0 MB
ibuffer = 0 MB
Inactive = 24.2714 MB
texture = 3.11458 MB
vbuffer = 20.2683 MB
ibuffer = 0.888512 MB
Nonresident = 0 MB
texture = 0 MB
vbuffer = 0 MB
ibuffer = 0 MB
Geom cache size = 1584
Active = 73
Geom cache operations = 0
evict = 0
erase = 0
record = 0
</snip>
The part I want to understand is why does "Draw" take so much more time and two why does my the following part take like 18ms i would expect it to be far less.
sheep = 17.1585 ms
doAutoMove = 11.6043 ms
doAutoFollow = 1.2207 ms
move = 4.3335 ms
Further these functions are called irrespective of whether a sheep is visible or not, so I would expect the time spent here to be a constant but it seems to go up a lot when more sheep are visible.
All the doAutoMove code does is the follow
@pstat_obj("sheep")
def doAutoMove(self):
elapsedTime = globalClock.getDt()
posTransform = self.actor.getNetTransform().getMat().getRow3(1)
posTransform.setZ(0)
posTransform.normalize()
newPos = self.actor.getPos() - posTransform*(elapsedTime*self.speed)
self.actor.setPos(self.world.terrain.clampToValidPos(newPos))
The clampToValidPos does the following
@pstat_obj("Terrain")
def clampToValidPos(self,pos):
if (pos.getX()<0):
pos.setX(0)
if (pos.getY()<0):
pos.setY(0)
if (pos.getX() > self.mapSizeX):
pos.setX(self.mapSizeX-1)
if (pos.getY() > self.mapSizeY):
pos.setY(self.mapSizeY-1)
elevation = self.terrain.getElevation(pos.getX(),pos.getY()) * self.mapScaleZ
pos.setZ(elevation)
return pos
Am I doing something wrong?