Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes #472

Merged
merged 6 commits into from Apr 12, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 30 additions & 6 deletions src/away3d/containers/ObjectContainer3D.as
Expand Up @@ -340,7 +340,8 @@ package away3d.containers
var m : Number;

while (i < len) {
m = _children[i++].minX;
var child:ObjectContainer3D = _children[i++];
m = child.minX + child.x;
if (m < min)
min = m;
}
Expand All @@ -359,7 +360,8 @@ package away3d.containers
var m : Number;

while (i < len) {
m = _children[i++].minY;
var child:ObjectContainer3D = _children[i++];
m = child.minY + child.y;
if (m < min)
min = m;
}
Expand All @@ -378,7 +380,8 @@ package away3d.containers
var m : Number;

while (i < len) {
m = _children[i++].minZ;
var child:ObjectContainer3D = _children[i++];
m = child.minZ + child.z;
if (m < min)
min = m;
}
Expand All @@ -398,7 +401,8 @@ package away3d.containers
var m : Number;

while (i < len) {
m = _children[i++].maxX;
var child:ObjectContainer3D = _children[i++];
m = child.maxX + child.x;
if (m > max)
max = m;
}
Expand All @@ -417,7 +421,8 @@ package away3d.containers
var m : Number;

while (i < len) {
m = _children[i++].maxY;
var child:ObjectContainer3D = _children[i++];
m = child.maxY + child.y;
if (m > max)
max = m;
}
Expand All @@ -436,7 +441,8 @@ package away3d.containers
var m : Number;

while (i < len) {
m = _children[i++].maxZ;
var child:ObjectContainer3D = _children[i++];
m = child.maxZ + child.z;
if (m > max)
max = m;
}
Expand Down Expand Up @@ -599,6 +605,24 @@ package away3d.containers

if (childIndex == -1) throw new Error("Parameter is not a child of the caller");

removeChildInternal(childIndex, child);
}


/**
* Removes a 3d object from the child array of the container
*
* @param index Index of 3d object to be removed
*/
public function removeChildAt(index:uint):void
{
var child:ObjectContainer3D = _children[index];

removeChildInternal(index, child);
}

private function removeChildInternal(childIndex:uint, child:ObjectContainer3D):void
{
// index is important because getChildAt needs to be regular.
_children.splice(childIndex, 1);

Expand Down
10 changes: 10 additions & 0 deletions src/away3d/containers/Scene3D.as
Expand Up @@ -90,6 +90,16 @@ package away3d.containers
_sceneGraphRoot.removeChild(child);
}

/**
* Removes a child from the scene's root.
* @param index Index of child to be removed from the scene.
*/
public function removeChildAt(index : uint) : void
{
_sceneGraphRoot.removeChildAt(index);
}


/**
* Retrieves the child with the given index
* @param index The index for the child to be retrieved.
Expand Down
5 changes: 5 additions & 0 deletions src/away3d/core/base/CompactSubGeometry.as
Expand Up @@ -55,6 +55,11 @@ package away3d.core.base
var numVertices : int = _vertexData.length / 13;
if (numVertices != _numVertices) disposeVertexBuffers(_vertexBuffer);
_numVertices = numVertices;

if (_numVertices == 0)
{
throw new Error("Bad data: geometry can't have zero triangles");
}

invalidateBuffers(_vertexDataInvalid);

Expand Down
2 changes: 2 additions & 0 deletions src/away3d/core/base/SubGeometryBase.as
Expand Up @@ -673,6 +673,7 @@ package away3d.core.base
vector.y = normals[i1];
vector.z = normals[i2];
vector = invTranspose.deltaTransformVector(vector);
vector.normalize();
normals[ni0] = vector.x;
normals[i1] = vector.y;
normals[i2] = vector.z;
Expand All @@ -688,6 +689,7 @@ package away3d.core.base
vector.y = tangents[i1];
vector.z = tangents[i2];
vector = invTranspose.deltaTransformVector(vector);
vector.normalize();
tangents[ti0] = vector.x;
tangents[i1] = vector.y;
tangents[i2] = vector.z;
Expand Down
3 changes: 2 additions & 1 deletion src/away3d/core/managers/Mouse3DManager.as
Expand Up @@ -53,7 +53,6 @@ package away3d.core.managers

public function updateCollider(view : View3D) : void
{
_previousCollidingObject = _collidingObject;

if (view == _activeView && (_forceMouseMove || _updateDirty)) { // If forceMouseMove is off, and no 2D mouse events dirtied the update, don't update either.
_collidingObject = _mousePicker.getViewCollision(view.mouseX, view.mouseY, view);
Expand Down Expand Up @@ -94,6 +93,8 @@ package away3d.core.managers
dispatcher.dispatchEvent(event);
}
_queuedEvents.length = 0;

_previousCollidingObject = _collidingObject;
}

// ---------------------------------------------------------------------
Expand Down
10 changes: 6 additions & 4 deletions src/away3d/loaders/parsers/OBJParser.as
Expand Up @@ -355,10 +355,12 @@ package away3d.loaders.parsers
translateVertexData(face, j+1, vertices, uvs, indices, normals);
}
}

subs = GeomUtil.fromVectors(vertices, indices, uvs, normals, null, null, null);
for (i=0; i<subs.length; i++) {
geometry.addSubGeometry(subs[i]);
if (vertices.length > 0)
{
subs = GeomUtil.fromVectors(vertices, indices, uvs, normals, null, null, null);
for (i=0; i<subs.length; i++) {
geometry.addSubGeometry(subs[i]);
}
}
}

Expand Down