bool kexWorldObject::TryMove(const kexVec3 &position, kexVec3 &dest, kexSector **sector) { traceInfo_t trace; trace.start = position; trace.end = dest; trace.dir = (trace.end - trace.start).Normalize(); trace.fraction = 1.0f; trace.hitActor = NULL; trace.hitTri = NULL; trace.hitMesh = NULL; trace.hitVector = trace.start; trace.owner = this; trace.sector = sector; if(InstanceOf(&kexFx::info)) { trace.bUseBBox = false; } else { trace.bUseBBox = true; trace.localBBox.min.Set(-(radius * 0.5f), 0, -(radius * 0.5f)); trace.localBBox.max.Set(radius * 0.5f, height, radius * 0.5f); trace.bbox = trace.localBBox; trace.bbox.min += position; trace.bbox.max += position; trace.bbox *= (dest - position); } localWorld.Trace(&trace); dest = trace.hitVector - (trace.dir * 0.05f); return (trace.fraction == 1); }
bool ChipStreamDataTransform::transformData(PsBoard &board, const DataStore &in, DataStore &out) { bool needTwoPass = false; if((InstanceOf(m_ChipStream, SketchQuantNormTran) && board.getOptions()->getOpt("target-sketch").empty()) || InstanceOf(m_ChipStream, ArtifactReduction)) { Verbose::out(1, "Doing two passes."); needTwoPass = true; } /* Send the chip data through the chipstream object. */ int numDataSets = in.getCelDataSetCount(); Verbose::progressBegin(1, ToStr("Processing Chips"), numDataSets, 1, numDataSets); std::vector<float> data; for(int chipIx = 0; chipIx < in.getCelDataSetCount(); chipIx++) { Verbose::progressStep(1); data.clear(); // Verbose::out(3, "Reading " + m_ChipStream->getDocName() + " for chip: " + ToStr(chipIx)); in.fillInCelData(chipIx, data); m_ChipStream->newChip(data); if(!needTwoPass) { for(int probeIx = 0; probeIx < data.size(); probeIx++) { data[probeIx] = m_ChipStream->transform(probeIx, chipIx, data[probeIx], board); } out.writeColumn(chipIx, in.getCelName(chipIx), data); } } Verbose::progressEnd(1, ToStr("Done.")); if(needTwoPass) { m_ChipStream->finishedChips(); Verbose::progressBegin(1, ToStr("Processing Stage Two Chips"), numDataSets, 1, numDataSets); /* Do the chipstream transformation and store the new intensities. */ for(int chipIx = 0; chipIx < in.getCelDataSetCount(); chipIx++) { Verbose::progressStep(1); // Verbose::out(3, "Applying " + m_ChipStream->getDocName() + " to chip: " + ToStr(chipIx)); std::vector<float> data; in.fillInCelData(chipIx, data); for(int probeIx = 0; probeIx < data.size(); probeIx++) { data[probeIx] = m_ChipStream->transform(probeIx, chipIx, data[probeIx]); } out.writeColumn(chipIx, in.getCelName(chipIx), data); } Verbose::progressEnd(1, ToStr("Done.")); } return true; }
bool kexWorldObject::Trace(traceInfo_t *trace) { kexVec2 org; kexVec2 dir; kexVec2 cDist; float cp; float rd; float r; if(bCollision == false) { return false; } // fx can't collide with each other nor with its owner if(trace->owner) { if(trace->owner->InstanceOf(&kexFx::info)) { if(InstanceOf(&kexFx::info)) { return false; } if(this == trace->owner->GetOwner()) { return false; } } // only fx can collide with objects else if(InstanceOf(&kexFx::info)) { return false; } } org = (origin - trace->start); dir = trace->dir; if(dir.Dot(org) <= 0) { return false; } float len = (trace->end - trace->start).Unit(); if(len == 0) { return false; } cp = dir.Dot(org); cDist = (org - (dir * cp)); r = radius + 8.192f; rd = r * r - cDist.UnitSq(); if(rd <= 0) { return false; } float frac = (cp - kexMath::Sqrt(rd)) * (1.0f / len); if(frac <= 1 && frac < trace->fraction) { kexVec3 hit; if(frac < 0) { frac = 0; } hit = trace->start.Lerp(trace->end, frac); if(hit[1] > origin[1] + height) { return false; } trace->hitActor = this; trace->fraction = frac; trace->hitVector = hit; trace->hitNormal = (hit - origin); trace->hitNormal[1] = 0; trace->hitNormal.Normalize(); return true; } return false; }