Example #1
0
    //int childMeshReadies = 0;
    //MeshData meshHolder = null;
    //// the marching cubes dispatcher calls this once mesh is ready
    //public void ReceiveMesh(MeshData data) {
    //    if (parent != null) {
    //        parent.childMeshReadies++;
    //    }
    //    meshHolder = data;
    //}

    public void SplitResolve(MeshData[] data)
    {
        SetSplitting(false);
        if (!ShouldSplit())
        {
            return; // this is probably bad. because children elements are not null at this point but just forgetting about it
        }

        for (int i = 0; i < 8; ++i)
        {
            Octree c = children[i];
            c.SetupChunk();
            c.AssignMesh(data[i]);
            c.obj.go.transform.parent = obj.go.transform;
            c.SetGeomorph();
        }
        obj.mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        if (depth > 0)
        {
            obj.ov.shouldDraw = false;
        }
        hasChildren = true;

        timeSinceCreation = 0.0f;   // now used to fade yourself out
        SetGeomorph();
    }
Example #2
0
    //public void SplitComputeResolve(MeshData[] meshes) {
    //    SetSplitting(false);
    //    if (!ShouldSplit() && depth > 0) {
    //        return; // just throw out all that work, and shed a single tear :'(
    //    }

    //    children = new Octree[8];
    //    hasChildren = true;
    //    for (int i = 0; i < 8; ++i) {
    //        Vector3 coff = childOffsets[i];
    //        Octree child = new Octree(body, this, localArea.center + coff * SIZE * voxelSize * .25f, depth + 1, i);
    //        children[i] = child;

    //        child.BuildGameObject(meshes[i]);
    //        child.obj.go.transform.parent = obj.go.transform;
    //        child.SetGeomorph();
    //    }

    //    obj.mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
    //    if (depth > 0) {
    //        obj.ov.shouldDraw = true;
    //    }

    //    timeSinceCreation = 0.0f;   // now used to fade yourself out
    //    SetGeomorph();

    //}

    public void SplitResolveCompute()
    {
        if (childMeshCount != 8)
        {
            Debug.LogWarning(childMeshCount);
        }

        SetSplitting(false);
        if (!ShouldSplit() && depth > 0)
        {
            return;
        }

        children = new Octree[8];
        for (int i = 0; i < 8; ++i)
        {
            Octree child = new Octree(body, this, GetChildCenter(i), depth + 1, i);
            children[i] = child;
            child.SetupChunk();
            child.AssignMesh(childMeshes[i]);
            child.obj.go.transform.parent = obj.go.transform;
            child.SetGeomorph();
        }
        obj.mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        if (depth > 0)
        {
            obj.ov.shouldDraw = true;
        }
        hasChildren = true;

        timeSinceCreation = 0.0f;   // now used to fade yourself out
        SetGeomorph();
    }