diff --git a/physics/CMakeLists.txt b/physics/CMakeLists.txt index db256db4..fb452f1e 100644 --- a/physics/CMakeLists.txt +++ b/physics/CMakeLists.txt @@ -17,6 +17,7 @@ target_link_libraries(physics PRIVATE model rtperformance sndlib + plog::plog ) target_include_directories(physics PUBLIC $type); + LOG_WARNING.printf("Unhandled collision of object type %d and wall\n", A->type); // Error( "Unhandled object type hit wall in collide.c\n" ); } diff --git a/physics/findintersection.cpp b/physics/findintersection.cpp index 32196668..59241e49 100644 --- a/physics/findintersection.cpp +++ b/physics/findintersection.cpp @@ -860,7 +860,7 @@ #include "3d.h" #include "collide.h" #include "doorway.h" -#include "mono.h" +#include "log.h" #include "findintersection.h" #include "physics.h" #include "player.h" @@ -1780,7 +1780,7 @@ int check_vector_to_object(vector *intp, float *col_dist, vector *p0, vector *p1 #ifdef _DEBUG if (Physics_player_verbose) { if (Player_object == &Objects[fvi_objnum]) { - mprintf(0, "FVI: Earily exit on %d\n", OBJNUM(still_obj)); + LOG_DEBUG.printf("FVI: Earily exit on %d", OBJNUM(still_obj)); } } #endif @@ -1796,9 +1796,9 @@ int check_vector_to_object(vector *intp, float *col_dist, vector *p0, vector *p1 if (total_size <= 0.0f) { #ifdef _DEBUG if (fvi_objnum >= 0) - mprintf(0, "Get Chris: type %d and type %d are zero radius\n", still_obj->type, Objects[fvi_objnum].type); + LOG_DEBUG.printf("Get Chris: type %d and type %d are zero radius", still_obj->type, Objects[fvi_objnum].type); else - mprintf(0, "Get Chris: A non-object tried to hit a zero radii object of type %d\n", still_obj->type); + LOG_DEBUG.printf("Get Chris: A non-object tried to hit a zero radii object of type %d", still_obj->type); #endif return 0; } @@ -2618,8 +2618,8 @@ int fvi_FindIntersection(fvi_query *fq, fvi_info *hit_data, bool no_subdivision) #ifndef NED_PHYSICS if (Tracking_FVI) { - mprintf(0, "Track FVI - Ray %d, thisobjnum=%d, startroom=%d, rad=%f\n", FVI_counter, fq->thisobjnum, fq->startroom, - fq->rad); + LOG_DEBUG.printf("Track FVI - Ray %d, thisobjnum=%d, startroom=%d, rad=%f", + FVI_counter, fq->thisobjnum, fq->startroom, fq->rad); } #endif @@ -3352,9 +3352,9 @@ void check_hit_obj(int objnum) { #ifdef _DEBUG if (Physics_player_verbose) { if (OBJNUM(Player_object) == objnum && m_obj_index != -1) { - mprintf(0, "FVI: %d AABB with player\n", m_obj_index); + LOG_DEBUG.printf("FVI: %d AABB with player", m_obj_index); } else if (Player_object == m_obj) { - mprintf(0, "FVI: Player AABB with %d\n", objnum); + LOG_DEBUG.printf("FVI: Player AABB with %d", objnum); } } #endif @@ -3593,7 +3593,7 @@ void check_hit_obj(int objnum) { } break; default: { - mprintf(0, "Collision of type %d is not programmed yet", collision_type); + LOG_WARNING.printf("Collision of type %d is not programmed yet", collision_type); } break; } } else { @@ -3601,7 +3601,7 @@ void check_hit_obj(int objnum) { #ifdef _DEBUG if (Physics_player_verbose) { if (OBJNUM(Player_object) == objnum || Player_object == m_obj) { - mprintf(0, "Related\n"); + LOG_DEBUG << "Related"; } } #endif @@ -3612,7 +3612,7 @@ void check_hit_obj(int objnum) { #ifdef _DEBUG if (Physics_player_verbose) { if (OBJNUM(Player_object) == objnum || Player_object == m_obj) { - mprintf(0, "Ignore list\n"); + LOG_DEBUG << "Ignore list"; } } #endif @@ -3626,7 +3626,7 @@ void check_hit_obj(int objnum) { if (Physics_player_verbose) { if (objnum != m_obj_index) { if (OBJNUM(Player_object) == objnum || Player_object == m_obj) { - mprintf(0, "Result nothing %d %d\n", objnum, m_obj_index); + LOG_DEBUG.printf("Result nothing %d %d", objnum, m_obj_index); } } } @@ -3638,7 +3638,7 @@ void check_hit_obj(int objnum) { #ifdef _DEBUG if (Physics_player_verbose) { if (OBJNUM(Player_object) == objnum || Player_object == m_obj) { - mprintf(0, "Dead %d %d\n", objnum, m_obj_index); + LOG_DEBUG.printf("Dead %d %d", objnum, m_obj_index); } } #endif diff --git a/physics/newstyle_fi.cpp b/physics/newstyle_fi.cpp index 09a9adec..960e0784 100644 --- a/physics/newstyle_fi.cpp +++ b/physics/newstyle_fi.cpp @@ -18,6 +18,7 @@ #include "findintersection.h" #include "game.h" +#include "log.h" #include "polymodel.h" #include "pserror.h" #include "vecmat.h" @@ -197,7 +198,7 @@ static void CollideSubmodelFacesUnsorted(poly_model *pm, bsp_info *sm) { fvi_hit_param = (newp - *fvi_query_ptr->p0) * x; if (!(fvi_hit_param > -10000000.0 && fvi_hit_param < 10000000.0)) { - mprintf(0, "FVI Warning: fvi_hit_param seems yucky!\n"); + LOG_WARNING << "FVI Warning: fvi_hit_param seems yucky!"; } fvi_collision_dist = col_dist; diff --git a/physics/physics.cpp b/physics/physics.cpp index f81256e2..54a17e70 100644 --- a/physics/physics.cpp +++ b/physics/physics.cpp @@ -27,6 +27,7 @@ #include "findintersection.h" #include "fireball.h" #include "game.h" +#include "log.h" #include "multi.h" #include "object.h" #include "physics.h" @@ -110,7 +111,7 @@ void DoPhysLinkedFrame(object *obj) { mn = obj->mtype.obj_link_info.sobj_index; if (mn < 0 || mn >= pm->n_models) { - mprintf(0, "Caught physics link bug!\n"); + LOG_WARNING << "Caught physics link bug!"; SetObjectDeadFlag(obj); return; } @@ -172,7 +173,7 @@ bool PhysCalcGround(vector *ground_point, vector *ground_normal, object *obj, in pm = &Poly_models[obj->rtype.pobj_info.model_num]; if (pm->n_ground == 0) { - mprintf(0, "WARNING: Object with no weapons is firing.\n", ground_num); + LOG_WARNING.printf("Object %d with no weapons is firing.", ground_num); if (ground_point) *ground_point = obj->pos; @@ -187,7 +188,7 @@ bool PhysCalcGround(vector *ground_point, vector *ground_normal, object *obj, in SetModelAnglesAndPos(pm, normalized_time); if (ground_num < 0 || ground_num >= pm->n_ground) { - mprintf(0, "WARNING: Bashing ground num %d to 0.\n", ground_num); + LOG_WARNING.printf("Bashing ground num %d to 0.", ground_num); ground_num = 0; f_good_gp = false; } @@ -671,7 +672,7 @@ void PhysicsDoSimLinear(const object &obj, const vector &pos, const vector &forc #ifdef _DEBUG if (Physics_player_verbose && obj.type == OBJ_PLAYER) { - mprintf(0, "Player Velocity = %f(%f)\n", vm_GetMagnitude(&velocity), vm_GetMagnitude(&movementVec) / simTime); + LOG_DEBUG.printf("Player Velocity = %f(%f)", vm_GetMagnitude(&velocity), vm_GetMagnitude(&movementVec) / simTime); } #endif } @@ -1095,15 +1096,14 @@ void do_physics_sim(object *obj) { Objects[objnum].lifetime = 10.0f; } if (obj == Player_object) { - mprintf(0, "Fate = %d for player - ", fate); if (fate == HIT_OBJECT || fate == HIT_SPHERE_2_POLY_OBJECT) { if (Objects[hit_info.hit_object[0]].flags & OF_BIG_OBJECT) { - mprintf(0, "Big object\n"); + LOG_DEBUG.printf("Fate = %d for player - Big object", fate); } else { - mprintf(0, "Small object\n"); + LOG_DEBUG.printf("Fate = %d for player - Small object", fate); } } else { - mprintf(0, "non-object\n"); + LOG_DEBUG.printf("Fate = %d for player - non-object", fate); } } } @@ -1333,7 +1333,7 @@ void do_physics_sim(object *obj) { if (obj->type != OBJ_PLAYER) SetObjectDeadFlag(obj); else - mprintf(0, "Got a ship that was set for bounce!!! BAD!!!\n"); + LOG_WARNING << "Got a ship that was set for bounce!!! BAD!!!"; } } obj->mtype.phys_info.num_bounces--; @@ -1430,7 +1430,7 @@ void do_physics_sim(object *obj) { fabs(obj->mtype.phys_info.velocity.z) < MAX_OBJECT_VEL)) { float mag = vm_NormalizeVector(&obj->mtype.phys_info.velocity); - mprintf(0, "PHYSICS: Bashing vel for Obj %d of type %d with %f velocity", objnum, obj->type, mag); + LOG_DEBUG.printf("Bashing vel for Obj %d of type %d with %f velocity", objnum, obj->type, mag); obj->mtype.phys_info.velocity *= MAX_OBJECT_VEL * 0.1f; } @@ -1566,12 +1566,12 @@ void do_physics_sim(object *obj) { } break; case HIT_BAD_P0: - mprintf(0, "PHYSICS ERROR: Bad p0 in physics!!!\n"); + LOG_ERROR << "Bad p0 in physics!!!"; Int3(); // Unexpected collision type: start point not in specified segment. break; default: - mprintf(0, "PHYSICS ERROR: Unknown and unhandled hit type returned from FVI\n"); + LOG_ERROR << "Unknown and unhandled hit type returned from FVI"; Int3(); break; } @@ -1586,7 +1586,7 @@ void do_physics_sim(object *obj) { // NOTE: These numbers limit the max collisions an object can have in a single frame if (count >= sim_loop_limit) { if (obj->type == OBJ_PLAYER) { - mprintf(0, "PHYSICS NOTE: Too many collisions for player!\n"); + LOG_WARNING << "Too many collisions for player!"; obj->mtype.phys_info.velocity = Zero_vector; } } @@ -1750,7 +1750,7 @@ bool PhysComputeWalkerPosOrient(object *obj, vector *pos, matrix *orient) { fate = PhysCastWalkRay(obj, &obj->pos, &foot_pnt, &hp); if (fate == HIT_NONE) { - mprintf(0, "Walking object %d should be falling\n", OBJNUM(obj)); + LOG_WARNING.printf("Walking object %d should be falling", OBJNUM(obj)); // SetObjectDeadFlag(obj); f_ok = false; } else { @@ -2136,7 +2136,7 @@ void do_walking_sim(object *obj) { goto end_of_sim; } else if (fate == HIT_OUT_OF_TERRAIN_BOUNDS) { - mprintf(0, "PHYSICS NOTE: Walker exited terrain\n"); + LOG_WARNING << "Walker exited terrain"; SetObjectDeadFlag(obj); obj->last_pos = init_pos; @@ -2166,7 +2166,7 @@ void do_walking_sim(object *obj) { // moved backwards if (fate == HIT_WALL && moved_vec_n * movement_vec < -0.000001 && actual_dist != 0.0) { - mprintf(0, "Obj %d Walked backwards!\n", OBJNUM(obj)); + LOG_WARNING.printf("Obj %d Walked backwards!", OBJNUM(obj)); /* mprintf(0, "PHYSICS NOTE: (%f, %f, %f) to (%f, %f, %f)\n", XYZ(&start_pos), @@ -2191,9 +2191,8 @@ void do_walking_sim(object *obj) { // chrishack -- negative simulation time pasted for this sim frame if (sim_time_remaining > old_sim_time_remaining) { - mprintf(0, - "PHYSICS WARNING: Bogus sim_time_remaining = %15.13f, old = %15.13f\nAttempted d = %15.13f, actual " - "= %15.13f\n", + LOG_WARNING.printf( + "Bogus sim_time_remaining = %15.13f, old = %15.13f; Attempted d = %15.13f, actual = %15.13f", sim_time_remaining, old_sim_time_remaining, attempted_dist, actual_dist); // Int3(); sim_time_remaining = old_sim_time_remaining; @@ -2316,7 +2315,7 @@ void do_walking_sim(object *obj) { fabs(obj->mtype.phys_info.velocity.z) < MAX_OBJECT_VEL)) { float mag = vm_NormalizeVector(&obj->mtype.phys_info.velocity); - mprintf(0, "PHYSICS: Bashing vel for Obj %d of type %d with %f velocity", objnum, obj->type, mag); + LOG_WARNING.printf("Bashing vel for Obj %d of type %d with %f velocity", objnum, obj->type, mag); obj->mtype.phys_info.velocity *= MAX_OBJECT_VEL * 0.1f; } @@ -2385,12 +2384,12 @@ void do_walking_sim(object *obj) { } break; case HIT_BAD_P0: - mprintf(0, "PHYSICS ERROR: Bad p0 in physics!!!\n"); + LOG_ERROR << "Bad p0 in physics!!!"; Int3(); // Unexpected collision type: start point not in specified segment. break; default: - mprintf(0, "PHYSICS ERROR: Unknown and unhandled hit type returned from FVI\n"); + LOG_ERROR << "Unknown and unhandled hit type returned from FVI"; Int3(); break; } @@ -2405,7 +2404,7 @@ void do_walking_sim(object *obj) { // NOTE: These numbers limit the max collisions an object can have in a single frame if (count >= sim_loop_limit) { if (obj->type == OBJ_PLAYER) { - mprintf(0, "PHYSICS NOTE: Too many collisions for player!\n"); + LOG_WARNING << "PHYSICS NOTE: Too many collisions for player!"; } } @@ -2580,9 +2579,7 @@ void phys_apply_force(object *obj, vector *force_vec, int16_t weapon_index) { ForceEffectsPlay(FORCE_TEST_FORCE, &scale, &local_norm); } - if (weapon_index != -1) { - mprintf(0, "Force from weapon\n"); - } + LOG_DEBUG_IF(weapon_index != -1) << "Force from weapon"; // mprintf(0,"Force: Magnitude = %f Scale = %1.3f\n",magnitude,scale); }