Exemplo n.º 1
0
bool TextInStream::GetLine(char *s, int size) {
	if (size <= 0) return true;
	if (!FillBuffer()) return false;
	if (size == 1) { *s=0; return true; }
	size--;
		
	while (true) {
		if (pos >= count && !FillBuffer()) break;
		char *b = buffer.ptr() + pos;
		char *e = buffer.ptr() + count;
		
		for (; b < e; b++) if (*b =='\n') break;
		
		if (size > 0) 
		{
			int n = b - (buffer.ptr() + pos);
			if (n > size) n = size;
			memcpy(s, buffer.ptr() + pos, n);
			size -= n;
			s += n;
		}
			
		pos = b - buffer.ptr();
			
		if (b < e) {
			pos++;
			break;
		}
	}
	*s = 0;
	
	return true;
}
 _TesselatedKdTreeLeafNode(const _PreallocatedArray<_TesselatedKdTreeBoxedPrimitive*>& p, int depth) {
     type = _KD_LEAF;
     prims.resize((uint32_t)p.size());
     for(uint32_t i = 0; i < prims.size(); i ++) {
         prims[i] = p[i]->prim;
     }
 }
 virtual void CollectStats(StatsManager& stats, int depth) {
     StatsCounterVariable* leafNodes = stats.GetVariable<StatsCounterVariable>("Ray Engine", "Kd Leaf Nodes");
     StatsDistributionVariable* leafPrims = stats.GetVariable<StatsDistributionVariable>("Ray Engine", "Kd Leaf Prims");
     StatsDistributionVariable* leafDepth = stats.GetVariable<StatsDistributionVariable>("Ray Engine", "Kd Leaf Depth");
     StatsCounterVariable* memory = stats.GetVariable<StatsCounterVariable>("Ray Engine", "Kd Memory");
     leafNodes->Increment();
     leafPrims->Value(prims.size());
     leafDepth->Value(depth);
     memory->Increment(static_cast<double>(sizeof(*this) + prims.size()*sizeof(RayPrimitive*)));
 }
Exemplo n.º 4
0
void TriangleTesselationCache::AddQuads(const carray<Vec3f>& pos, const carray<Vec3f>& normal, const carray<Vec2f>& uv, const carray<Vec4i>& quads) {
    // check if they have normals
    if(!normal.empty()) {
        AddTriangles(pos, normal, uv, ElementOperations::QuadsToTriangles(quads));
    } else {
        carray<Vec4i> newQuads;
        ElementOperations::UnshareForFaceNormals(pos, 
            (!uv.empty())?uv:carray<Vec2f>(pos.size(),Vec2f(0,0)), 
            ElementOperations::QuadNormals(pos, quads),
            quads,
            this->pos, this->normal, this->uv, newQuads);
        this->triangles = ElementOperations::QuadsToTriangles(newQuads);
    }

    _UpdateBBox();
}
Exemplo n.º 5
0
void TriangleTesselationCache::AddTriangles(const carray<Vec3f>& pos, const carray<Vec3f>& normal, const carray<Vec2f>& uv, const carray<Vec3i>& triangles) {
    // check if they have normals
    if(!normal.empty()) {
        this->pos = pos;
        this->normal = normal;
        if(!uv.empty()) this->uv = uv;
        else { this->uv.resize(pos.size()); this->uv.set(0.5); }
        this->triangles = triangles;
    } else {
        ElementOperations::UnshareForFaceNormals(pos, 
            (!uv.empty())?uv:carray<Vec2f>(pos.size(),Vec2f(0,0)), 
            ElementOperations::TriangleNormals(pos, triangles),
            triangles,
            this->pos, this->normal, this->uv, this->triangles);
    }

    _UpdateBBox();
}
Exemplo n.º 6
0
void TBToolTip::Paint(wal::GC &gc, const crect &paintRect)
{
	gc.SetFillColor(UiGetColor(uiBackground, 0,0, 0xFFFFFF)/*GetColor(IC_BG)*/); //0x80FFFF);
	crect r = ClientRect();
	gc.FillRect(r);
	gc.SetTextColor(UiGetColor(uiColor, 0,0, 0)/*GetColor(IC_TEXT)*/);
	//gc.TextOutF(0,0,text.ptr());
	 DrawStaticText(gc, 2, 1, text.ptr(), GetFont(), false);
}
Exemplo n.º 7
0
bool SysOptDialog::Command(int id, int subId, Win *win, void *data)
{
	if (id == 1000) {
		CfgLangDialog dlg((NCDialogParent*)Parent(), curLangId.ptr(), &list);
		if (dlg.DoModal() == CMD_OK)
		{
			SetCurLang(dlg.GetId());
		}
		return true;
	}
	return NCVertDialog::Command(id, subId, win, data);
}
Exemplo n.º 8
0
void TextOutStream::Put(const char *s, int size)
{
	while (size > 0) 
	{
		if (pos >= bufSize) Flush();
		int n = bufSize - pos;
		if (n > size) n = size;
		memcpy(buffer.ptr()+pos, s, n);
		pos += n;
		size-=n;
		s+=n;
	}
}
Exemplo n.º 9
0
void fft(carray& x, carray& roots) {
    int N = x.size();
    if (N <= 1) return;
    carray even = x[slice(0, N/2, 2)];
    carray odd = x[slice(1, N/2, 2)];
    carray rs = roots[slice(0, N/2, 2)];
    fft(even, rs);
    fft(odd, rs);
    for (int k = 0; k < N / 2; ++k) {
        auto t = roots[k] * odd[k];
        x[k    ] = even[k] + t;
        x[k+N/2] = even[k] - t;
    }
}
Exemplo n.º 10
0
shared_ptr<Image<shared_ptr<GatherTree> > > GatherForestBuilder::Build( shared_ptr<Scene> scene, shared_ptr<RayEngine> engine, uint32_t width, uint32_t height, uint32_t samples, carray<float> &timeInstantces, shared_ptr<ReportHandler> report /*= shared_ptr<ReportHandler>()*/ )
{
    shared_ptr<Image<shared_ptr<GatherTree> > > forest = 
        shared_ptr<Image<shared_ptr<GatherTree> > >(new Image<shared_ptr<GatherTree> >(width, height));
    StratifiedPathSamplerMT sampler;

    Vec2f pixelSize(1.0f/width, 1.0f/height);

    _tsample = timeInstantces.size();

    if(report) report->beginActivity("Build Gather Forest");

    for(uint32_t j = 0; j < height; j ++) 
    {
        for(uint32_t i = 0; i < width; i ++) 
        {
            vector<GatherPoint> points;
            sampler.BeginPixel(_tsample);
            for (uint32_t s = 0; s < samples; s++)
            {
                Vec2f puv = (Vec2f(Vec2i(i,j)) + sampler.Pixel()) * pixelSize;
                uint32_t ts = clamp<uint32_t>(static_cast<uint32_t>(sampler.Time() * _tsample), 0, _tsample - 1);
                Ray ray = scene->MainCamera()->GenerateRay(puv, sampler.Lens(), timeInstantces[ts]);

                Intersection isect;
                if(engine->Intersect(ray, &isect))
                {
                    GatherPoint point;
                    point.position = isect.dp.P;
                    point.normal = isect.dp.N;
                    point.ms = isect.m;
                    point.timeInst = s;
                    points.push_back(point);
                }
                sampler.NextPixelSample();
            }
            sampler.EndPixel();
            shared_ptr<GatherTree> tree = _BuildTree(points);
            if(report) report->progress((float)j / (float)(height));
        }
    }
    if(report) report->endActivity();
    return forest;
}
Exemplo n.º 11
0
	void Flush(){ 	if (pos>0) { Write(buffer.ptr(), pos); pos = 0; } }
Exemplo n.º 12
0
	TextOutStream(int _bSize = 1024):bufSize(_bSize>0 ? _bSize : 1024), pos(0){ buffer.alloc(bufSize); }
Exemplo n.º 13
0
	TextInStream(int _bSize = 1024):bufSize(_bSize>0 ? _bSize : 1024), count(1), pos(1){ buffer.alloc(bufSize); }
Exemplo n.º 14
0
	bool FillBuffer(){ if (pos < count) return true; if ( count <= 0) return false; count = Read(buffer.ptr(), bufSize); pos = 0; return count>0; }
    void Print(FILE* f, int depth) {
		for(int i = 0; i < depth*2; i ++) fputc(' ', f);
		fprintf(f, "leaf with %d\n", prims.size());
	}