MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / Render

Method Render

src/Renderer/Renderer.cpp:64–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64AssetData Renderer::Render() {
65 ParamData userParams;
66
67 // Skip CAN animation of PS1 track loaded
68 bool camera_animation_played = track->tag == NFS_3_PS1;
69
70 if (track->tag == NFS_2_SE || track->tag == NFS_2 || track->tag == NFS_3_PS1) {
71 userParams.use_nb_data = false;
72 }
73
74 if (track->tag != NFS_3_PS1) {
75 mainCamera.setCameraAnimation(track->camera_animations);
76 }
77
78 // Detect position change to trigger Cull code
79 glm::vec3 oldWorldPosition(0, 0, 0);
80
81 ResetToVroad(0, track, car);
82
83 bool entity_targeted = false;
84 Entity *targetedEntity;
85
86 bool newAssetSelected = false;
87
88 while (!glfwWindowShouldClose(window)) {
89 // glfwGetTime is called only once, the first time this function is called
90 static double lastTime = glfwGetTime();
91 // Compute time difference between current and last frame
92 double currentTime = glfwGetTime();
93 // Update time between engine ticks
94 auto deltaTime = float(currentTime - lastTime); // Keep track of time between engine ticks
95
96 NewFrame(&userParams);
97 physicsEngine.mydebugdrawer.SetMatrices(mainCamera.ViewMatrix, mainCamera.ProjectionMatrix);
98
99 moon.attenuation.x = sun.attenuation.x = 0.710f;
100 moon.attenuation.y = sun.attenuation.y = 0;
101 moon.attenuation.z = sun.attenuation.z = 0;
102
103 // Play the original camera animation
104 if (!camera_animation_played) {
105 camera_animation_played = mainCamera.playAnimation();
106 } else if (userParams.attach_cam_to_hermite) {
107 mainCamera.useSpline(totalTime);
108 } else if (userParams.attach_cam_to_car) {
109 // Compute MVP from keyboard and mouse, centered around a target car
110 mainCamera.followCar(car, userParams.window_active, ImGui::GetIO());
111 } else {
112 // Compute the MVP matrix from keyboard and mouse input
113 mainCamera.computeMatricesFromInputs(userParams.window_active, ImGui::GetIO(), deltaTime);
114 }
115
116 //TODO: Refactor to controller class? AND USE SDL
117 if (userParams.simulate_car) {
118 car->simulate();
119 } else {
120 if (userParams.window_active && !ImGui::GetIO().MouseDown[1]) {
121 car->applyAccelerationForce(glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS,

Callers 2

runMethod · 0.45
TrainAgentsMethod · 0.45

Calls 15

setCameraAnimationMethod · 0.80
SetMatricesMethod · 0.80
playAnimationMethod · 0.80
useSplineMethod · 0.80
followCarMethod · 0.80
simulateMethod · 0.80
applyBrakingForceMethod · 0.80
applySteeringRightMethod · 0.80
applySteeringLeftMethod · 0.80
stepSimulationMethod · 0.80

Tested by

no test coverage detected