Merge branch 'v3' into v3-win10

This commit is contained in:
Dale Stammen 2015-08-18 11:07:38 -07:00
commit 47b72ba30e
9 changed files with 53 additions and 42 deletions

View File

@ -251,7 +251,7 @@ void FontAtlas::findNewCharacters(const std::u16string& u16Text, std::unordered_
else
{
auto length = u16Text.length();
newChars.resize(length);
newChars.reserve(length);
for (size_t i = 0; i < length; ++i)
{
auto outIterator = _letterDefinitions.find(u16Text[i]);

View File

@ -66358,8 +66358,7 @@ bool js_cocos2dx_TMXLayer_getTileGIDAt(JSContext *cx, uint32_t argc, jsval *vp)
cocos2d::Vec2 arg0;
cocos2d::TMXTileFlags_* arg1;
ok &= jsval_to_vector2(cx, args.get(0), &arg0);
#pragma warning NO CONVERSION TO NATIVE FOR TMXTileFlags_*
ok = false;
uint32_t tempData;arg1=(cocos2d::TMXTileFlags_*)&tempData;ok &= jsval_to_uint32(cx, args.get(1), (uint32_t *)&arg1);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_getTileGIDAt : Error processing arguments");
unsigned int ret = cobj->getTileGIDAt(arg0, arg1);
jsval jsret = JSVAL_NULL;
@ -66652,7 +66651,7 @@ bool js_cocos2dx_TMXLayer_setTileGID(JSContext *cx, uint32_t argc, jsval *vp)
ok &= jsval_to_vector2(cx, args.get(1), &arg1);
if (!ok) { ok = true; break; }
cocos2d::TMXTileFlags_ arg2;
ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2);
ok &= jsval_to_uint32(cx, args.get(2), (uint32_t *)&arg2);
if (!ok) { ok = true; break; }
cobj->setTileGID(arg0, arg1, arg2);
args.rval().setUndefined();

View File

@ -116,8 +116,7 @@ int iterPath(const char *fpath, const struct stat *sb, int typeflag)
{
if(typeflag == FTW_F)
{
auto len = strlen(fpath);
if (len > 9 && strcmp(".material", fpath + len - 9) == 0)
if (FileUtils::getInstance()->getFileExtension(fpath) == ".material")
PUMaterialCache::Instance()->loadMaterials(fpath);
}
return 0;
@ -152,9 +151,9 @@ bool PUMaterialCache::loadMaterialsFromSearchPaths( const std::string &fileFolde
std::string seg("/");
while ((fileName = AAssetDir_getNextFileName(dir)) != nullptr)
{
std::string fullpath = fileFolder + seg + std::string(fileName);
if (strlen(fileName) > 9 && (strcmp(".material", fileName + strlen(fileName) - 9) == 0))
if (FileUtils::getInstance()->getFileExtension(fileName) == ".material")
{
std::string fullpath = fileFolder + seg + std::string(fileName);
loadMaterials(fullpath);
}
}
@ -179,9 +178,9 @@ bool PUMaterialCache::loadMaterialsFromSearchPaths( const std::string &fileFolde
continue;
}
std::string fullpath = fileFolder + "/" + file->d_name;
if (strlen(file->d_name) > 9 && (strcmp(".material", file->d_name + strlen(file->d_name) - 9) == 0))
if (FileUtils::getInstance()->getFileExtension(file->d_name) == ".material")
{
std::string fullpath = fileFolder + "/" + file->d_name;
CCLOG("%s", fullpath.c_str());
loadMaterials(fullpath);
state = true;

View File

@ -226,7 +226,7 @@ void PUMaterialPassTranslator::translate( PUScriptCompiler* compiler, PUAbstract
PUAbstractNodeList::const_iterator end = prop->values.end();
unsigned int n = 0;
Vec4 color;
float shininess;
float shininess = 0.0f;
while(it != end)
{
float v = 0;

View File

@ -87,15 +87,19 @@ void PUParticle3D::initForEmission()
// Reset freeze flag
freezed = false;
for (auto it : behaviours) {
it->initParticleForEmission(this);
if (!behaviours.empty()){
for (auto &it : behaviours) {
it->initParticleForEmission(this);
}
}
}
void PUParticle3D::initForExpiration( float timeElapsed )
{
for (auto it : behaviours) {
it->initParticleForExpiration(this, timeElapsed);
if (!behaviours.empty()){
for (auto &it : behaviours) {
it->initParticleForExpiration(this, timeElapsed);
}
}
}
@ -103,8 +107,10 @@ void PUParticle3D::process( float timeElapsed )
{
timeFraction = (totalTimeToLive - timeToLive) / totalTimeToLive;
for (auto it : behaviours) {
it->updateBehaviour(this, timeElapsed);
if (!behaviours.empty()){
for (auto &it : behaviours) {
it->updateBehaviour(this, timeElapsed);
}
}
}
@ -422,7 +428,7 @@ void PUParticleSystem3D::resumeParticleSystem()
void PUParticleSystem3D::update(float delta)
{
if (_isMarkedForEmission) return;
if (!_isEnabled || _isMarkedForEmission) return;
if (_state != State::RUNNING){
if (_state == State::PAUSE)
return;
@ -1165,13 +1171,14 @@ void PUParticleSystem3D::removeAllListener()
void PUParticleSystem3D::draw( Renderer *renderer, const Mat4 &transform, uint32_t flags )
{
if (!_isEnabled) return;
if (getAliveParticleCount() <= 0) return;
if (_render)
_render->render(renderer, transform, this);
if (!_emittedSystemParticlePool.empty())
{
for (auto iter : _emittedSystemParticlePool)
for (auto &iter : _emittedSystemParticlePool)
{
PUParticle3D *particle = static_cast<PUParticle3D *>(iter.second.getFirst());
while (particle)
@ -1185,6 +1192,7 @@ void PUParticleSystem3D::draw( Renderer *renderer, const Mat4 &transform, uint32
void PUParticleSystem3D::processParticle( ParticlePool &pool, bool &firstActiveParticle, bool &firstParticle, float elapsedTime )
{
Vec3 scale = getDerivedScale();
PUParticle3D *particle = static_cast<PUParticle3D *>(pool.getFirst());
//Mat4 ltow = getNodeToWorldTransform();
//Vec3 scl;
@ -1257,7 +1265,7 @@ void PUParticleSystem3D::processParticle( ParticlePool &pool, bool &firstActiveP
// particle->heightInWorld = scl.y * particle->height;
// particle->depthInWorld = scl.z * particle->depth;
//}
processMotion(particle, elapsedTime, firstActiveParticle);
processMotion(particle, elapsedTime, scale, firstActiveParticle);
}
else{
initParticleForExpiration(particle, elapsedTime);
@ -1298,7 +1306,7 @@ bool PUParticleSystem3D::makeParticleLocal( PUParticle3D* particle )
return true;
}
void PUParticleSystem3D::processMotion( PUParticle3D* particle, float timeElapsed, bool firstParticle )
void PUParticleSystem3D::processMotion( PUParticle3D* particle, float timeElapsed, const Vec3 &scl, bool firstParticle )
{
if (particle->isFreezed())
return;
@ -1345,11 +1353,10 @@ void PUParticleSystem3D::processMotion( PUParticle3D* particle, float timeElapse
particle->direction *= (_maxVelocity / particle->direction.length());
}
Vec3 scale = getDerivedScale();
// Update the position with the direction.
particle->position.add(particle->direction.x * scale.x * _particleSystemScaleVelocity * timeElapsed
, particle->direction.y * scale.y * _particleSystemScaleVelocity * timeElapsed
, particle->direction.z * scale.z * _particleSystemScaleVelocity * timeElapsed);
particle->position.add(particle->direction.x * scl.x * _particleSystemScaleVelocity * timeElapsed
, particle->direction.y * scl.y * _particleSystemScaleVelocity * timeElapsed
, particle->direction.z * scl.z * _particleSystemScaleVelocity * timeElapsed);
}
void PUParticleSystem3D::calulateRotationOffset( void )
@ -1379,7 +1386,7 @@ int PUParticleSystem3D::getAliveParticleCount() const
sz += _particlePool.getActiveDataList().size();
if (!_emittedEmitterParticlePool.empty()){
for (auto iter : _emittedEmitterParticlePool){
for (auto &iter : _emittedEmitterParticlePool){
sz += iter.second.getActiveDataList().size();
}
}
@ -1387,7 +1394,7 @@ int PUParticleSystem3D::getAliveParticleCount() const
if (_emittedSystemParticlePool.empty())
return sz;
for (auto iter : _emittedSystemParticlePool){
for (auto &iter : _emittedSystemParticlePool){
auto pool = iter.second;
sz += pool.getActiveDataList().size();
PUParticle3D *particle = static_cast<PUParticle3D *>(pool.getFirst());

View File

@ -371,7 +371,7 @@ protected:
void executeEmitParticles(PUEmitter* emitter, unsigned requested, float elapsedTime);
void emitParticles(ParticlePool &pool, PUEmitter* emitter, unsigned requested, float elapsedTime);
void processParticle(ParticlePool &pool, bool &firstActiveParticle, bool &firstParticle, float elapsedTime);
void processMotion(PUParticle3D* particle, float timeElapsed, bool firstParticle);
void processMotion(PUParticle3D* particle, float timeElapsed, const Vec3 &scl, bool firstParticle);
void notifyRescaled(const Vec3 &scl);
void initParticleForEmission(PUParticle3D* particle);
void initParticleForExpiration(PUParticle3D* particle, float timeElapsed);

View File

@ -164,35 +164,36 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4 &transform, P
}
Vec3 halfwidth = particle->width * 0.5f * right;
Vec3 halfheight = particle->height * 0.5f * up;
Vec3 offset = halfwidth * offsetX + halfheight * offsetY;
//transform.transformPoint(particle->position, &position);
position = particle->position;
if (_rotateType == TEXTURE_COORDS){
float costheta = cosf(-particle->zRotation);
float sintheta = sinf(-particle->zRotation);
Vec2 texOffset = particle->lb_uv + 0.5f * (particle->rt_uv - particle->lb_uv);
Vec2 texOffset = 0.5f * (particle->lb_uv + particle->rt_uv);
Vec2 val;
val.set((particle->lb_uv.x - texOffset.x), (particle->lb_uv.y - texOffset.y));
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
fillVertex(vertexindex, (position + (- halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(val.x + texOffset.x, val.y + texOffset.y));
fillVertex(vertexindex, (position + (-halfwidth - halfheight + offset)), particle->color, val + texOffset);
val.set(particle->rt_uv.x - texOffset.x, particle->lb_uv.y - texOffset.y);
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
fillVertex(vertexindex + 1, (position + (halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(val.x + texOffset.x, val.y + texOffset.y));
fillVertex(vertexindex + 1, (position + (halfwidth - halfheight + offset)), particle->color, val + texOffset);
val.set(particle->lb_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
fillVertex(vertexindex + 2, (position + (- halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(val.x + texOffset.x, val.y + texOffset.y));
fillVertex(vertexindex + 2, (position + (-halfwidth + halfheight + offset)), particle->color, val + texOffset);
val.set(particle->rt_uv.x - texOffset.x, particle->rt_uv.y - texOffset.y);
val.set(val.x * costheta - val.y * sintheta, val.x * sintheta + val.y * costheta);
fillVertex(vertexindex + 3, (position + (halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(val.x + texOffset.x, val.y + texOffset.y));
fillVertex(vertexindex + 3, (position + (halfwidth + halfheight + offset)), particle->color, val + texOffset);
}else{
Mat4::createRotation(backward, -particle->zRotation, &pRotMat);
fillVertex(vertexindex , (position + pRotMat * (- halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, particle->lb_uv);
fillVertex(vertexindex + 1, (position + pRotMat * (halfwidth - halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(particle->rt_uv.x, particle->lb_uv.y));
fillVertex(vertexindex + 2, (position + pRotMat * (- halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, Vec2(particle->lb_uv.x, particle->rt_uv.y));
fillVertex(vertexindex + 3, (position + pRotMat * (halfwidth + halfheight + halfwidth * offsetX + halfheight * offsetY)), particle->color, particle->rt_uv);
fillVertex(vertexindex , (position + pRotMat * (- halfwidth - halfheight + offset)), particle->color, particle->lb_uv);
fillVertex(vertexindex + 1, (position + pRotMat * (halfwidth - halfheight + offset)), particle->color, Vec2(particle->rt_uv.x, particle->lb_uv.y));
fillVertex(vertexindex + 2, (position + pRotMat * (-halfwidth + halfheight + offset)), particle->color, Vec2(particle->lb_uv.x, particle->rt_uv.y));
fillVertex(vertexindex + 3, (position + pRotMat * (halfwidth + halfheight + offset)), particle->color, particle->rt_uv);
}
fillTriangle(index, vertexindex, vertexindex + 1, vertexindex + 3);
@ -454,6 +455,8 @@ void PUParticle3DModelRender::render( Renderer* renderer, const Mat4 &transform,
continue;
}
sprite->setTexture(_texFile);
sprite->setBlendFunc(particleSystem->getBlendFunc());
sprite->setCullFaceEnabled(false);
sprite->retain();
_spriteList.push_back(sprite);
}
@ -488,9 +491,11 @@ void PUParticle3DModelRender::render( Renderer* renderer, const Mat4 &transform,
mat.m[12] = particle->position.x;
mat.m[13] = particle->position.y;
mat.m[14] = particle->position.z;
if (_spriteList[index]->getCameraMask() != particleSystem->getCameraMask())
_spriteList[index]->setCameraMask(particleSystem->getCameraMask());
_spriteList[index]->setColor(Color3B(particle->color.x * 255, particle->color.y * 255, particle->color.z * 255));
_spriteList[index]->setOpacity(particle->color.w * 255);
_spriteList[index]->draw(renderer, mat, 0);
_spriteList[index]->visit(renderer, mat, Node::FLAGS_DIRTY_MASK);
++index;
}
}

View File

@ -260,9 +260,10 @@ void AssetsManager::update()
// 1. Urls of package and version should be valid;
// 2. Package should be a zip file.
if (_versionFileUrl.size() == 0 ||
_packageUrl.size() == 0 ||
std::string::npos == _packageUrl.find(".zip"))
if (_versionFileUrl.empty()
|| _packageUrl.empty()
|| FileUtils::getInstance()->getFileExtension(_packageUrl) != ".zip"
)
{
CCLOG("no version file url, or no package url, or the package is not a zip file");
_isDownloading = false;

View File

@ -11,6 +11,6 @@ varying vec2 v_texCoord;
void main()
{
gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;
gl_Position = CC_PMatrix * a_position;
v_texCoord = a_texCoord;
}