Search in sources :

Example 31 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.

the class ServerImpl method sendEntities.

private void sendEntities(NetData.NetMessage.Builder message) {
    TIntIterator dirtyIterator = netDirty.iterator();
    while (dirtyIterator.hasNext()) {
        int netId = dirtyIterator.next();
        EntityRef entity = networkSystem.getEntity(netId);
        if (isOwned(entity)) {
            Set<Class<? extends Component>> emptyComponentClassSet = Collections.emptySet();
            EntityData.PackedEntity entityData = entitySerializer.serialize(entity, emptyComponentClassSet, changedComponents.get(netId), emptyComponentClassSet, new ClientComponentFieldCheck());
            if (entityData != null) {
                message.addUpdateEntity(NetData.UpdateEntityMessage.newBuilder().setEntity(entityData).setNetId(netId));
            }
        }
    }
    netDirty.clear();
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator) EntityData(org.terasology.protobuf.EntityData) Component(org.terasology.gestalt.entitysystem.component.Component) NetworkComponent(org.terasology.engine.network.NetworkComponent) BlockComponent(org.terasology.engine.world.block.BlockComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponentFieldCheck(org.terasology.engine.network.serialization.ClientComponentFieldCheck)

Example 32 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.

the class GLTFCommonFormat method loadBones.

protected List<Bone> loadBones(GLTF gltf, GLTFSkin skin, List<byte[]> loadedBuffers) {
    List<Bone> bones = new ArrayList<>();
    TIntIntMap boneToJoint = new TIntIntHashMap();
    List<Matrix4f> inverseMats = loadInverseMats(skin.getInverseBindMatrices(), skin.getJoints().size(), gltf, loadedBuffers);
    for (int i = 0; i < skin.getJoints().size(); i++) {
        int nodeIndex = skin.getJoints().get(i);
        GLTFNode node = gltf.getNodes().get(nodeIndex);
        Vector3f position = new Vector3f();
        Quaternionf rotation = new Quaternionf();
        Vector3f scale = new Vector3f(1, 1, 1);
        if (node.getTranslation() != null) {
            position.set(node.getTranslation());
        }
        if (node.getRotation() != null) {
            rotation.set(node.getRotation());
        }
        if (node.getScale() != null) {
            scale.set(node.getScale());
        }
        String boneName = node.getName();
        if (Strings.isNullOrEmpty(boneName)) {
            boneName = "bone_" + i;
        }
        Bone bone = new Bone(i, boneName, new Matrix4f().translationRotateScale(position, rotation, scale));
        bone.setInverseBindMatrix(inverseMats.get(i));
        bones.add(bone);
        boneToJoint.put(nodeIndex, i);
    }
    for (int i = 0; i < skin.getJoints().size(); i++) {
        int nodeIndex = skin.getJoints().get(i);
        GLTFNode node = gltf.getNodes().get(nodeIndex);
        Bone bone = bones.get(i);
        TIntIterator iterator = node.getChildren().iterator();
        while (iterator.hasNext()) {
            bone.addChild(bones.get(boneToJoint.get(iterator.next())));
        }
    }
    return bones;
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) TFloatArrayList(gnu.trove.list.array.TFloatArrayList) Quaternionf(org.joml.Quaternionf) TIntIntMap(gnu.trove.map.TIntIntMap) Matrix4f(org.joml.Matrix4f) Vector3f(org.joml.Vector3f) GLTFNode(org.terasology.engine.rendering.gltf.model.GLTFNode) Bone(org.terasology.engine.rendering.assets.skeletalmesh.Bone) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap)

Example 33 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.

the class TroveUtils method intToFloat.

public static TFloatList intToFloat(TIntList list) {
    TFloatList result = new TFloatArrayList(list.size());
    TIntIterator iterator = list.iterator();
    while (iterator.hasNext()) {
        int i = iterator.next();
        result.add(i);
    }
    return result;
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator) TFloatList(gnu.trove.list.TFloatList) TFloatArrayList(gnu.trove.list.array.TFloatArrayList)

Example 34 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.

the class TroveUtils method intToLong.

public static TLongList intToLong(TIntList list) {
    TLongList result = new TLongArrayList(list.size());
    TIntIterator iterator = list.iterator();
    while (iterator.hasNext()) {
        int i = iterator.next();
        result.add(i);
    }
    return result;
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator) TLongArrayList(gnu.trove.list.array.TLongArrayList) TLongList(gnu.trove.list.TLongList)

Example 35 with TIntIterator

use of gnu.trove.iterator.TIntIterator in project Terasology by MovingBlocks.

the class TroveUtils method intToDouble.

public static TDoubleList intToDouble(TIntList list) {
    TDoubleList result = new TDoubleArrayList(list.size());
    TIntIterator iterator = list.iterator();
    while (iterator.hasNext()) {
        int i = iterator.next();
        result.add(i);
    }
    return result;
}
Also used : TDoubleList(gnu.trove.list.TDoubleList) TIntIterator(gnu.trove.iterator.TIntIterator) TDoubleArrayList(gnu.trove.list.array.TDoubleArrayList)

Aggregations

TIntIterator (gnu.trove.iterator.TIntIterator)39 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)13 BlockPos (net.minecraft.util.math.BlockPos)8 ArrayList (java.util.ArrayList)5 TIntArrayList (gnu.trove.list.array.TIntArrayList)4 TIntHashSet (gnu.trove.set.hash.TIntHashSet)4 IBlockState (net.minecraft.block.state.IBlockState)4 Chunk (net.minecraft.world.chunk.Chunk)4 EntityData (org.terasology.protobuf.EntityData)4 TIntList (gnu.trove.list.TIntList)3 HashSet (java.util.HashSet)3 ExtendedBlockStorage (net.minecraft.world.chunk.storage.ExtendedBlockStorage)3 Vector (ValkyrienWarfareBase.API.Vector)2 TFloatArrayList (gnu.trove.list.array.TFloatArrayList)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)2 VWChunkCache (ValkyrienWarfareBase.Relocation.VWChunkCache)1