int dupl(int n) { /* duplicate the subtree whose root is n, return ptr to it */ int i; i = name[n]; if(i < NCH) return(mn0(i)); switch(i){ case RNULLS: return(mn0(i)); case RCCL: case RNCCL: return(mnp(i,ptr[n])); case FINAL: case S1FINAL: case S2FINAL: return(mn1(i,left[n])); case STAR: case QUEST: case PLUS: case CARAT: return(mn1(i,dupl(left[n]))); case RSTR: case RSCON: return(mn2(i,dupl(left[n]),right[n])); case BAR: case RNEWE: case RCAT: case DIV: return(mn2(i,dupl(left[n]),dupl(right[n]))); # ifdef DEBUG default: warning("bad switch dupl %d",n); # endif } return(0); }
TEST(monom, can_getnext) { monom *mn = new monom(4, 5, NULL); monom mn2(5, 4); ASSERT_NO_THROW(mn2.setnext(NULL)); }
void sphere::contactSphere(const sphere& s, vec3& v, float& f) const { vec3 mn1(c - r), mx1(c + r); vec3 mn2(s.c - s.r), mx2(s.c + s.r); if(mn2 < mn1) mn1 = mn2; if(mx2 > mx1) mx1 = mx2; v = vec3((mx1 + mn1) / 2.0f); mn1 = (mx1 - mn1) / 2.0f; f = max(mn1.z, max(mn1.x, mn1.y)); }
/* Gets node tile from any place relative to block. Returns TILE_NODE if doesn't exist or should not be drawn. */ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, NodeModMap &temp_mods) { TileSpec spec; spec = mn.getTile(face_dir); /* Check temporary modifications on this node */ /*core::map<v3s16, NodeMod>::Node *n; n = m_temp_mods.find(p); // If modified if(n != NULL) { struct NodeMod mod = n->getValue();*/ NodeMod mod; if(temp_mods.get(p, &mod)) { if(mod.type == NODEMOD_CHANGECONTENT) { MapNode mn2(mod.param); spec = mn2.getTile(face_dir); } if(mod.type == NODEMOD_CRACK) { /* Get texture id, translate it to name, append stuff to name, get texture id */ // Get original texture name u32 orig_id = spec.texture.id; std::string orig_name = g_texturesource->getTextureName(orig_id); // Create new texture name std::ostringstream os; os<<orig_name<<"^[crack"<<mod.param; // Get new texture u32 new_id = g_texturesource->getTextureId(os.str()); /*dstream<<"MapBlock::getNodeTile(): Switching from " <<orig_name<<" to "<<os.str()<<" (" <<orig_id<<" to "<<new_id<<")"<<std::endl;*/ spec.texture = g_texturesource->getTexture(new_id); } } return spec; }
int main(){ // double r=2.0; // double i=3.0; Zespolone a=zes(20.0,32.0); Zespolone b=zes(4.0,4.0); dod2(&a,&b); printz(b); b=zes(4.0,4.0); a=zes(20.0,32.0); printz(*dod(a,b)); od2(&a,&b); printz(b); b=zes(4.0,4.0); a=zes(20.0,32.0); printz(*od(a,b)); mn2(&a,&b); printz(b); b=zes(4.0,4.0); a=zes(20.0,32.0); printz(*mn(a,b)); dziel2(&a,&b); printz(b); b=zes(4.0,4.0); a=zes(20.0,32.0); printz(*dziel(a,b)); return 0;}