void set(int p, uint32_t r, uint32_t c, ColorVal x) { assert(p>=0); if (p < 4 && constant[p]) { if (x == constant_val[p]) return; constant[p] = false; } #ifdef SUPPORT_HDR if (depth <= 8) { #endif switch(p) { case 0: return plane_8_1->set(r,c,x); case 1: return plane_16_1->set(r,c,x); case 2: return plane_16_2->set(r,c,x); case 3: return plane_8_2->set(r,c,x); default: return plane_frame_lookbacks->set(r,c,x); } #ifdef SUPPORT_HDR } else { switch(p) { case 0: return plane_16_1->set(r,c,x); case 1: return plane_32_1->set(r,c,x); case 2: return plane_32_2->set(r,c,x); case 3: return plane_16_2->set(r,c,x); default: return plane_frame_lookbacks->set(r,c,x); } } #endif }
// access pixel by coordinate ColorVal operator()(const int p, const uint32_t r, const uint32_t c) const { assert(p>=0); assert(depth == 8 || depth == 16); if (p<4 && constant[p]) return constant_val[p]; #ifdef SUPPORT_HDR if (depth <= 8) { #endif switch(p) { case 0: return plane_8_1->get(r,c); case 1: return plane_16_1->get(r,c); case 2: return plane_16_2->get(r,c); case 3: return plane_8_2->get(r,c); default: return plane_frame_lookbacks->get(r,c); } #ifdef SUPPORT_HDR } else { switch(p) { case 0: return plane_16_1->get(r,c); case 1: return plane_32_1->get(r,c); case 2: return plane_32_2->get(r,c); case 3: return plane_16_2->get(r,c); default: return plane_frame_lookbacks->get(r,c); } } #endif }
void drop_alpha() { if (num<4) return; assert(num==4); if (depth <= 8) { plane_8_2.reset(nullptr); } else { plane_16_2.reset(nullptr); } num=3; }
void ParticleSystem::collide(ParticlePtr part, PlanePtr plane) { //SimonState::exemplar()->messages << "Cloth: Kollision Kugel vs. Ebene gestartet" << SimonState::endm; float distance = dot(part->getPosition() - plane->getRigidBody()->getPosition(), plane->getNormal()); Vector3<float> n = plane->getNormal(); Vector3<float> v = part->getVelocity(); float vDotN = dot (v, n); //Vector3<float> f = getRigidBody()->getForce(); // no resting contact. check collision if ( distance <= 3.0) { if (vDotN<=0.5f) { // normal colliding contact: Vector3 <float> velPart = part->getVelocity(); Vector3 <float> normPlane = plane->getNormal(); normPlane.normalize(); float vDoN = dot(velPart, normPlane); normPlane *= vDoN; part->setVelocity(part->getVelocity() - normPlane); //cout << "Vel aus col " << part->getVelocity()<< endl; normPlane = plane->getNormal(); normPlane.normalize(); Vector3 <float> forcePart = part->getForce(); float fDotN = dot(forcePart, normPlane); normPlane *= fDotN; part->addForce((-1) * normPlane); //cout << "Acc aus Col " << part->getAcceleration() << endl; // factor in elasticity // geschummelt (eigentlich getBounciness) //vDotN *= 1 + 2.5f; // reflect veloctiy along normal //part->setVelocity( Vector3<float>(v[X] - vDotN*n[X], v[Y] - vDotN*n[Y], v[Z] - vDotN*n[Z])); SimonState::exemplar()->messages << "Cloth: Kollision Particle vs. Ebene beendet" << SimonState::endm; } } }
void clear() { plane_8_1.reset(nullptr); plane_8_2.reset(nullptr); plane_16_1.reset(nullptr); plane_16_2.reset(nullptr); plane_frame_lookbacks.reset(nullptr); #ifdef SUPPORT_HDR plane_32_1.reset(nullptr); plane_32_2.reset(nullptr); #endif }
void set(int p, uint32_t r, uint32_t c, ColorVal x) { assert(p>=0); #ifdef SUPPORT_HDR if (depth <= 8) { #endif switch(p) { case 0: return plane_8_1->set(r,c,x); case 1: return plane_16_1->set(r,c,x); case 2: return plane_16_2->set(r,c,x); case 3: return plane_8_2->set(r,c,x); default: return plane_frame_lookbacks->set(r,c,x); } #ifdef SUPPORT_HDR } else { switch(p) { case 0: return plane_16_1->set(r,c,x); case 1: return plane_32_1->set(r,c,x); case 2: return plane_32_2->set(r,c,x); case 3: return plane_16_2->set(r,c,x); default: return plane_frame_lookbacks->set(r,c,x); } } #endif }
void drop_frame_lookbacks() { assert(num==5); plane_frame_lookbacks.reset(nullptr); num=4; }