MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Update

Method Update

Source/Main/scenegraph.cpp:904–1033  ·  view source on GitHub ↗

Update all objects

Source from the content-addressed store, hash-verified

902
903// Update all objects
904void SceneGraph::Update(float timestep, float curr_game_time) {
905 if (queued_level_reset_) {
906 PROFILER_ZONE(g_profiler_ctx, "Resetting level");
907 queued_level_reset_ = false;
908 Level::CollisionPtrMap blank;
909 level->HandleCollisions(blank, *this);
910 SendMessageToAllObjects(OBJECT_MSG::RESET);
911 level->Message("post_reset");
912 }
913
914 // uint64_t start_count = SDL_GetPerformanceCounter();
915 {
916 PROFILER_ZONE(g_profiler_ctx, "Bullet world update");
917 bullet_world_->Update(timestep);
918 }
919 // uint64_t end_count = SDL_GetPerformanceCounter();
920 plant_bullet_world_->Update(timestep);
921
922 {
923 PROFILER_ZONE(g_profiler_ctx, "Abstract world collisions");
924 level->HandleCollisions(abstract_bullet_world_->GetCollisions(), *this);
925 }
926
927 {
928 // Only updating specific subtypes of objects? -Max
929 PROFILER_ZONE(g_profiler_ctx, "Object updates");
930 for (int i = 0; i < num_update_objects; ++i) {
931 Object* obj = update_objects_[i];
932 PROFILER_ZONE(g_profiler_ctx, "%s %d update", CStringFromEntityType(obj->GetType()), obj->GetID());
933 obj->ReceiveObjectMessage(OBJECT_MSG::UPDATE, timestep);
934 }
935 /*
936 for(object_list::iterator it = objects_.begin(); it != objects_.end();) {
937 Object* obj = *it;
938 if(obj->active){
939 PROFILER_ZONE(g_profiler_ctx,"%s %d update",CStringFromEntityType(obj->GetType()),obj->GetID());
940 obj->Update();
941 }
942 ++it;
943 if(obj->to_delete){
944 UnlinkObject(obj);
945 delete obj;
946 }
947 }*/
948 }
949
950 // Checking sanity, a couple of objects at a time
951 int partial_loop_countdown = 10;
952 size_t objects_size = objects_.size();
953 while (objects_size > 0 && partial_loop_countdown > 0) {
954 if (partial_object_loop_counter >= objects_size) {
955 partial_object_loop_counter = 0;
956 }
957
958 int i = partial_object_loop_counter;
959
960 ObjectSanityState oss = objects_[i]->GetSanity();
961

Callers

nothing calls this directly

Calls 15

CStringFromEntityTypeFunction · 0.85
ObjectSanityStateClass · 0.85
findFunction · 0.85
HandleCollisionsMethod · 0.80
OkMethod · 0.80
MessageMethod · 0.45
GetTypeMethod · 0.45
GetIDMethod · 0.45
ReceiveObjectMessageMethod · 0.45
sizeMethod · 0.45
GetSanityMethod · 0.45

Tested by

no test coverage detected