mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Optimize Mapp:RotateVertex()
This function can get rather expensive and waste a surprisingly large amount of time. Using moors as a test zone simply switching from the C math API cos/sin to std::cos/std::sin seemed to help 11.11% Map::RotateVertex(glm::tvec3<float, (glm::precision)0>&, float, float, float) 4.16% Map::RotateVertex(glm::tvec3<float, (glm::precision)0>&, float, float, float)
This commit is contained in:
parent
402353affa
commit
a9ff407657
12
zone/map.cpp
12
zone/map.cpp
@ -897,18 +897,18 @@ bool Map::LoadV2(FILE *f) {
|
||||
void Map::RotateVertex(glm::vec3 &v, float rx, float ry, float rz) {
|
||||
glm::vec3 nv = v;
|
||||
|
||||
nv.y = (cos(rx) * v.y) - (sin(rx) * v.z);
|
||||
nv.z = (sin(rx) * v.y) + (cos(rx) * v.z);
|
||||
nv.y = (std::cos(rx) * v.y) - (std::sin(rx) * v.z);
|
||||
nv.z = (std::sin(rx) * v.y) + (std::cos(rx) * v.z);
|
||||
|
||||
v = nv;
|
||||
|
||||
nv.x = (cos(ry) * v.x) + (sin(ry) * v.z);
|
||||
nv.z = -(sin(ry) * v.x) + (cos(ry) * v.z);
|
||||
nv.x = (std::cos(ry) * v.x) + (std::sin(ry) * v.z);
|
||||
nv.z = -(std::sin(ry) * v.x) + (std::cos(ry) * v.z);
|
||||
|
||||
v = nv;
|
||||
|
||||
nv.x = (cos(rz) * v.x) - (sin(rz) * v.y);
|
||||
nv.y = (sin(rz) * v.x) + (cos(rz) * v.y);
|
||||
nv.x = (std::cos(rz) * v.x) - (std::sin(rz) * v.y);
|
||||
nv.y = (std::sin(rz) * v.x) + (std::cos(rz) * v.y);
|
||||
|
||||
v = nv;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user