Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
SantyWang committed Oct 16, 2023
1 parent e20e9c6 commit 61d1e43
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 94 deletions.
9 changes: 4 additions & 5 deletions cocos/particle/Impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export declare namespace Impl {
addModule(module: ParticleSystemModule): void;
removeModule(module: ParticleSystemModule): void;
}
export class ParticleSystemRenderer {
setFlip(x: number, y: number, z: number): void;
setPivot(x: number, y: number, z: number): void;
}

export class ParticleSystemManager {
static getInstance(): ParticleSystemManager;
Expand Down Expand Up @@ -233,11 +237,6 @@ export declare namespace Impl {

export class RectangleShape extends Shape {}

export class Renderer extends ParticleSystemModule {
setFlip(x: number, y: number, z: number): void;
setPivot(x: number, y: number, z: number): void;
}

export class RotationBySpeed extends ParticleSystemModule {
setSeparateAxes(separateAxes: boolean): void;
getAngularVelocityX(): CurveRange;
Expand Down
1 change: 0 additions & 1 deletion cocos/particle/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ export enum ParticleSystemModuleStage {
SPAWN,
PRE_SOLVE_UPDATE,
POST_SOLVE_UPDATE,
RENDER
}

export const meshPosition = new Attribute(AttributeName.ATTR_POSITION, Format.RGB32F, false, 0); // mesh position
Expand Down
38 changes: 0 additions & 38 deletions cocos/particle/modules/renderer.ts

This file was deleted.

27 changes: 26 additions & 1 deletion cocos/particle/particle-system-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
THE SOFTWARE.
*/

import { ccclass, visible, override, executeInEditMode, requireComponent, menu } from 'cc.decorator';
import { ccclass, visible, override, executeInEditMode, requireComponent, menu, serializable, type, tooltip } from 'cc.decorator';
import { legacyCC } from '../core/global-exports';
import { ModelRenderer } from '../misc';
import { scene } from '../render-scene';
Expand All @@ -36,6 +36,31 @@ import { Material } from '../asset/assets';
@executeInEditMode
@requireComponent(ParticleSystem)
export class ParticleSystemRenderer extends ModelRenderer {
@type(Vec3)
@tooltip('i18n:ParticleSystem.Renderer.flip')
public get flip (): Readonly<Vec3> {
return this._flip;
}

public set flip (val: Readonly<Vec3>) {
Vec3.copy(this._flip, val);
}

@type(Vec3)
@tooltip('i18n:ParticleSystem.Renderer.pivot')
public get pivot (): Readonly<Vec3> {
return this._pivot;
}

public set pivot (val: Readonly<Vec3>) {
Vec3.copy(this._pivot, val);
}

@serializable
private _flip = new Vec3();
@serializable
private _pivot = new Vec3();

@override
@visible(false)
get sharedMaterials (): (Material | null)[] {
Expand Down
11 changes: 2 additions & 9 deletions cocos/particle/particle-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
*/

// eslint-disable-next-line max-len
import { ccclass, help, executeInEditMode, executionOrder, menu, tooltip, displayOrder, type, range, serializable, rangeMin, rangeStep } from 'cc.decorator';
import { ccclass, help, executeInEditMode, executionOrder, menu, tooltip, type, range, serializable, rangeMin } from 'cc.decorator';
import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { Curve } from '../animation/tracks/track';
import { assertIsTrue, CCBoolean, CCFloat, CCInteger, clamp01, Enum, warn } from '../core';
import { Component } from '../scene-graph/component';
import { CurveRange } from './curve-range';
import { CoordinateSpace, CullingMode, PlaybackState, ScalingMode, ShapeType } from './define';
import { Impl } from './impl';
import { BoxShape, CircleShape, ColorBySpeed, ColorOverLifetime, ConeShape, CurlNoiseOverLifetime, CustomData, DampenOverLifetime, DonutShape, DragOverLifetime, EdgeShape, EmissionByBurst, EmissionOverDistance, EmissionOverTime, ForceOverLifetime, GravityOverLifetime, InheritStartVelocity, InheritVelocityOverLifetime, LinearVelocityOverLifetime, OrbitalVelocityOverLifetime, RectangleShape, Renderer, RotationBySpeed, RotationOverLifetime, Shape, SizeBySpeed, SizeOverLifetime, SpeedMultiplierOverLifetime, SphereShape, StartColor, StartLifetime, StartLifetimeByEmitterSpeed, StartRotation, StartSize, StartSpeed, TextureSheetAnimation, Trail } from './modules';
import { BoxShape, CircleShape, ColorBySpeed, ColorOverLifetime, ConeShape, CurlNoiseOverLifetime, CustomData, DampenOverLifetime, DonutShape, DragOverLifetime, EdgeShape, EmissionByBurst, EmissionOverDistance, EmissionOverTime, ForceOverLifetime, GravityOverLifetime, InheritStartVelocity, InheritVelocityOverLifetime, LinearVelocityOverLifetime, OrbitalVelocityOverLifetime, RectangleShape, RotationBySpeed, RotationOverLifetime, Shape, SizeBySpeed, SizeOverLifetime, SpeedMultiplierOverLifetime, SphereShape, StartColor, StartLifetime, StartLifetimeByEmitterSpeed, StartRotation, StartSize, StartSpeed, TextureSheetAnimation, Trail } from './modules';
import { ParticleSystemModule } from './particle-system-module';

/**
Expand Down Expand Up @@ -387,12 +386,6 @@ export class ParticleSystem extends Component {
return this.getModule(Trail);
}

@type(Renderer)
@tooltip('i18n:ParticleSystem.renderer')
public get renderer (): Renderer | null {
return this.getModule(Renderer);
}

/**
* @en Whether this particle system is playing or not.
* @zh 粒子系统是否正在播放。
Expand Down
3 changes: 1 addition & 2 deletions native/cocos/particle/Define.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,4 @@ enum class ParticleSystemModuleStage : uint8_t {
SPAWN,
PRE_SOLVE_UPDATE,
POST_SOLVE_UPDATE,
RENDER
}
};
6 changes: 0 additions & 6 deletions native/cocos/particle/ParticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ void ParticleSystem::addModule(ParticleSystemModule& module) {
case ParticleSystemModuleStage::POST_SOLVE_UPDATE:
_postSolveUpdateModules.push_back(&module);
break;
case ParticleSystemModuleStage::RENDER:
_renderModules.push_back(&module);
break;
}
}

Expand All @@ -62,9 +59,6 @@ void ParticleSystem::removeModule(ParticleSystemModule& module) {
case ParticleSystemModuleStage::POST_SOLVE_UPDATE:
stage = &_postSolveUpdateModules;
break;
case ParticleSystemModuleStage::RENDER:
stage = &_renderModules;
break;
}

auto& index = std::find(stage->begin(), stage->end(), &module);
Expand Down
1 change: 0 additions & 1 deletion native/cocos/particle/ParticleSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,5 @@ class ParticleSystem {
std::vector<ParticleSystemModule*> _spawnModules{};
std::vector<ParticleSystemModule*> _preSolveUpdateModules{};
std::vector<ParticleSystemModule*> _postSolveUpdateModules{};
std::vector<ParticleSystemModule*> _renderModules{};
};
};
31 changes: 0 additions & 31 deletions native/cocos/particle/modules/Renderer.h

This file was deleted.

0 comments on commit 61d1e43

Please sign in to comment.