本文整理汇总了C++中Solid::get_rotation_cache方法的典型用法代码示例。如果您正苦于以下问题:C++ Solid::get_rotation_cache方法的具体用法?C++ Solid::get_rotation_cache怎么用?C++ Solid::get_rotation_cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solid
的用法示例。
在下文中一共展示了Solid::get_rotation_cache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tick
void World::tick(float time)
{
float ay = GRAVITY * time;
float damping = pow(DAMPING, time);
float angular_damping = pow(ANGULAR_DAMPING, time);
WeakSet<Solid*>::iterator si = solids.begin();
WeakSet<Solid*>::iterator sie = solids.end();
while (si != sie)
{
Solid *s = *si;
// TODO: Remove sqrt
float steps = floor(s->max_rad * s->vr + sqrt(s->vx * s->vx + s->vy * s->vy));
s->vx *= damping;
s->vy *= damping;
s->vr *= angular_damping;
s->vy += ay;
float vx = s->vx / steps;
float vy = s->vy / steps;
float vr = s->vr / steps;
unsigned int i = steps;
while (i--)
{
s->x += vx;
s->y += vy;
s->r += vr;
float sin_r = sin(s->r);
float cos_r = cos(s->r);
Solid::RotationCache rc = s->get_rotation_cache();
signed int aabb[4];
aabb[Direction::up ] = s->y + rc.aabb[Direction::up ];
aabb[Direction::down ] = s->y + rc.aabb[Direction::down ];
aabb[Direction::left ] = s->x + rc.aabb[Direction::left ];
aabb[Direction::right] = s->x + rc.aabb[Direction::right];
Chunk *chunk = s->chunk;
const std::vector<std::uint16_t> &cps = s->get_collision_particles();
std::vector<std::uint16_t>::const_iterator cpsi = cps.cbegin();
while (cpsi != cps.cend())
{
unsigned int i = *cpsi;
signed int x = s->x + s->particles[i]->rx * cos_r - s->particles[i]->ry * sin_r;
signed int y = s->y + s->particles[i]->rx * sin_r + s->particles[i]->ry * cos_r;
signed int cx = (x / CHUNK_SIZE) * CHUNK_SIZE;
signed int cy = (y / CHUNK_SIZE) * CHUNK_SIZE;
if (cx != chunk->x || cy != chunk->y)
{
while (cx < chunk->x)
{
chunk = chunk->neighbor(this, Chunk::neighbor_left);
cx += CHUNK_SIZE;
}
while (cx > chunk->x)
{
chunk = chunk->neighbor(this, Chunk::neighbor_right);
cx -= CHUNK_SIZE;
}
while (cy < chunk->y)
{
chunk = chunk->neighbor(this, Chunk::neighbor_up);
cy += CHUNK_SIZE;
}
while (cx > chunk->x)
{
chunk = chunk->neighbor(this, Chunk::neighbor_down);
cy -= CHUNK_SIZE;
}
}
Cell *cell = chunk->cells + (x - cx) + (y - cy) * CHUNK_SIZE;
switch (cell->state)
{
case Cell::state_air:
break;
case Cell::state_static:
break;
case Cell::state_solid:
break;
case Cell::state_particle:
break;
}
cpsi++;
}
}
si++;
//.........这里部分代码省略.........