BOOL LLPartData::pack(LLDataPacker &dp) { LLColor4U coloru; dp.packU32(mFlags, "pdflags"); dp.packFixed(mMaxAge, "pdmaxage", FALSE, 8, 8); coloru.setVec(mStartColor); dp.packColor4U(coloru, "pdstartcolor"); coloru.setVec(mEndColor); dp.packColor4U(coloru, "pdendcolor"); dp.packFixed(mStartScale.mV[0], "pdstartscalex", FALSE, 3, 5); dp.packFixed(mStartScale.mV[1], "pdstartscaley", FALSE, 3, 5); dp.packFixed(mEndScale.mV[0], "pdendscalex", FALSE, 3, 5); dp.packFixed(mEndScale.mV[1], "pdendscaley", FALSE, 3, 5); return TRUE; }
void LLVOClouds::getGeometry(S32 idx, LLStrider<LLVector4a>& verticesp, LLStrider<LLVector3>& normalsp, LLStrider<LLVector2>& texcoordsp, LLStrider<LLColor4U>& colorsp, LLStrider<U16>& indicesp) { if (idx >= mCloudGroupp->getNumPuffs()) { return; } LLDrawable* drawable = mDrawable; LLFace *facep = drawable->getFace(idx); if (!facep->hasGeometry()) { return; } const LLCloudPuff &puff = mCloudGroupp->getPuff(idx); LLColor4 float_color(LLColor3(gSky.getSunDiffuseColor() + gSky.getSunAmbientColor()),puff.getAlpha()); LLColor4U color; color.setVec(float_color); facep->setFaceColor(float_color); U32 vert_offset = facep->getGeomIndex(); LLVector4a part_pos_agent; part_pos_agent.load3(facep->mCenterLocal.mV); LLVector4a at; at.load3(LLViewerCamera::getInstance()->getAtAxis().mV); LLVector4a up(0, 0, 1); LLVector4a right; right.setCross3(at, up); right.normalize3fast(); up.setCross3(right, at); up.normalize3fast(); right.mul(0.5f*CLOUD_PUFF_WIDTH); up.mul(0.5f*CLOUD_PUFF_HEIGHT); LLVector3 normal(0.f,0.f,-1.f); //HACK -- the verticesp->mV[3] = 0.f here are to set the texture index to 0 (particles don't use texture batching, maybe they should) // this works because there is actually a 4th float stored after the vertex position which is used as a texture index // also, somebody please VECTORIZE THIS LLVector4a ppapu; LLVector4a ppamu; ppapu.setAdd(part_pos_agent, up); ppamu.setSub(part_pos_agent, up); verticesp->setSub(ppapu, right); (*verticesp++).getF32ptr()[3] = 0.f; verticesp->setSub(ppamu, right); (*verticesp++).getF32ptr()[3] = 0.f; verticesp->setAdd(ppapu, right); (*verticesp++).getF32ptr()[3] = 0.f; verticesp->setAdd(ppamu, right); (*verticesp++).getF32ptr()[3] = 0.f; // *verticesp++ = puff_pos_agent - right + up; // *verticesp++ = puff_pos_agent - right - up; // *verticesp++ = puff_pos_agent + right + up; // *verticesp++ = puff_pos_agent + right - up; *colorsp++ = color; *colorsp++ = color; *colorsp++ = color; *colorsp++ = color; *texcoordsp++ = LLVector2(0.f, 1.f); *texcoordsp++ = LLVector2(0.f, 0.f); *texcoordsp++ = LLVector2(1.f, 1.f); *texcoordsp++ = LLVector2(1.f, 0.f); *normalsp++ = normal; *normalsp++ = normal; *normalsp++ = normal; *normalsp++ = normal; *indicesp++ = vert_offset + 0; *indicesp++ = vert_offset + 1; *indicesp++ = vert_offset + 2; *indicesp++ = vert_offset + 1; *indicesp++ = vert_offset + 3; *indicesp++ = vert_offset + 2; }
void LLVOClouds::getGeometry(S32 te, LLStrider<LLVector3>& verticesp, LLStrider<LLVector3>& normalsp, LLStrider<LLVector2>& texcoordsp, LLStrider<LLColor4U>& colorsp, LLStrider<U16>& indicesp) { if (te >= mCloudGroupp->getNumPuffs()) { return; } LLDrawable* drawable = mDrawable; LLFace *facep = drawable->getFace(te); if (!facep->hasGeometry()) { return; } LLVector3 normal(0.f,0.f,-1.f); const LLCloudPuff &puff = mCloudGroupp->getPuff(te); S32 index_offset = facep->getGeomIndex(); LLColor4 float_color(LLColor3(gSky.getSunDiffuseColor() + gSky.getSunAmbientColor()),puff.getAlpha()); LLColor4U color; color.setVec(float_color); facep->setFaceColor(float_color); LLVector3 up; LLVector3 right; LLVector3 at; const LLVector3& puff_pos_agent = facep->mCenterLocal; LLVector2 uvs[4]; uvs[0].setVec(0.f, 1.f); uvs[1].setVec(0.f, 0.f); uvs[2].setVec(1.f, 1.f); uvs[3].setVec(1.f, 0.f); LLVector3 vtx[4]; at = LLViewerCamera::getInstance()->getAtAxis(); right = at % LLVector3(0.f, 0.f, 1.f); right.normVec(); up = right % at; up.normVec(); right *= 0.5f*CLOUD_PUFF_WIDTH; up *= 0.5f*CLOUD_PUFF_HEIGHT;; *colorsp++ = color; *colorsp++ = color; *colorsp++ = color; *colorsp++ = color; vtx[0] = puff_pos_agent - right + up; vtx[1] = puff_pos_agent - right - up; vtx[2] = puff_pos_agent + right + up; vtx[3] = puff_pos_agent + right - up; verticesp->mV[3] = 0.f; *verticesp++ = vtx[0]; verticesp->mV[3] = 0.f; *verticesp++ = vtx[1]; verticesp->mV[3] = 0.f; *verticesp++ = vtx[2]; verticesp->mV[3] = 0.f; *verticesp++ = vtx[3]; *texcoordsp++ = uvs[0]; *texcoordsp++ = uvs[1]; *texcoordsp++ = uvs[2]; *texcoordsp++ = uvs[3]; *normalsp++ = normal; *normalsp++ = normal; *normalsp++ = normal; *normalsp++ = normal; *indicesp++ = index_offset + 0; *indicesp++ = index_offset + 1; *indicesp++ = index_offset + 2; *indicesp++ = index_offset + 1; *indicesp++ = index_offset + 3; *indicesp++ = index_offset + 2; }
U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_declaration, eControlType declare_as) { U32 item = 0; U32 validitems = 0; llifstream file; S32 version; file.open(filename.c_str()); /*Flawfinder: ignore*/ if (!file) { llinfos << "LLControlGroup::loadFromFile unable to open." << llendl; return 0; } // Check file version LLString name; file >> name; file >> version; if (name != "version" || version != CURRENT_VERSION) { llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl; return 0; } while (!file.eof()) { file >> name; if (name.empty()) { continue; } if (name.substr(0,2) == "//") { // This is a comment. char buffer[MAX_STRING]; /*Flawfinder: ignore*/ file.getline(buffer, MAX_STRING); continue; } BOOL declared = mNameTable.find(name) != mNameTable.end(); if (require_declaration && !declared) { // Declaration required, but this name not declared. // Complain about non-empty names. if (!name.empty()) { //read in to end of line char buffer[MAX_STRING]; /*Flawfinder: ignore*/ file.getline(buffer, MAX_STRING); llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl; } continue; } // Got an item. Load it up. item++; // If not declared, assume it's a string if (!declared) { switch(declare_as) { case TYPE_COL4: declareColor4(name, LLColor4::white, LLString::null, NO_PERSIST); break; case TYPE_COL4U: declareColor4U(name, LLColor4U::white, LLString::null, NO_PERSIST); break; case TYPE_STRING: default: declareString(name, LLString::null, LLString::null, NO_PERSIST); break; } } // Control name has been declared in code. LLControlBase *control = getControl(name); llassert(control); mLoadedSettings.insert(name); switch(control->mType) { case TYPE_F32: { F32 initial; file >> initial; control->set(initial); validitems++; } break; case TYPE_S32: { S32 initial; file >> initial; control->set(initial); validitems++; } break; case TYPE_U32: { U32 initial; file >> initial; control->set((LLSD::Integer) initial); validitems++; } break; case TYPE_BOOLEAN: { char boolstring[256]; /*Flawfinder: ignore*/ BOOL valid = FALSE; BOOL initial = FALSE; file >> boolstring; if (!strcmp("TRUE", boolstring)) { initial = TRUE; valid = TRUE; } else if (!strcmp("FALSE", boolstring)) { initial = FALSE; valid = TRUE; } if (valid) { control->set(initial); } else { llinfos << filename << "Item " << item << ": Invalid BOOL control " << name << ", " << boolstring << llendl; } validitems++; } break; case TYPE_STRING: { LLString string; file >> string; control->set(string); validitems++; } break; case TYPE_VEC3: { F32 x, y, z; file >> x >> y >> z; LLVector3 vector(x, y, z); control->set(vector.getValue()); validitems++; } break; case TYPE_VEC3D: { F64 x, y, z; file >> x >> y >> z; LLVector3d vector(x, y, z); control->set(vector.getValue()); validitems++; } break; case TYPE_RECT: { S32 left, bottom, width, height; file >> left >> bottom >> width >> height; LLRect rect; rect.setOriginAndSize(left, bottom, width, height); control->set(rect.getValue()); validitems++; } break; case TYPE_COL4U: { S32 red, green, blue, alpha; LLColor4U color; file >> red >> green >> blue >> alpha; color.setVec(red, green, blue, alpha); control->set(color.getValue()); validitems++; } break; case TYPE_COL4: { LLColor4 color; file >> color.mV[VRED] >> color.mV[VGREEN] >> color.mV[VBLUE] >> color.mV[VALPHA]; control->set(color.getValue()); validitems++; } break; case TYPE_COL3: { LLColor3 color; file >> color.mV[VRED] >> color.mV[VGREEN] >> color.mV[VBLUE]; control->set(color.getValue()); validitems++; } break; } } file.close(); return validitems; }